SA-MP Forums Archive
SetPlayerAmmo & GetPlayerAmmo - Bugged still? - 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: SetPlayerAmmo & GetPlayerAmmo - Bugged still? (/showthread.php?tid=311084)



SetPlayerAmmo & GetPlayerAmmo - Bugged still? - Scarred - 15.01.2012

pawn Код:
case 0: //standard
                    {
                        if(GetPlayerWeapon(playerid) != 0) {
                            if(tempGun[playerid] != -1)
                            {
                                SetPlayerArmedWeapon(playerid, tempGun[playerid]);
                                SetPlayerAmmo(playerid, GetWeaponSlot(tempGun[playerid]), tempAmmo[playerid]);
                       
                                expAmmo[playerid] = -1;
                                UsingTazer[playerid] = -1;
                                tempGun[playerid] = -1;
                                tempAmmo[playerid] = -1;
                               
                                SendClientMessage(playerid, COLOR_SUCCESSFUL, "* You are now using Standard Rounds!");
                            }
                            else return SendClientMessage(playerid, COLOR_ERROR, "< You are already using Standard Rounds!");
                        }
                    }
                    case 1: //explosive
                    {
                        if(tempGun[playerid] == -1)
                        {
                            expAmmo[playerid] = 1;
                            UsingTazer[playerid] = -1;
                           
                            tempAmmo[playerid] = GetPlayerAmmo(playerid);
                            tempGun[playerid] = GetPlayerWeapon(playerid);
                           
                            SetPlayerAmmo(playerid, GetWeaponSlot(tempGun[playerid]), -1);
                            SetPlayerAmmo(playerid, GetWeaponSlot(tempGun[playerid]), UserInfo[playerid][ExplosiveAmmo]);

                            SendClientMessage(playerid, COLOR_SUCCESSFUL, "* You are now using Incendiary Rounds!");
                        }
                    }
pawn Код:
stock GetWeaponSlot(weaponid)
{
    switch (weaponid)
    {
        case 0, 1: return 0; // Unarmed
        case 2 .. 9: return 1; // Melee
        case 22 .. 24: return 2; // Pistol
        case 25 .. 27: return 3; // Shotgun
        case 28, 29, 32: return 4; // SMG
        case 30, 31: return 5; // Machinegun
        case 33, 34: return 6; // Rifle
        case 35 .. 38: return 7; // Heavy
        case 16, 18, 39: return 8; // Projectile
        case 42, 43: return 9; // Special
        case 14 : return 10; // Gifts
        case 44 .. 46: return 11; // Special
        case 40 : return 12; // Detonator
    }
    return 0;
}
It doesn't set my ammo what-so-ever, and from what I can see, this should work correctly. What am I doing wrong?


Re: SetPlayerAmmo & GetPlayerAmmo - Bugged still? - Scenario - 15.01.2012

I've never had a problem with either of those functions...


Re: SetPlayerAmmo & GetPlayerAmmo - Bugged still? - Scarred - 15.01.2012

Well, do you see any problems with the code above? Because it is not even touching my ammo.. When it obviously should. (Yes, the userfile is loading correctly and everything)


Re: SetPlayerAmmo & GetPlayerAmmo - Bugged still? - coole210 - 15.01.2012

pawn Код:
SetPlayerAmmo(playerid, GetWeaponSlot(tempGun[playerid]), -1);
SetPlayerAmmo isn't by weapon slot, its by weapon ID


Re: SetPlayerAmmo & GetPlayerAmmo - Bugged still? - Scarred - 15.01.2012

Quote:
Originally Posted by coole210
Посмотреть сообщение
pawn Код:
SetPlayerAmmo(playerid, GetWeaponSlot(tempGun[playerid]), -1);
SetPlayerAmmo isn't by weapon slot, its by weapon ID
Wow, thank you!


Re: SetPlayerAmmo & GetPlayerAmmo - Bugged still? - jamesbond007 - 15.01.2012

i thought setplayerammo was bugged in sa-mp...

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


Re: SetPlayerAmmo & GetPlayerAmmo - Bugged still? - Sergei - 15.01.2012

Quote:
Originally Posted by jamesbond007
Посмотреть сообщение
i thought setplayerammo was bugged in sa-mp...

https://sampwiki.blast.hk/wiki/Bugs
Nah. The problem was that it said weaponslot instead of weaponid, so everyone thought you needed to input weapon slot.