Anit -DB bagged
#1

Okay. here i made a anti db only for 1 weapon, M5.

I did so when a player enter to any vehicle as driver his weapon ammo will go to 0 (-30 ingame)

So when player exit from vehicle he loses he's weapon. I want to get the player weapon back and he's ammo too.


pawn Код:
new WeaponId;
    new ammo;

    if((newstate == PLAYER_STATE_DRIVER))
    {
        for(new i=0;i<11;i++)
    {
           if(GetPlayerWeapon(playerid) == 29)
           {
              GetPlayerWeaponData(playerid, i, WeaponId, ammo);
              SetPlayerAmmo(playerid, 29, 0);
           }
        }
    }
    if((newstate == PLAYER_STATE_ONFOOT) && ((oldstate == PLAYER_STATE_DRIVER)))
    {
        GivePlayerWeapon(playerid,29, ammo);
    }
   return 1;
}
How to give him the weapon back with ammo that he had before incar?


How to use Use GetPlayerWeaponData ? Make it for me
Reply
#2

Use GetPlayerWeaponData
Reply
#3

Quote:
Originally Posted by LarzI
Посмотреть сообщение
Use GetPlayerWeaponData
I can't, can u make it please for me?
Reply
#4

Is the code you posted above what you use already?
Reply
#5

Quote:
Originally Posted by LarzI
Посмотреть сообщение
Is the code you posted above what you use already?
Well as you see i already triyed the WeaponData. Maybe i didn't made it right?
Reply
#6

pawn Код:
new gun, ammo;

    if(newstate == PLAYER_STATE_DRIVER && GetPlayerWeapon(playerid) == 29)
    {
        if(GetPlayerWeapon(playerid) == 29)
        {
              GetPlayerWeaponData(playerid, 4, gun, ammo); // An MP5 was, is, and always will be slot 4. You don't need a loop for a constant value.
              SetPlayerAmmo(playerid, 4, 0); // SetPlayerAmmo works on the SLOT, not the weapon.
        }
    }
    if(newstate == 1 && oldstate == 2)
    {
        GivePlayerWeapon(playerid, 29, ammo);
    }
   return 1;
}
There's one way to do it, but the other...

pawn Код:
public OnPlayerStateChange(playerid, oldstate, newstate)
{
    if(newstate == 2) SetPlayerArmedWeapon(playerid, 0);
    return 1;
}
Reply
#7

Quote:
Originally Posted by Brian.
Посмотреть сообщение
pawn Код:
new gun, ammo;

    if(newstate == PLAYER_STATE_DRIVER && GetPlayerWeapon(playerid) == 29)
    {
        if(GetPlayerWeapon(playerid) == 29)
        {
              GetPlayerWeaponData(playerid, 4, gun, ammo); // An MP5 was, is, and always will be slot 4. You don't need a loop for a constant value.
              SetPlayerAmmo(playerid, 4, 0); // SetPlayerAmmo works on the SLOT, not the weapon.
        }
    }
    if(newstate == 1 && oldstate == 2)
    {
        GivePlayerWeapon(playerid, 29, ammo);
    }
   return 1;
}
There's one way to do it, but the other...

pawn Код:
public OnPlayerStateChange(playerid, oldstate, newstate)
{
    if(newstate == 2) SetPlayerArmedWeapon(playerid, 0);
    return 1;
}

Not working dude.
Reply
#8

Are you sure ammo is a global variable?
Reply
#9

Quote:
Originally Posted by Brian.
Посмотреть сообщение
Are you sure ammo is a global variable?
Yes i'm sure. When i enter to a vehicle nothing happen. My ammo stay as it was before and i can shot.
Reply
#10

pawn Код:
public OnPlayerStateChange(playerid, oldstate, newstate)
{
    if(newstate == 2) GivePlayerWeapon(playerid, 0, 6666); // Give the player fists with an arbitrary ammo value
    return 1;
}
Pretty sure SetPlayerArmedWeapon doesn't work in cars.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)