Reset Weapons. -
kubeba59 - 16.05.2014
Heu guys
I have a weapon system with the function GivePlayerWeapon,however,I also have a duty system with the same function and when I type /duty when I am on duty its reset
all my weapons.I would like to do that only the duty weapons will disappear,how can I do that ?
Re: Reset Weapons. -
Dignity - 16.05.2014
Usage:
pawn Код:
RemovePlayerWeapon(playerid, weaponid);
Code:
pawn Код:
stock RemovePlayerWeapon(playerid, weaponid)
{
new plyWeapons[12], plyAmmo[12];
for(new slot = 0; slot != 12; slot++)
{
new wep, ammo;
GetPlayerWeaponData(playerid, slot, wep, ammo);
if(wep != weaponid)
{
GetPlayerWeaponData(playerid, slot, plyWeapons[slot], plyAmmo[slot]);
}
}
ResetPlayerWeapons(playerid);
for(new slot = 0; slot != 12; slot++)
{
GivePlayerWeapon(playerid, plyWeapons[slot], plyAmmo[slot]);
}
}
Re: Reset Weapons. -
[..MonTaNa..] - 16.05.2014
EDIT: too late
Re: Reset Weapons. -
kubeba59 - 17.05.2014
Quote:
Originally Posted by Mionee
Usage:
pawn Код:
RemovePlayerWeapon(playerid, weaponid);
Code:
pawn Код:
stock RemovePlayerWeapon(playerid, weaponid) { new plyWeapons[12], plyAmmo[12];
for(new slot = 0; slot != 12; slot++) { new wep, ammo;
GetPlayerWeaponData(playerid, slot, wep, ammo); if(wep != weaponid) { GetPlayerWeaponData(playerid, slot, plyWeapons[slot], plyAmmo[slot]); } } ResetPlayerWeapons(playerid);
for(new slot = 0; slot != 12; slot++) { GivePlayerWeapon(playerid, plyWeapons[slot], plyAmmo[slot]); } }
|
Hey bro thanks but how will it recognaiz that the weapons are duty weapons ? I need to defined them and then use that function.
I also sell in the weapon store all the weapons that shows on the duty.
Re: Reset Weapons. -
kubeba59 - 23.05.2014
UP....
Re : Reset Weapons. -
S4t3K - 23.05.2014
Yes, you have to create an array with all duty weapons inside (their ids), then using a for loop to check if the weapon the player's holding is one of the weapon duty declared in the array.
PHP код:
new weaponsDuty[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 18, 22, 24, 34}; // Example
for(new i = 0; i < sizeof(weaponsDuty); i++)
{
if(GetPlayerWeapon(playerid) == weaponsDuty[i]) RemovePlayerWeapon(playerid, GetPlayerWeapon(playerid));
}
Re: Re : Reset Weapons. -
kubeba59 - 23.05.2014
Quote:
Originally Posted by S4t3K
Yes, you have to create an array with all duty weapons inside (their ids), then using a for loop to check if the weapon the player's holding is one of the weapon duty declared in the array.
PHP код:
new weaponsDuty[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 18, 22, 24, 34}; // Example
for(new i = 0; i < sizeof(weaponsDuty); i++)
{
if(GetPlayerWeapon(playerid) == weaponsDuty[i]) RemovePlayerWeapon(playerid, GetPlayerWeapon(playerid));
}
|
It didn't worked bro,I have the same weapons both places and its just the same..
Re : Reset Weapons. -
S4t3K - 23.05.2014
So use an array to store the weapon ids that the player takes in duty.
Then, when you wanna remove'em, simply check if the id is in the array.
Re: Re : Reset Weapons. -
kubeba59 - 23.05.2014
Quote:
Originally Posted by S4t3K
So use an array to store the weapon ids that the player takes in duty.
Then, when you wanna remove'em, simply check if the id is in the array.
|
How can I use that array ? :\
Re : Reset Weapons. -
S4t3K - 23.05.2014
PHP код:
new weaponsDuty[MAX_PLAYERS][12] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
// When the player duties
GivePlayerWeapon(playerid, weaponid);
for(new i = 0; i < 12; i++)
{
if(weaponsDuty[playerid][i] == -1 && i != weaponid) weaponsDuty[playerid][i] = weaponid; break;
}
// When the player unduties
for(new i = 0; i < MAX_PLAYERS; i++)
{
RemovePlayerWeapon(playerid, weaponsDuty[playerid][i]);
}