[HELP]: Reseting weapons
#1

Hello !

Is there any way to reset only one weapon ? Not like ResetPlayerWeapons, but like ResetPlayerWeapon(playerid, weaponid);

- Weaponid - id of the weapon to reset.

I only find this. BUt that's not what i need :/

Thanks.
Reply
#2

How is that nit what you need?
Reply
#3

Resetting the ammo & the gun will reset itself, Try this function I made.

pawn Code:
stock ResetPlayerWeaponID(playerid, weaponid)
    return GivePlayerWeapon(playerid, weaponid, 0);
Reply
#4

Because in that ResetPlayerWeaponsEx(playerid, weapoid) is like that,

-weapoid - The list of weapons to exclude

That means, if i do like ResetPlayerWeaponsEx(playerid, 31); then it will delete all weapons, but M4 will stay, but i want to delete only M4 and other weapons will stay.
Reply
#5

Quote:
Originally Posted by pds2k12
View Post
Resetting the ammo & the gun will reset itself, Try this function I made.

pawn Code:
stock ResetPlayerWeaponID(playerid, weaponid)
    return GivePlayerWeapon(playerid, weaponid, 0);
Thanks, i will try.
Reply
#6

Quote:
Originally Posted by pds2k12
View Post
Resetting the ammo & the gun will reset itself, Try this function I made.

pawn Code:
stock ResetPlayerWeaponID(playerid, weaponid)
    return GivePlayerWeapon(playerid, weaponid, 0);
I'm not sure about that. If you have a deagle with 500 ammo and you give 0, you should still have 500 ammo.

Anyways, I'd save the weapons/ammo in an array with GetPlayerWeaponData and if the weaponid existed, I'd reset the weapons and give them back except the weaponid you chose (note that you should know the slot of the weapon).
Reply
#7

Yeah, it doesn't work.

EDIT: I don't really understand what you said :/
Reply
#8

Quote:
Originally Posted by Konstantinos
View Post
I'm not sure about that. If you have a deagle with 500 ammo and you give 0, you should still have 500 ammo.

Anyways, I'd save the weapons/ammo in an array with GetPlayerWeaponData and if the weaponid existed, I'd reset the weapons and give them back except the weaponid you chose (note that you should know the slot of the weapon).
Just realized that LoL, How dumb Am I? I was thinking that GivePlayerWeapon works the same as SetPlayerHealth, SetPlayerMoney & SetPlayerArmour, oh-well Areax Konstantinos means something like this, I didn't test it but atleast give it a try

pawn Code:
stock RemovePlayerWeaponID(playerid, weaponid)
{
    new
        ArrayWeapons[12], ArrayAmmunations[12], Weapon, Ammunation;

    for(new slot = 0; slot != 12; slot++) {
        GetPlayerWeaponData(playerid, slot, Weapon, Ammunation);
        if(Weapon != weaponid) {
            GetPlayerWeaponData(playerid, slot, ArrayWeapons[slot], ArrayAmmunations[slot]);
        }
    }

    for(new slot = 0; slot != 12; slot++) {
        GivePlayerWeapon(playerid, ArrayWeapons[slot], 300);
    }

    ResetPlayerWeapons(playerid);
}
Reply
#9

pawn Code:
stock RemovePlayerWeaponEx( playerid, weaponid )
{
    new
        wdata[ 2 ][ 13 ],
        slot
    ;
    for( new i; i != 13; i++ )
    {
        GetPlayerWeaponData( playerid, i, wdata[ 0 ][ i ], wdata[ 1 ][ i ] );
        if( wdata[ 0 ][ i ] == weaponid ) slot = i;
    }
   
    ResetPlayerWeapons( playerid );
   
    for( new i; i != 13; i++ ) if( i != slot) GivePlayerWeapon( playerid, wdata[ 0 ][ i ], wdata[ 1 ][ i ] );
}
Reply
#10

Quote:
Originally Posted by Konstantinos
View Post
pawn Code:
stock RemovePlayerWeaponEx( playerid, weaponid )
{
    new
        wdata[ 2 ][ 13 ],
        slot
    ;
    for( new i; i != 13; i++ )
    {
        GetPlayerWeaponData( playerid, i, wdata[ 0 ][ i ], wdata[ 1 ][ i ] );
        if( wdata[ 0 ][ i ] == weaponid ) slot = i;
    }
   
    ResetPlayerWeapons( playerid );
   
    for( new i; i != 13; i++ ) if( i != slot) GivePlayerWeapon( playerid, wdata[ 0 ][ i ], wdata[ 1 ][ i ] );
}
Okay, i tried that code, but didn't really work. I am working on weapon system and i did like Shotgun and M4 are both primary weapons, so if you have M4 and then you buy Shotgun, then M4 will be deleted and Shotgun will be given.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)