Prevent switch 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: Prevent switch weapons (
/showthread.php?tid=457223)
Prevent switch weapons -
JacobWilkerson - 10.08.2013
Hi all, are you okay?
I was wondering how to go about preventing the player to switch a heavy weapon (Style AK-47, shotgun, sniper etc.) to not have so many heavy weapons, unrealistic thing.
Bye.
Re: Prevent switch weapons -
BullseyeHawk - 10.08.2013
This is like an example:
- Tought if you want to make it fully support each gun, I'd recommand making a loop with data over them as you chose. And other values. You didn't give us a code to work with, this is the best I can make for you for now.
pawn Код:
new pastWI[MAX_PLAYERS];
OnPlayerConnect(playerid)
{
pastWI[playerid] = 0;
return 1;
}
OnPlayerUpdate(playerid)
{
new weaponid = GetPlayerWeapon(playerid);
if(weaponid != pastWI[playerid])
{
if(pastWI[playerid] == 24 && weaponid == 31)
{
SetPlayerArmedWeapon(playerid, 24);
}
}
}
Re : Prevent switch weapons -
JacobWilkerson - 10.08.2013
Suppose I have a gun (m4 id 31), if I want the switcher will remain in my hands?
Re: Prevent switch weapons -
BullseyeHawk - 10.08.2013
The switcher I showed above, detectes if old weapon as 24 (deagle). If it was and new weapon is suddenly 31, it'll switch back towards 24. I hope you understand that and that you'll need to do it yourself all of the other coding.
Again, I suggest making a loop with an enum/new values that loops trought them.
Re: Prevent switch weapons -
dEcooR - 10.08.2013
Yes so you should use loop example for all player weps player got,using geweapondata i guess