Reset Weapons.
#1

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 ?
Reply
#2

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]);
    }
}
Reply
#3

EDIT: too late
Reply
#4

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.
Reply
#5

UP....
Reply
#6

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[] = {0123456789101118222434}; // Example

for(new 0sizeof(weaponsDuty); i++)
{
    if(
GetPlayerWeapon(playerid) == weaponsDuty[i]) RemovePlayerWeapon(playeridGetPlayerWeapon(playerid));

Reply
#7

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[] = {0123456789101118222434}; // Example
for(new 0sizeof(weaponsDuty); i++)
{
    if(
GetPlayerWeapon(playerid) == weaponsDuty[i]) RemovePlayerWeapon(playeridGetPlayerWeapon(playerid));

It didn't worked bro,I have the same weapons both places and its just the same..
Reply
#8

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.
Reply
#9

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 ? :\
Reply
#10

PHP код:
new weaponsDuty[MAX_PLAYERS][12] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
// When the player duties
GivePlayerWeapon(playeridweaponid);
for(new 
012i++)
{
    if(
weaponsDuty[playerid][i] == -&& != weaponidweaponsDuty[playerid][i] = weaponid; break;
}
// When the player unduties
for(new 0MAX_PLAYERSi++)
{
    
RemovePlayerWeapon(playeridweaponsDuty[playerid][i]);

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)