Check all the guns in all slots?
#1

Hi. I tried to make a function that checks if the player has any weapon in any slot, I tried to use GetPlayerWeaponData but I think I faild The thing I need help with is just to check if there is any gun in any slot.. If there is the code should do something I hope you get what I mean
Reply
#2

pawn Код:
new WeaponData[13][2], string[128];
for (new i = 0; i < 13; i++)
{
    GetPlayerWeaponData(playerid, i, WeaponData[i][0], WeaponData[i][1]);
   
    format(string, sizeof(string), "Slot %d: weapon id %d with %d ammo.", i, WeaponData[i][0], WeaponData[i][1]);
    SendClientMessage(playerid, 0xFFFFFFFF, string);
}
Reply
#3

Well not really like you did it Im trying to do so that if the player has a gun in ANY slot it will do something else it wont The code needs to stop if finds a gun in one of the slots
Reply
#4

You mean something like this? Untested.

pawn Код:
new WeaponData[13][2], string[128];
for (new i = 0; i < 13; i++)
{
    WeaponData[i][0] = 255;

    GetPlayerWeaponData(playerid, i, WeaponData[i][0], WeaponData[i][1]);
    if(WeaponData[i][0] != 255)
    {
        format(string, sizeof(string), "Found a weapon in slot %d", i);
        SendClientMessage(playerid, 0xFFFFFFFF, string);
        break;
    }
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)