Skip to content
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

Add fixes for OnPlayerSpawn, OnPlayerKeyStateChange, OnPlayerStateChange #181

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AmyrAhmady
Copy link

This amazing PR adds three new fixes to one of the most used libraries of SA-MP community.

1. OnPlayerSpawn

I noticed while OnPlayerConnect is called when a filterscript loads, fixes.inc doesn't call OnPlayerSpawn for all spawned players. So imagine this situation: What if players are already spawned and user is doing some sort of initialization like some sort of cheat detection or something, and when script is loaded mid-game, that type of code never runs for players who are already spawned! This is such an important and required fix!
Also this fix internally is called FIX_OnPlayerSpawnCall since FIX_OnPlayerSpawn is taken. But I guess it shouldn't be a problem, if it is, let me know, I offer to quickly modify it based on your preferences.

2. OnPlayerKeyStateChange

Just like OnPlayerSpawn but this time for keys. What if a player is already holding a key and you load your filterscript? Then script's OnPlayerKeyStateChange would never get called, because there's no change yet! You may ask well why even call it then since there's no change? That's because players are already connected so why are you calling OnPlayerConnect? To fix it!

3. OnPlayerStateChange

This works just like both above, I need my filterscript to be aware when it's loaded and there are players in different states

Note:

This is my first time contributing to fixes.inc project, if there's any problem in my code and it goes against fixes.inc guidelines, let me know because I'm offering to fix my own mistakes for free. Thanks!

Maybe player is holding a key so your script never knows it's happening unless they press or unpress another key
@Cheaterman
Copy link

I can't believe fixes.inc missed those cases for a decade! Thanks for your amazing contribution to the SA-MP community.

@NexiusTailer
Copy link
Contributor

What about OnVehicleSirenStateChange? Should be very similar to KeyStateChange yet missed.

@ziggi
Copy link
Collaborator

ziggi commented Mar 7, 2024

What about this callbacks? I think they are should be in the list too.

  • OnActorStreamIn
  • OnEnterExitModShop
  • OnGameModeInit
  • OnIncomingConnection
  • OnNPCConnect
  • OnNPCModeInit
  • OnNPCSpawn
  • OnObjectMoved
  • OnPickupStreamIn
  • OnPlayerEnterCheckpoint
  • OnPlayerEnterGangZone
  • OnPlayerEnterPlayerGangZone
  • OnPlayerEnterRaceCheckpoint
  • OnPlayerEnterVehicle
  • OnPlayerFinishedDownloading
  • OnPlayerInteriorChange
  • OnPlayerObjectMoved
  • OnPlayerPickUpPickup
  • OnPlayerPickUpPlayerPickup
  • OnPlayerPickupStreamIn
  • OnPlayerRequestClass
  • OnPlayerRequestDownload
  • OnPlayerRequestSpawn
  • OnPlayerSelectObject
  • OnPlayerStreamIn

@Y-Less
Copy link
Member

Y-Less commented Mar 8, 2024

Are these callbacks called in a gamemode when it starts?

@AmyrAhmady
Copy link
Author

AmyrAhmady commented Mar 8, 2024

Of course not! I didn't know that's an important factor for this, because OnPlayerConnect isn't called in gamemode when it starts! It's called when "server" is restarted, not your gamemode, not your filterscript, the entire server therefore it has to emulate player disconnecting and reconnecting for all scripts on server restarts, because you want your players to join again when you stop and start again. I'm so sorry if samp client fakes server rejoin!

And if it's an important thing to consider, then my apologies, I forgot to add another fix to call OnGameModeInit when a filterscript starts at runtime, because that's the one and only callbacks that gets called when a gamemode is generally started.

So please, let me know if I should add this one too! because then we are missing it on filterscript reload!

@AbdulOmarCR
Copy link

This PR has been approved by me.

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.

6 participants