SetPlayerAmmo & GetPlayerAmmo - Bugged still?
#1

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

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

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)
Reply
#4

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

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!
Reply
#6

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)