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

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from

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

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! 😊

Comment on lines +5 to +8
{ x = 0, y = 0, z = 0, c = tocolor(0, 0, 0, 255) },
{ x = 0, y = 0, z = 0, c = tocolor(0, 0, 0, 255) },
{ x = 0, y = 0, z = 0, c = tocolor(0, 0, 0, 255) },
{ x = 0, y = 0, z = 0, c = tocolor(0, 0, 0, 255) }
Copy link
Collaborator

Choose a reason for hiding this comment

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

For now we can leave this, but I will advise against doing changes like these in the future. It simply creates noise, causing the review process to be lengthier.

addEvent('OnPlayerGiveDamageActor_Ev', true)
addEventHandler('OnPlayerGiveDamageActor_Ev', root,
function(actor, loss, weapon, bodypart)
if not actor or getElementData(actor, 'amx.invulnerable') then return end
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was changed to 'Invulnerable' via setElementData, meaning accessing it this way will most likely not work.

Comment on lines +301 to +305
GetVehicleModelInfo = {'i', 'i', 'r', 'r', 'r'},
GetVehicleParamsCarDoors = {'v', 'r', 'r', 'r', 'r'},
GetVehicleParamsEx = {'v', 'r', 'r', 'r', 'r', 'r', 'r', 'r'},
GetVehicleParamsSirenState = {'v'},
GetVehiclePoolSize = {},
Copy link
Collaborator

Choose a reason for hiding this comment

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

As I said for other things in my previous comment, let's avoid moving things like these in the future, there's no need to do so. 😊

playerdata.returntoclasssel = nil
putPlayerInClassSelection(player)
return true
else
spawnPlayerBySelectedClass(player)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If TogglePlayerSpectating is called too early (when loading player's data in order to spawn them) certain scripts might misbehave and cause the player to be kicked when OnPlayerSpawn kicks in (especially if there's checks to see if they have logged in and this executes prior to loading the player's data). Additionally, I believe this shouldn't be here.

I have tested this and it works fine for my specific use-case, it replicates just what SA-MP does.

Suggested change
spawnPlayerBySelectedClass(player)
--spawnPlayerBySelectedClass(player)

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)

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

oX = 0.0, oY = 0.0, oZ = 0.0,
hX = 0.0, hY = 0.0, hZ = 0.0
}
g_Players[playerID].conntick = getTickCount()
g_Players[playerID].viewingintro = true
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's also initialize the state as PLAYER_STATE_NONE.

Suggested change
g_Players[playerID].viewingintro = true
g_Players[playerID].viewingintro = true
g_Players[playerID].state = PLAYER_STATE_NONE

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