My SetPlayerAmmo bugged
#1

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.
Reply
#2

Don't use ammo+VALUE
Just use VALUE

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

If i dont use ammo+Value i got - ammo.
Reply
#4

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.
Reply
#5

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

I could be wrong though.
Reply
#6

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

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
Reply
#8

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?
Reply
#9

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

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

}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)