03.10.2014, 15:13
I want to check if a player has a forbidden weapon regardless if it's armed or not.
I gave myself a forbidden weapon but codes below doesn't work.
I gave myself a forbidden weapon but codes below doesn't work.
pawn Код:
SetTimerEx("ss_weaponcheck", 1000, true, "d", playerid)
pawn Код:
new forbidden_weapon_list[39][2] =
{
{1, 0}, // weapon id - weapon's slot
{2, 1},
{3, 1},
{4, 1},
{5, 1},
{6, 1},
{7, 1},
{9, 1},
{10, 10},
{11, 10},
{12, 10},
{13, 10},
{14, 10},
{15, 10},
{16, 8},
{17, 8},
{18, 8},
{22, 2},
{23, 2},
{25, 3},
{26, 3},
{27, 3},
{28, 4},
{29, 4},
{31, 5},
{32, 4},
{33, 6},
{35, 7},
{36, 7},
{37, 7},
{38, 7},
{39, 8},
{40, 12},
{41, 9},
{42, 9},
{43, 9},
{44, 11},
{45, 11},
{46, 11}
};
pawn Код:
F:ss_weaponcheck(playerid)
{
new weapons[13][2], slot, y = 0;
for (new i = 0; i <= 12; i++)
{
GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
}
loop_start:
if(y < sizeof forbidden_weapon_list)
{
slot = forbidden_weapon_list[y][1];
if(weapons[slot][0] == forbidden_weapon_list[slot][0])
{
ResetPlayerWeapons(playerid);
if(CharacterData[playerid][W_Bullet] > 0)
{
if(CharacterData[playerid][W_Maingun] != 0)
{
GivePlayerWeapon(playerid, CharacterData[playerid][W_Maingun], CharacterData[playerid][W_Bullet]);
}
if(CharacterData[playerid][W_Handgun] != 0)
{
GivePlayerWeapon(playerid, CharacterData[playerid][W_Handgun], CharacterData[playerid][W_Bullet]);
}
SetPlayerArmedWeapon(playerid,0);
}
}
else
{
y++;
goto loop_start;
}
}
return 1;
}