SA-MP Forums Archive
Get Player Weapons, before and after a cmd.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Get Player Weapons, before and after a cmd.. (/showthread.php?tid=468510)



Get Player Weapons, before and after a cmd.. - CesarLT - 08.10.2013

Hello everyone, so basically my problem is that I need the guns a player wears to save before he uses a cmd, and after 20 seconds (I've a settimerex), they shall return to his hands. How can I do that? Thanks in advance.


Re: Get Player Weapons, before and after a cmd.. - [EnErGyS]KING - 08.10.2013

Maybe just use OnPlayerUpdate ?


Re: Get Player Weapons, before and after a cmd.. - CesarLT - 08.10.2013

Quote:
Originally Posted by [EnErGyS]KING
Посмотреть сообщение
Maybe just use OnPlayerUpdate ?
Yeah, well if you could explain a bit, it's my 2nd week scripting actually..


Re: Get Player Weapons, before and after a cmd.. - iFiras - 08.10.2013

Quote:
Originally Posted by CesarLT
Посмотреть сообщение
Hello everyone, so basically my problem is that I need the guns a player wears to save before he uses a cmd, and after 20 seconds (I've a settimerex), they shall return to his hands. How can I do that? Thanks in advance.
You mean disarm player then reset his weapons after 20 seconds?
Or do a command to see a player's weps?


Re: Get Player Weapons, before and after a cmd.. - CesarLT - 08.10.2013

Quote:
Originally Posted by iFiras
Посмотреть сообщение
You mean disarm player then reset his weapons after 20 seconds?
Or do a command to see a player's weps?
I mean, that once he uses a cmd, (already scripted one), his weapons shall save and reset, and in 20 seconds, (also scripted), they shall return..how can I do that?


Re: Get Player Weapons, before and after a cmd.. - Konstantinos - 08.10.2013

When the player uses that command, use GetPlayerWeaponData to get the weapons and store them to an array. Then reset the player's weapon (if you want) and set the timer. When the timer's callback will be called, use loop again (like the example of GetPlayerWeaponData) and use GivePlayerWeapon instead. As the weaponid and ammo for parameters, you need to use the array (the index is the number of the loop).


Re: Get Player Weapons, before and after a cmd.. - [EnErGyS]KING - 08.10.2013

Just like I said use "OnPlayerUpdate"
and then save weapon.
http://pastebin.com/TaD5miwQ (not mine)


Re: Get Player Weapons, before and after a cmd.. - iFiras - 08.10.2013

Aww they did for you already -_-


Re: Get Player Weapons, before and after a cmd.. - DanishHaq - 08.10.2013

Quote:
Originally Posted by [EnErGyS]KING
Посмотреть сообщение
Just like I said use "OnPlayerUpdate"
and then save weapon.
http://pastebin.com/TaD5miwQ (not mine)
OnPlayerUpdate is called every 2-3 seconds per player (can and will change each time) as far as I know, you'd have to make a 20 second timer instead. OnPlayerUpdate is good for anti-money hacks, i.e. use a variable to store money and then just reset the player money there, and give them the variable money.


Re: Get Player Weapons, before and after a cmd.. - Konstantinos - 08.10.2013

Quote:
Originally Posted by DanishHaq
Посмотреть сообщение
OnPlayerUpdate is called every 2-3 seconds per player (can and will change each time) as far as I know, you'd have to make a 20 second timer instead. OnPlayerUpdate is good for anti-money hacks, i.e. use a variable to store money and then just reset the player money there, and give them the variable money.
It is called even more frequently than you said, more than 10 calls per second.