Cant detect gun & Ammo
#1

Hello, I am trying to detect how much ammo they got. If they already have the gun and a certain ammount of ammo then they cant take the gun again. But it is not working, they can still take the gun even if they have more and less then the amount put.

pawn Код:
CMD:takegun(playerid, params[])
{
    new string[128], weapon, ammo;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!IsACop(playerid) && !IsFBI(playerid) && !IsNG(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not a LEO.");
    if(GetPlayerVehicleID(playerid) != GetPlayerVehicleID(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Player is not in your vehicle.");
    for (new i = 0; i <= 12; i++)
    {
    GetPlayerWeaponData(playerid, i, weapon, ammo);
    }
    if(sscanf(params, "s[32]", params))
    {
        SendClientMessage(playerid, USAGE, "[Usage]: /takegun [gunslot]");
        SendClientMessage(playerid, USAGE, "Use /listguns to choose a gun to take.");
        return 1;
    }
    if(!strcmp(params, "1", true))
    {
        if(weapon == 29 && ammo <= 150) return SendClientMessage(playerid, COLOR_GREY, "You already got that gun.");
        GiveDodWeapon(playerid, 29, 500);
        format(string, sizeof(string), "* %s grab a MP5 from the back of %s trunk.", RPN(playerid), HisHer(playerid));
        SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 5.0, 5000);
        format(string, sizeof(string), "> %s grab a MP5 from the back of %s trunk.", RPN(playerid), HisHer(playerid));
        SendClientMessage(playerid, COLOR_PURPLE, string);
    }
    else if(!strcmp(params, "2", true))
    {
        if(weapon == 31 && ammo <= 75) return SendClientMessage(playerid, COLOR_GREY, "You already got that gun.");
        GiveDodWeapon(playerid, 31, 250);
        format(string, sizeof(string), "* %s grab a M4 from the back of %s trunk.", RPN(playerid), HisHer(playerid));
        SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 5.0, 5000);
        format(string, sizeof(string), "> %s grab a M4 from the back of %s trunk.", RPN(playerid), HisHer(playerid));
        SendClientMessage(playerid, COLOR_PURPLE, string);
    }
    else if(!strcmp(params, "3", true))
    {
        if(weapon == 25 && ammo <= 10) return SendClientMessage(playerid, COLOR_GREY, "You already got that gun.");
        GiveDodWeapon(playerid, 25, 50);
        format(string, sizeof(string), "* %s grab a shotgun from the back of %s trunk.", RPN(playerid), HisHer(playerid));
        SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 5.0, 5000);
        format(string, sizeof(string), "> %s grab a shotgun from the back of %s trunk.", RPN(playerid), HisHer(playerid));
        SendClientMessage(playerid, COLOR_PURPLE, string);
    }
    else if(!strcmp(params, "4", true))
    {
        if(weapon == 34 && ammo <= 5) return SendClientMessage(playerid, COLOR_GREY, "You already got that gun.");
        GiveDodWeapon(playerid, 34, 25);
        format(string, sizeof(string), "* %s grab a sniper from the back of %s trunk.", RPN(playerid), HisHer(playerid));
        SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 5.0, 5000);
        format(string, sizeof(string), "> %s grab a sniper from the back of %s trunk.", RPN(playerid), HisHer(playerid));
        SendClientMessage(playerid, COLOR_PURPLE, string);
    }
    return 1;
}
Reply
#2

Bump. Anyone got any clues or maybe even possible fixes?
Reply
#3

No one knows?
Reply
#4

Change <= to == and && to ||
Reply
#5

Thanks for the reply, but I already fixed it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)