[HELP] Weapon ammo out...
#1

How do that when ammo go-s 0 then set something off?
Reply
#2

I don't understand.. Example?
Reply
#3

I wrote this completely out of my head. Not sure if It'll work, but, afaik, it should
pawn Код:
new
    iNewPlayerWeapon[MAX_PLAYERS],
    iPlayerWeapon[MAX_PLAYERS];

public OnPlayerUpdate(playerid)
{
    iNewPlayerWeapon[playerid] = GetPlayerWeapon(playerid);
    if(iNewPlayerWeapon[playerid] != iPlayerWeapon[playerid])
    {
        OnPlayerWeaponChange(playerid, iNewPlayerWeapon[playerid], iPlayerWeapon[playerid]);
        iPlayerWeapon[playerid] = iNewPlayerWeapon[playerid];
    }
    return 1;
}

forward OnPlayerWeaponChange(playerid, newweapon, oldweapon);
public OnPlayerWeaponChange(playerid, neweapon, oldweapon)
{
    new
        weapons[13][2],
        i = 0;
    for (; i < 13; i++) GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
    for (i = 0; i < 13; i++) if (weapons[i][0] == oldweapon) i = 30;

    if (i != 30)
    {
        //player ran out of ammo on a weapon
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by [N
BL!nk ]
I don't understand.. Example?
Like when people just run out off bullets( 0-0 ) i can set some value to something....
Reply
#5

Код:
GivePlayerWeapon(GetPlayerWeapon(playerid),200);
Reply
#6

pawn Код:
new tmp = GetPlayerWeaponState(playerd);
if(tmp == WEAPONSTATE_NO_BULLETS) {
  //player has no ammo
}

//https://sampwiki.blast.hk/wiki/GetPlayerWeaponState
Reply
#7

Quote:
Originally Posted by [___
Whitetiger [www.sampcommunity.com] ]
Код:
new tmp = GetPlayerWeaponState(playerd);
if(tmp == WEAPONSTATE_NO_BULLETS) {
  //player has no ammo
}

//https://sampwiki.blast.hk/wiki/GetPlayerWeaponState
Like this?
pawn Код:
new tmp = GetPlayerWeaponState(playerid);
if(tmp == WEAPONSTATE_NO_BULLETS) {
  if(tmp == 4){PlayerInfo[playerid][psomething]=0;}//???
}
but where i added it?
Reply
#8

Quote:
Originally Posted by dice7
I wrote this completely out of my head. Not sure if It'll work, but, afaik, it should
pawn Код:
new
    iNewPlayerWeapon[MAX_PLAYERS],
    iPlayerWeapon[MAX_PLAYERS];

public OnPlayerUpdate(playerid)
{
    iNewPlayerWeapon[playerid] = GetPlayerWeapon(playerid);
    if(iNewPlayerWeapon[playerid] != iPlayerWeapon[playerid])
    {
        OnPlayerWeaponChange(playerid, iNewPlayerWeapon[playerid], iPlayerWeapon[playerid]);
        iPlayerWeapon[playerid] = iNewPlayerWeapon[playerid];
    }
    return 1;
}

forward OnPlayerWeaponChange(playerid, newweapon, oldweapon);
public OnPlayerWeaponChange(playerid, neweapon, oldweapon)
{
    new
        weapons[13][2],
        i = 0;
    for (; i < 13; i++) GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
    for (i = 0; i < 13; i++) if (weapons[i][0] == oldweapon) i = 30;

    if (i != 30)
    {
        //player ran out of ammo on a weapon
    }
    return 1;
}
Here a similar version of OnPlayerWeaponChange: >>
https://sampwiki.blast.hk/wiki/OnPlayerUpdate
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)