19.02.2017, 16:27
FIXED
To anyone having trouble with this:
Under OnPlayerUpdate:
The OnPlayerWeaponChange function:
GetGunSlot for getting the weapon slot (obviously):
No use of GetPlayerWeaponData leads to no bugs what so ever.
To anyone having trouble with this:
Under OnPlayerUpdate:
PHP код:
new currweapon = GetPlayerWeapon(playerid);
new lastweapon = GetPVarInt(playerid, "LastWeap");
if(currweapon != lastweapon)
{
OnPlayerWeaponChange(playerid, lastweapon, currweapon);
SetPVarInt(playerid, "LastWeap", currweapon);
}
PHP код:
stock OnPlayerWeaponChange(playerid, lastweap, newweap)
{
if(PlayerInfo[playerid][pGuns][11] != 46 && newweap == 46)
// Assigning the parachute to pGuns (because i.e., if you jump out of a hydra, you get a parachute)
{
PlayerInfo[playerid][pGuns][11] = 46;
return 1;
}
if(newweap != 0)
{
if(PlayerInfo[playerid][pGuns][GetGunSlot(newweap)] != newweap)
{
// ... your ban code
return 1;
}
}
return 1;
}
PHP код:
stock GetGunSlot(weaponid)
{
switch(weaponid)
{
case 0, 1: return 0;
case 2 .. 9: return 1;
case 10 .. 15: return 10;
case 16 .. 18, 39: return 8;
case 22 .. 24: return 2;
case 25 .. 27: return 3;
case 28, 29, 32: return 4;
case 30, 31: return 5;
case 33, 34: return 6;
case 35 .. 38: return 7;
case 40: return 12;
case 41 .. 43: return 9;
case 44 .. 46: return 11;
}
return -1;
}