Put / take commands not working properly
#2

Try the command putgun and tell me the results:

pawn Код:
CMD:putgun(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_GREY, "[LOGIN] Your athentication is required! Log in before using this command!");
        new slot;
        if(sscanf(params,"i",slot)) return SendClientMessage(playerid,-1,"USAGE: /putgun [slot 1-6]");
        new string[256];
        new gunname[100];
        new gunID = GetPlayerWeapon(playerid);
        new gunAmmo = GetPlayerAmmo(playerid);
        new Float:Health;
        GetPlayerHealth(playerid, Health);
        if(Health <= 15) return SendClientMessage(playerid, COLOR_GREY,"[ERROR] You can't perform that action with low health!");
        if(gunID != 0 && gunAmmo != 0)
        {
            if(slot < 1||slot > 6)
            {
                SendClientMessage(playerid, COLOR_GREY, "[Note] You can't go below slot 1 and you can't exceed slot 6");
                return 1;
            }
            if(slot == 1)
            {
                if(PlayerInfo[playerid][pInvWeapon] != 0 || PlayerInfo[playerid][pInvAmmo] != 0)
                {
                    SendClientMessage(playerid, COLOR_GREY, "[ERROR] You have already placed something in Slot 1!");
                    return 1;
                }
                PlayerInfo[playerid][pInvWeapon] = gunID;
                PlayerInfo[playerid][pInvAmmo] = gunAmmo;
                RemovePlayerWeapon(playerid, gunID);
                GetWeaponName(gunID, gunname, sizeof(gunname));
                format(string, sizeof(string), "[Inventory] You've put %s in slot 1.", gunname);
                SendClientMessage(playerid, COLOR_GREY, string);
            }
            if(slot == 2)
            {
                if(PlayerInfo[playerid][pInvWeapon2] != 0 || PlayerInfo[playerid][pInvAmmo2] != 0)
                {
                    SendClientMessage(playerid, COLOR_GREY, "[ERROR] You have already placed something in Slot 2!");
                    return 1;
                }
                PlayerInfo[playerid][pInvWeapon2] = gunID;
                PlayerInfo[playerid][pInvAmmo2] = gunAmmo;
                RemovePlayerWeapon(playerid, gunID);
                GetWeaponName(gunID, gunname, sizeof(gunname));
                format(string, sizeof(string), "[Inventory] You've put %s in Slot 2.", gunname);
                SendClientMessage(playerid, COLOR_GREY, string);
            }
            if(slot == 3)
            {
                if(PlayerInfo[playerid][pInvWeapon3] != 0 || PlayerInfo[playerid][pInvAmmo3] != 0)
                {
                    SendClientMessage(playerid, COLOR_GREY, "[ERROR] You have already placed something in Slot 3!");
                    return 1;
                }
                PlayerInfo[playerid][pInvWeapon3] = gunID;
                PlayerInfo[playerid][pInvAmmo3] = gunAmmo;
                RemovePlayerWeapon(playerid, gunID);
                GetWeaponName(gunID, gunname, sizeof(gunname));
                format(string, sizeof(string), "[Inventory] You've put %s in Slot 3.", gunname);
                SendClientMessage(playerid, COLOR_GREY, string);
            }
            if(slot == 4)
            {
                if(PlayerInfo[playerid][pInvWeapon4] != 0 || PlayerInfo[playerid][pInvAmmo4] != 0)
                {
                    SendClientMessage(playerid, COLOR_GREY, "[ERROR] You have already placed something in Slot 4!");
                    return 1;
                }
                PlayerInfo[playerid][pInvWeapon4] = gunID;
                PlayerInfo[playerid][pInvAmmo4] = gunAmmo;
                RemovePlayerWeapon(playerid, gunID);
                GetWeaponName(gunID, gunname, sizeof(gunname));
                format(string, sizeof(string), "[Inventory] You've put %s in Slot 4.", gunname);
                SendClientMessage(playerid, COLOR_GREY, string);
            }
            if(slot == 5)
            {
                if(PlayerInfo[playerid][pInvWeapon5] != 0 || PlayerInfo[playerid][pInvAmmo5] != 0)
                {
                    SendClientMessage(playerid, COLOR_GREY, "[ERROR] You have already placed something in Slot 5!");
                    return 1;
                }
                PlayerInfo[playerid][pInvWeapon5] = gunID;
                PlayerInfo[playerid][pInvAmmo5] = gunAmmo;
                RemovePlayerWeapon(playerid, gunID);
                GetWeaponName(gunID, gunname, sizeof(gunname));
                format(string, sizeof(string), "[Inventory] You've put %s in your Slot 5.", gunname);
                SendClientMessage(playerid, COLOR_GREY, string);
            }
            if(slot == 6)
            {
                if(PlayerInfo[playerid][pInvWeapon6] != 0 || PlayerInfo[playerid][pInvAmmo6] != 0)
                {
                    SendClientMessage(playerid, COLOR_GREY, "[ERROR] You have already placed something in Slot 6!");
                    return 1;
                }
                PlayerInfo[playerid][pInvWeapon6] = gunID;
                PlayerInfo[playerid][pInvAmmo6] = gunAmmo;
                RemovePlayerWeapon(playerid, gunID);
                GetWeaponName(gunID, gunname, sizeof(gunname));
                format(string, sizeof(string), "[Inventory] You've put %s in your slot 6.", gunname);
                SendClientMessage(playerid, COLOR_GREY, string);
            }
            new sendername[MAX_PLAYER_NAME];
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "* %s puts %s %s in %s Bag.", sendername, PlayerInfo[playerid][pGender], gunname, PlayerInfo[playerid][pGender]);
            ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
            new y, m, d;
            new h,mi,s;
            getdate(y,m,d);
            gettime(h,mi,s);
            format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /putgun %d (%s)",d,m,y,h,mi,s,sendername, slot, gunname);
            CommandLog(string);
        }
    }
    return 1;
}
I used sscanf2 instead of isnull and changed the the message to "[Note] You can't go below slot 1 and you can't exceed slot 6"

- Make sure you have the latest sscanf and "#include <sscanf2>" in top of your script
Reply


Messages In This Thread
Put / take commands not working properly - by AndySedeyn - 08.04.2014, 08:58
Re: Put / take commands not working properly - by Stanford - 08.04.2014, 09:50
Re: Put / take commands not working properly - by AndySedeyn - 08.04.2014, 10:27
Re: Put / take commands not working properly - by AndySedeyn - 08.04.2014, 10:36

Forum Jump:


Users browsing this thread: 1 Guest(s)