Skip to content

Lots of fixes and improvements #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
May 4, 2025

Conversation

NexiusTailer
Copy link
Contributor

@NexiusTailer NexiusTailer commented Apr 29, 2025

  1. Many formatting fixes, bringing code style to a more consistent level based on how most of the code in the project has been formatted up to this point. Updated previously broken links (like here or here), correct spelling of SA-MP name everywhere where it's mentioned
  2. Fixes for many typos which were found with Lua linter, pretty critical examples are this, this or this
  3. A bit more clear explanation of installation in README.md according to the latest improvements on releases page
  4. Update min client version from 1.5.5-9.14060 to 1.6.0-9.22457 since some functions require it now, also update notes about it in README.md
  5. Significant improvements in RCON implementation: server variables (those which printed on "varlist" in the server console or obtained via GetConsoleVarAs* pawn natives) updated for actual SA-MP 0.3.7 version list. They now also sync with MTA config settings where it's possible (where they fully match, like MTA's ase -> SA-MP's announce) and integrated with meta.xml or settings.xml, which means you can obtain any custom config variables from those config files with GetConsoleVarAs* functions (if a console variable isn't found in default variables list, it will try to get it from config files). New ACL right requests for "function.getServerPassword" and "function.setServerPassword" were added because more rcon variables (including password) were implemented, and it's now also noted in README.md
  6. More consistent return values: if some function returns ID starting from 0, invalid ID won't be "false" anymore (because false is anyway 0 in pawn), it uses more appropriate error return values instead. The same with bare 'return's which were presented in some places before, even considering that the function should return some specific value
  7. All functions which write strings in args by reference now return the string length which they just written, like SA-MP does. There are also improvements related to buffer size validation before it will write anything into it (early return if it's invalid; truncate string if it's less than needed and return the length of the final string written)
  8. Vehicles and objects start with ID 1 in SA-MP, while all other entities start with 0. Now objects follow this pattern as well as vehicles
  9. Implemented OnPlayerClickPlayer callback and fixed previously broken scoreboard functions (they depend on scoreboard default resource which is now correctly validated if it's running and only then it's used)
  10. Implemented OnPlayerWeaponShot and GetPlayerLastShotVectors
  11. Implemented OnPlayerGiveDamage, OnPlayerTakeDamage and OnPlayerGiveDamageActor
  12. Implemented OnVehicleDamageStatusUpdate callback
  13. Fixed OnPlayerDeath and OnBotDeath. killerid parameter can be only player type and now it's explicitly validated
  14. Fixed OnPlayerPickUpPickup callback, previously it didn't really work because of wrong event source
  15. CreatePlayerObject now has the same logic as CreateObject: if the object model was invalid (probably SA-MP object model passed), it will create an invisible dummy and throw a warning
  16. Fully completed PVar system and implemented SVar system
  17. Added all NPC functions as stubs/dummies (#16)
  18. Implemented GetPlayerVersion, GetGravity and GetPlayerTargetPlayer
  19. Bugfix in SA-MP classes system since the previous PR (there was an issue with spawning from class selection if pawn script didn't add any classes at all)
  20. Implemented GetNetworkStats and GetPlayerNetworkStats (based on MTA's getNetworkStats info)
  21. Implemented AttachCameraToPlayerObject, AttachObjectToObject and AttachPlayerObjectToVehicle (#33)
  22. Fixed gametext/textdraw color mapping, now all colors fully match GTA SA and SA-MP default colors (~g~, ~r~, ~y~ etc)
  23. GetVehicleParamsSirenState now returns whether a siren is added (as it should), and not the fact that it's currently toggled on
  24. Fixed SetPlayerArmedWeapon behaviour (previously it has wrongly taken weapon slot instead of weapon ID in this parameter)
  25. Implemented SetActorInvulnerable and IsActorInvulnerable
  26. Fixed IsValidActor which didn't work at all because of accessing to the wrong (objects) pool
  27. Implemented SetVehicleAngularVelocity (#60) and GetVehicleModelInfo (#88)
  28. Now ShowPlayerMarker has global/streamed mode toggler, and SetPlayerMapIcon has global/local style like in SA-MP. Mode "streamed" or style "local" is a feature to show marker or mapicon only if it's near the player position (it's in his stream zone). Global mode will still show marker or mapicon for player not considering the distances
  29. MoveObject and MovePlayerObject now has support for object rotations
  30. Implemented IsObjectMoving and IsPlayerObjectMoving (#87)
  31. GetPlayerWeaponState now does return WEAPONSTATE_RELOADING when actual reloading (#82)
  32. ShowPlayerDialog now handles dialogid -1 and closes the current shown dialog for a player like SA-MP does
  33. Fixed GetPlayerWeaponData, now it correctly updates weapons data once per second (if it changed). Previous behaviour of "update every 5 seconds" caused SA-MP script bugs as it was too big delay
  34. Implemented GetAnimationName (#83) and ApplyActorAnimation (#20)
  35. Fixed GetPlayerFacingAngle since it used deprecated getPedRotation function, moreover doing it incorrectly
  36. Implemented GetPlayerSurfingObjectID and GetPlayerSurfingVehicleID (#85)
  37. Implemented GetPlayerObjectModel and IsPlayerAttachedObjectSlotUsed
  38. Obsolete custom made functions binor, binand, binshr and binshl replaced with built-in and more relevant bitOr, bitAnd, bitRShift and bitLShift
  39. Implemented LimitPlayerMarkerRadius function (#15)
  40. ShowCursor has been renamed to ShowPlayerCursor on pawn side, since it's specifically player related (this is a more common naming pattern in SA-MP). Also, a counterpart has been implemented: IsPlayerCursorShowing
  41. SetScoreBoardData has been renamed to SetPlayerScoreBoardData on pawn side for the same reason
  42. Implemented additional db_ functions (#56) and improved parameter validations in existent ones
  43. Fixed return values ​​for GetWaveHeight and NetStats_PacketLossPercent (should've return float, although they returned int without proper conversion so it failed on the pawn script side)
  44. Added additional functions in a_amx.inc (from a_mta.lua) for players, vehicles and objects - mainly those which looks like were missed for some reason but still very useful
  45. Added additional functions in a_amx.inc (from a_mta.lua) for bots: (Add/Remove/Get)BotClothes, (Get/Set)BotInterior, (Get/Set)BotVirtualWorld, (Get/Set)BotSkillLevel, GetBotVehicleID, IsBotIn(Any)Vehicle, GetBot(Ammo/Weapon) to be a more substantial replacement for NPC/actors
  46. Glitches like 'quickreload', 'fastmove', 'fastfire', 'crouchbug', 'fastsprint' and 'quickstand' are now all enabled to be in line with SA-MP default gameplay
  47. World special properties like 'randomfoliage' and 'roadsignstext' are now disabled and 'snipermoon' is enabled to be in line with SA-MP default gameplay
  48. Ambient sounds of 'gunfire' type is now disabled to be in line with SA-MP default gameplay

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
also returned SetPlayerDisabledWeapons deprecation, many fixes to string length return in functions
and add a couple of earlier unimplemeted functions
No more "Sorry, but [native] is not implemented" when the server start, now all dummies are included and some of previously unimplemented dummies are implemented into working functions
and also new natives from MTA in a_amx.inc
by changing them to native bit* functions
obtain announce and lanmode correctly
Copy link
Collaborator

@colistro123 colistro123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed and tested the changes, and overall, they look good. I have left a few comments on some code I'd like to see adjusted.

For future PRs, it would be helpful if they were broken down a little bit more. This makes the review process more efficient for the person that has to go through it. I also noticed a couple of redundant elements, which add unnecessary noise to the review (I commented on those so said things can be avoided in the future).

Overall, creating smaller PRs makes it easier to spot issues and revert changes when needed, while also allowing other contributions to be merged more quickly. As the saying goes, it’s best not to put all your eggs in one basket.

Have a great weekend and thanks for your awesome contribution! 😊

spawnPlayerBySelectedClass(player)
--In samp calling TogglePlayerSpectating also unsets camera interpolation
clientCall(player, 'removeCamHandlers')
setElementAlpha(player, 255)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up above we're disabling all controls when spectating, but never re-enabling them.
I also add PLAYER_STATE_NONE to mirror OpenMP's behavior to some degree.

Suggested change
setElementAlpha(player, 255)
setElementAlpha(player, 255)
toggleAllControls(player, true, true, false)
setPlayerState(player, PLAYER_STATE_NONE)

Copy link
Contributor Author

@NexiusTailer NexiusTailer May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're actually enabling all player controls when he is spawned unconditionally (here), since SA-MP does it as well (you can freeze a player even directly with TogglePlayerControllable and he will be unfrozen after spawn anyway, so I replicated this behaviour). I can add some comment inside TogglePlayerSpectating to make it more clear because it can look like we really forgot about it.

As for setting state none when leaving spectate like in omp, it is actually a critical behaviour difference with SA-MP server and I reported about it there with reasons why. I suppose they did it to bypass some other issue, but created a new one.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're actually enabling all player controls when he is spawned unconditionally (here), since SA-MP does it as well (you can freeze a player even directly with TogglePlayerControllable and he will be unfrozen after spawn anyway, so I replicated this behaviour). I can add some comment inside TogglePlayerSpectating to make it more clear because it can look like we really forgot about it.

As for setting state none when leaving spectate like in omp, it is actually a critical behaviour difference with SA-MP server and I reported about it there with reasons why. I suppose they did it to bypass some other issue, but created a new one.

I agree on your points, but the current logic assumes we only spectate during one specific stage. It won't unfreeze the player or re-enable their controls if we for example say, behave as an administrator in a server and spectate a vehicle or player using TogglePlayerSpectating. When we're done spectating we will be frozen in place.

Comment on lines +176 to +178
if g_Players[playerID].doingclasssel then
return
end
Copy link
Collaborator

@colistro123 colistro123 May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're spectating don't send an event to show the UI. I believe this is what SA-MP does and it mirrors my gamemode's behavior in SA-MP (I tested this).

Suggested change
if g_Players[playerID].doingclasssel then
return
end
if g_Players[playerID].doingclasssel or g_Players[playerID].state == PLAYER_STATE_SPECTATING then
return
end

@colistro123
Copy link
Collaborator

I will merge this, in the future do please break down your PRs, I can't stress that enough. Do multiple PRs (Pull Requests) if needed so it gets easier to review.

Thanks! 😊

@NexiusTailer
Copy link
Contributor Author

NexiusTailer commented May 4, 2025

Thank you for merge, sure.

As for class selection logic and your latest fixes, I'll try to test it further and probably make a new PR with final improvements and solutions for it since yesterday I got stuck with some of MTA AMX specific features (namely viewingintro mode which causes some behavior difference with classes when using TogglePlayerSpectating in OnPlayerConnect), so I didn't decide how to handle this case to match SA-MP behavior better.

Also about some stale issues which seems not relevant anymore and probably could be closed with "Solved" label: #63, #33, #20, #15 and #4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants