SA-MP Forums Archive
[HELP] Weapon ammo out... - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Weapon ammo out... (/showthread.php?tid=144471)



[HELP] Weapon ammo out... - whitedragon - 27.04.2010

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



Re: [HELP] Weapon ammo out... - -Rebel Son- - 27.04.2010

I don't understand.. Example?


Re: [HELP] Weapon ammo out... - dice7 - 27.04.2010

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;
}



Re: [HELP] Weapon ammo out... - whitedragon - 28.04.2010

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....


Re: [HELP] Weapon ammo out... - MafiaGuy™ - 28.04.2010

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



Re: [HELP] Weapon ammo out... - Whitetiger - 28.04.2010

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

//https://sampwiki.blast.hk/wiki/GetPlayerWeaponState



Re: [HELP] Weapon ammo out... - whitedragon - 28.04.2010

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?


Re: [HELP] Weapon ammo out... - RyDeR` - 28.04.2010

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