SA-MP Forums Archive
Reset Weapons. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Reset Weapons. (/showthread.php?tid=513553)



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

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


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(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]);