Reload of Weapons!!! - 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: Reload of Weapons!!! (
/showthread.php?tid=381719)
Reload of Weapons!!! -
BiosMarcel - 30.09.2012
Hello Peoples,
Is it possibile that the players must reload her weapons and not only change them 2 times?
Please help.
mfg Marcel
Re: Reload of Weapons!!! -
Mauzen - 30.09.2012
Most people will say thats impossible, but yep, thats indeed possible. [ame]http://www.youtube.com/watch?v=e1hQEVd1Ze8[/ame]
Though its quite hard, i did it with completely serversided weapons, but thats not neccessary. Im not going to reveal my code, its way too long to post here anyways.
Basically you need a way to detect when a player is shooting. You can e.g. do that with GetPlayerAmmo in OnPlayerUpdate to see how many shots a player fired. With that you can calculate how much ammo is left in a gun (by subtracting it from the weapons default clip size). Also in OnPlayerUpdate you can detect when a player switches his weapon, then store the remaining ammo of the last weapon, and apply the ammo for the new weapon. This might be the most difficult part. You could reduce the total ammo for that gun to the ammo for a single clip for example, and add new ammo on every weapon reload.
An alternative would be just giving a player a single clip of amunition, and never more. Then detect when hes out of ammo in OnPlayerUpdate and add the next clip to his ammo, until a variable containing the total left ammo is empty.