SA-MP Forums Archive
My SetPlayerAmmo bugged - 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: My SetPlayerAmmo bugged (/showthread.php?tid=620269)



My SetPlayerAmmo bugged - henkas - 28.10.2016

Sup!
i try make today a /giveammo command its work fine bat sometimes its delete me all ammo and then add +30 like i have weapon with 300 bullets, right? then i type /giveammo playerid, and its delete me all 300 bullets and add +30 so i just have 30 bullets bat i should have 330 so this is me code
Код:
   new Ammo = GetPlayerAmmo(playerid);
    pInfo[playerid][Giveammo] -= 1;
    GetPlayerName(playerid, name, sizeof(name));
    SetPlayerAmmo(playerid, 16, Ammo+1);
    SetPlayerAmmo(playerid, 18, Ammo+1);
    SetPlayerAmmo(playerid, 22, Ammo+30);
    SetPlayerAmmo(playerid, 23, Ammo+30);
    SetPlayerAmmo(playerid, 24, Ammo+20);
    SetPlayerAmmo(playerid, 25, Ammo+30);
    SetPlayerAmmo(playerid, 26, Ammo+20);
    SetPlayerAmmo(playerid, 27, Ammo+20);
    SetPlayerAmmo(playerid, 28, Ammo+30);
    SetPlayerAmmo(playerid, 29, Ammo+30);
    SetPlayerAmmo(playerid, 30, Ammo+30);
    SetPlayerAmmo(playerid, 31, Ammo+30);
    SetPlayerAmmo(playerid, 32, Ammo+30);
    SetPlayerAmmo(playerid, 33, Ammo+20);
    SetPlayerAmmo(playerid, 34, Ammo+20);
    SetPlayerAmmo(playerid, 37, Ammo+15);
    SetPlayerAmmo(playerid, 39, Ammo+1);
    SetPlayerAmmo(playerid, 41, Ammo+20);
    SetPlayerAmmo(playerid, 42, Ammo+20);
    format(string,sizeof(string),""chat""COL_LGREEN" You just give ammo for %s",name);
    SendClientMessage(playerid, 0x0000FFFF, string);
    format(stringa,sizeof(stringa),""chat""COL_LGREEN" %s has given you ammo",name);
    SendClientMessage(playerid, 0x0000FFFF, stringa);
    GivePlayerXP(playerid,2);
Its not full code bat its the most important part of code.


Re: My SetPlayerAmmo bugged - iLearner - 28.10.2016

Don't use ammo+VALUE
Just use VALUE

Because ammo+VALUE could be used for SetPlayerAmmo(idk if it exists).


Re: My SetPlayerAmmo bugged - henkas - 28.10.2016

If i dont use ammo+Value i got - ammo.


Re: My SetPlayerAmmo bugged - iLearner - 28.10.2016

Also as I see you're giving ammo for multiple weapons, I suggest using getplayerweapondata cuz your ammo variable contains ammo for the weapon he has equipped only not all.


Re: My SetPlayerAmmo bugged - BurnZ - 28.10.2016

You didn't save the player's previous ammo.

I could be wrong though.


Re: My SetPlayerAmmo bugged - henkas - 28.10.2016

Quote:
Originally Posted by BurnZ
Посмотреть сообщение
You didn't save the player's previous ammo.

I could be wrong though.
I don't think so it can by problem with save previous ammo.


Re: My SetPlayerAmmo bugged - henkas - 28.10.2016

Quote:
Originally Posted by iLearner
Посмотреть сообщение
Also as I see you're giving ammo for multiple weapons, I suggest using getplayerweapondata cuz your ammo variable contains ammo for the weapon he has equipped only not all.
I never used getplayerweapondata function so i have no idea how it works


Re: My SetPlayerAmmo bugged - BurnZ - 28.10.2016

Quote:
Originally Posted by henkas
Посмотреть сообщение
I don't think so it can by problem with save previous ammo.
Well, you said in your OP that the ammo don't add to the new one.

What else can it be?


Re: My SetPlayerAmmo bugged - iLearner - 28.10.2016

I'll post the command it self in few minutes.


Re: My SetPlayerAmmo bugged - iLearner - 28.10.2016

new weaponid, ammo;
for (new i = 0; i < 12; i++)
{

GetPlayerWeaponData(playerid, i, weaponid, ammo);
if(weaponid > WEAPON_ID_HERE || weaponid > WEAPON_ID_HERE ....)
{
SetPlayerAmmo(playerid, weaponid, ammo+VALUE_HERE);
}

}