SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 14/09/2019, 09:24 AM   #1
alvin6
Big Clucker
 
alvin6's Avatar
 
Join Date: Mar 2017
Posts: 58
Reputation: 2
Thumbs up Help with syncing RPG

im making serversided weapons and on OnPlayerWeaponShot every non-serversided weapon is being detect and player is getting kick but RPG is not being sync/detect in that

can anyone tell me where to sync RPG to check if its server sided or not?

PHP Code:
forward public OnPlayerWeaponShotplayeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ );
public 
OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    new 
weapname[32];
    
GetWeaponName(weaponidweapnamesizeof(weapname));
    if(
GetPVarInt(playeridweapname) < 1) return Kick(playerid);
    
SetPVarInt(playeridweapnameGetPVarInt(playeridweapname) -1);
    return 
1;

alvin6 is offline   Reply With Quote
Old 14/09/2019, 11:26 AM   #2
Plastikmensch
Huge Clucker
 
Join Date: Aug 2016
Posts: 272
Reputation: 27
Default Re: Help with syncing RPG

Just tested and OnPlayerWeaponShot doesn't get called when shooting RPGs, that's why it can't be detected.
You could check on OnPlayerGiveDamage, but that only gets called when another player gets hit. (And causes other problems as stated on the wiki page like weaponid being 51 (Explosion) for any explosive weapon)
Plastikmensch is offline   Reply With Quote
Old 14/09/2019, 02:26 PM   #3
alvin6
Big Clucker
 
alvin6's Avatar
 
Join Date: Mar 2017
Posts: 58
Reputation: 2
Default Re: Help with syncing RPG

Quote:
Originally Posted by Plastikmensch View Post
Just tested and OnPlayerWeaponShot doesn't get called when shooting RPGs, that's why it can't be detected.
You could check on OnPlayerGiveDamage, but that only gets called when another player gets hit. (And causes other problems as stated on the wiki page like weaponid being 51 (Explosion) for any explosive weapon)
Any other way to detect it? any help will be appreciated
alvin6 is offline   Reply With Quote
Old 14/09/2019, 02:33 PM   #4
Jonny
Huge Clucker
 
Jonny's Avatar
 
Join Date: Nov 2009
Location: Italy
Posts: 280
Reputation: 38
Default Re: Help with syncing RPG

Maybe you can check if there's a particular animation when shooting with RPG, or well, not that accurate but you could work with OnPlayerKeyStateChange and a timer but those will always be poor solutions
__________________
Jonny is offline   Reply With Quote
Old 14/09/2019, 02:36 PM   #5
alvin6
Big Clucker
 
alvin6's Avatar
 
Join Date: Mar 2017
Posts: 58
Reputation: 2
Default Re: Help with syncing RPG

Quote:
Originally Posted by darkdrago View Post
Maybe you can check if there's a particular animation when shooting with RPG, or well, not that accurate but you could work with OnPlayerKeyStateChange and a timer but those will always be poor solutions
will you mind if you can give example of OnPlayerKeyStateChange with my code please? so i can understand more
alvin6 is offline   Reply With Quote
Old 14/09/2019, 03:15 PM   #6
Jonny
Huge Clucker
 
Jonny's Avatar
 
Join Date: Nov 2009
Location: Italy
Posts: 280
Reputation: 38
Default Re: Help with syncing RPG

EDIT: This code was completely messy, i don't want people to take this sh*t, look down for the solution
__________________

Last edited by Jonny; 14/09/2019 at 05:43 PM.
Jonny is offline   Reply With Quote
Old 14/09/2019, 03:49 PM   #7
alvin6
Big Clucker
 
alvin6's Avatar
 
Join Date: Mar 2017
Posts: 58
Reputation: 2
Thumbs up Re: Help with syncing RPG

Quote:
Originally Posted by darkdrago View Post
https://paste.ofcode.org/mwgkKz5QBbujBniT9TGrLH
As i said above, might not be accurate but i don't see many ways to do it
Thanks for your help but its still not being detected/sync
alvin6 is offline   Reply With Quote
Old 14/09/2019, 05:33 PM   #8
Jonny
Huge Clucker
 
Jonny's Avatar
 
Join Date: Nov 2009
Location: Italy
Posts: 280
Reputation: 38
Default Re: Help with syncing RPG

Quote:
Originally Posted by alvin6 View Post
Thanks for your help but its still not being detected/sync
Just tested it and figured out it was completely messy.
I got another idea, and i tested it even if i don't really know if you wanna do it for an Anti Weapon Hack or something

https://paste.ofcode.org/UBZY2EB6ppUFvWMfpTaCwF

I tested it and seems working good, it sets the ammo every 500ms the fire key is holding (the half of the time RPG needs to shoot so it can be accurate as much as it can) in the client-side ammo ONLY if server-side has higher ammo, if player has more client-side ammo than server-side he gets detected as Weapon Hacker.
I left the SCM i used to debug and see how it was working, you can test it yourself
__________________

Last edited by Jonny; 14/09/2019 at 05:42 PM. Reason: Added comments in the code
Jonny is offline   Reply With Quote
Old 14/09/2019, 08:55 PM   #9
alvin6
Big Clucker
 
alvin6's Avatar
 
Join Date: Mar 2017
Posts: 58
Reputation: 2
Default Re: Help with syncing RPG

Quote:
Originally Posted by darkdrago View Post
Just tested it and figured out it was completely messy.
I got another idea, and i tested it even if i don't really know if you wanna do it for an Anti Weapon Hack or something

https://paste.ofcode.org/UBZY2EB6ppUFvWMfpTaCwF

I tested it and seems working good, it sets the ammo every 500ms the fire key is holding (the half of the time RPG needs to shoot so it can be accurate as much as it can) in the client-side ammo ONLY if server-side has higher ammo, if player has more client-side ammo than server-side he gets detected as Weapon Hacker.
I left the SCM i used to debug and see how it was working, you can test it yourself
Thank you for all your effort and help and its worked finally
alvin6 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
anims not syncing tommzy09 Scripting Help 6 10/04/2015 11:10 PM
Syncing SetPlayerTime? 2KY Scripting Help 3 26/02/2012 05:09 AM
De-syncing Grenades Benjo Help Archive 2 07/12/2010 02:49 PM
Animation syncing SkizzoTrick Help Archive 1 03/12/2010 10:10 PM
syncing help Annihalation Help Archive 2 18/07/2009 03:42 AM


All times are GMT. The time now is 05:33 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.