08.12.2011, 11:33
Well for starters, GivePlayerValidWeapon is not a native SAMP function. It's obviously part of an anticheat.
So to explain simply:
The code detects what guns the player has, saves them to an array if they DO NOT equal the gun to be removed.
Then it removes ALL of the player's guns.
Apon completion, it gives the player all of the guns stored in that array (so naturally minus the one you wanted to remove)
pawn Код:
stock RemovePlayerWeapon(playerid, weaponid) //declares the following code as a stock function.
{
new plyWeapons[13]; //declares a variable with array size 13 (this will store the player's current weapons)
for(new s = 0; s < 12; s++) //loops s from 0 to 11
{
new wep, ammo; //declares two empty variables
GetPlayerWeaponData(playerid, s, wep, ammo); //get's whatever weapons is at slot 's' for playerid and returns "wep" as weaponid and "ammo" as ammoid
if(wep != weaponid) //checks whether the detected gun is NOT the one specified in the function call
{
GetPlayerWeaponData(playerid, s, plyWeapons[s], ammo); // if not? return the information to plyWeapons at the index of 's' in the array. Also returns the ammo to 'ammo'
}
else //if wep DOES equal the weaponid specified on function call
{
PlayerInfo[playerid][pGuns][s] = 0; //enum'd array storing the player's information > the gun @ slot 's' is set to 0
PlayerInfo[playerid][pAGuns][s] = 0; //same as above, just set's a custom variable for storing the ammo to 0. this will later be saved in a db/file for later use
}
}
ResetPlayerWeapons(playerid); //at this point all of the player's weapons are removed.
for(new s = 0; s < 12; s++) // once again loop through 's' until it equals 11
{
GivePlayerValidWeapon(playerid, plyWeapons[s], 60000); //give the player back the weaponid stored in plyWeapons[]
}
return 1;
}
The code detects what guns the player has, saves them to an array if they DO NOT equal the gun to be removed.
Then it removes ALL of the player's guns.
Apon completion, it gives the player all of the guns stored in that array (so naturally minus the one you wanted to remove)