SA-MP Forums Archive
RemovePlayerArmedWeapon? - 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: RemovePlayerArmedWeapon? (/showthread.php?tid=341800)



RemovePlayerArmedWeapon? - Mento - 12.05.2012

Is there a function for that? Where it only removes the player's current armed weapon, and not the other ones?


Re: RemovePlayerArmedWeapon? - zSuYaNw - 12.05.2012

this function doesn't exist's!
you can use "SetPlayerAmmo".


Re: RemovePlayerArmedWeapon? - Ballu Miaa - 12.05.2012

Quote:
Originally Posted by [Full]Garfield[XDB]
Посмотреть сообщение
this function doesn't exist's!
you can use "SetPlayerAmmo".
OMFG What the hell.

Here is the Function.
pawn Код:
SetPlayerArmedWeapon(playerid, 0);



Re: RemovePlayerArmedWeapon? - Jonny5 - 12.05.2012

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
OMFG What the hell.

Here is the Function.
pawn Код:
SetPlayerArmedWeapon(playerid, 0);
this will just set their weapon to fist
I dont think it will remove it from the players weapon slots.

I think the only way todo it is to
https://sampwiki.blast.hk/wiki/GetPlayerWeaponData
then
https://sampwiki.blast.hk/wiki/ResetPlayerWeapons
and then
https://sampwiki.blast.hk/wiki/GivePlayerWeapon


Re: RemovePlayerArmedWeapon? - ReneG - 12.05.2012

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
OMFG What the hell.

Here is the Function.
pawn Код:
SetPlayerArmedWeapon(playerid, 0);
That would indeed just set them to hold fists.


You can always just loop through all the weapon data, remove all the weapons, and give all the weapons excluding the desired weapon


Re: RemovePlayerArmedWeapon? - [ABK]Antonio - 12.05.2012

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
That would indeed just set them to hold fists.


You can always just loop through all the weapon data, remove all the weapons, and give all the weapons excluding the desired weapon
You could also just do this

pawn Код:
stock RemoveWeapon(playerid, weaponid) SetPlayerAmmo(playerid, weaponid, 0);
EDIT: If it says that function doesn't exist (read on ****** it does...but i see it on wiki) you can add this

pawn Код:
stock SetPlayerAmmo(playerid, weaponid, ammo)
{
    new weapon[13][2];
    for(new i=0; i < 13; i++)
    {
        GetPlayerWeaponData(playerid, i, weapon[i][0], weapon[i][1]);
        if(weapon[i][0] == weaponid)
        {
            GivePlayerWeapon(playerid, weaponid, -(weapon[i][1]*2));
            break;
        }
    }
    GivePlayerWeapon(playerid, weaponid, ammo);
    return 1;
}



Re: RemovePlayerArmedWeapon? - Ballu Miaa - 12.05.2012

Wow really. Thanks for the information guys


Re: RemovePlayerArmedWeapon? - Abreezy - 12.05.2012

Or here's another way, with

pawn Код:
RemovePlayerWeapon
pawn Код:
stock RemovePlayerWeapon(playerid, weaponid)
{
    new plyWeapons[12];
    new 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: RemovePlayerArmedWeapon? - Mento - 12.05.2012

Thanks for all the replies I just created a stock of my own, made me get my lazy self to start the weapon saving system anyway, so thanks once again.