Unable to give items
#1

So, I can give every item except for Xanax, any idea why?
PHP код:
CMD:give(playeridparams[])
{
    new 
playeramountitem[128], str[128];
    if(
sscanf(params"usi"playeritemamount)) return SendClientMessage(playeridCOLOR_GRAY"/give [playerid] [item] [quantity]");
    {
        if(
amount <= 0) return SendErrorMessage(playerid"Invalid amount.");
        if(
player == playerid) return SendErrorMessage(playerid"Invalid Player");
        if(
IsInRangeOfPlayer(playeridplayer5))
        {
            if(!
strcmp(item"VehicleRadio"true))
            {
                if(
Inventory[playerid][VehicleRadio] >= amount)
                {
                    
TakeInventoryItem(playeridVRADIOamount);
                    
GiveInventoryItem(playerVRADIOamount);
                }
                else 
SendErrorMessage(playerid"You don't have this item.");
                return 
1;
            }
            else if(!
strcmp(item"Weapon"true))
            {
            }
            else if(!
strcmp(item"Screwdriver"true))
            {
                if(
Inventory[playerid][Screwdriver] >= amount)
                {
                    
TakeInventoryItem(playeridSCREWDRIVERamount);
                    
GiveInventoryItem(playerSCREWDRIVERamount);
                }
                else 
SendErrorMessage(playerid"You don't have this item.");
                }
                else if(!
strcmp(item"Marijuana"true))
            {
                if(
Inventory[playerid][Marijuana] >= amount)
                {
                    
TakeInventoryItem(playeridMARIJUANAamount);
                    
format(strsizeof(str), "%s passes Marijuana to %s. "GetRoleplayName(playerid), GetRoleplayName(player));
                    
SetPlayerChatBubble(playeridstrCOLOR_RPRange_Short7000);
                    
GiveInventoryItem(playerMARIJUANAamount);
                }
                    else if(!
strcmp(item"Xanax"true))
            {
                if(
Inventory[playerid][Xanax] >= amount)
                {
                    
TakeInventoryItem(playeridXANAXamount);
                    
format(strsizeof(str), "%s passes Xanax to %s. "GetRoleplayName(playerid), GetRoleplayName(player));
                    
SetPlayerChatBubble(playeridstrCOLOR_RPRange_Short7000);
                    
GiveInventoryItem(playerXANAXamount);
                }
                else 
SendErrorMessage(playerid"You don't have this item.");
                return 
1;
                }
            }
        }
        else 
SendErrorMessage(playerid"You are too far away from this player.");
    }
    return 
1;

Reply
#2

Код:
CMD:give(playerid, params[])
{
    new player, amount, item[128], str[128];
    if(sscanf(params, "usi", player, item, amount)) return SendClientMessage(playerid, COLOR_GRAY, "/give [playerid] [item] [quantity]");
    {
        if(amount <= 0) return SendErrorMessage(playerid, "Invalid amount.");
        if(player == playerid) return SendErrorMessage(playerid, "Invalid Player");
        if(IsInRangeOfPlayer(playerid, player, 5))
        {
            if(!strcmp(item, "VehicleRadio", true))
            {
                if(Inventory[playerid][VehicleRadio] >= amount)
                {
                    TakeInventoryItem(playerid, VRADIO, amount);
                    GiveInventoryItem(player, VRADIO, amount);

                }
                else SendErrorMessage(playerid, "You don't have this item.");
                
            }
            else if(!strcmp(item, "Weapon", true))
            {

            }
            else if(!strcmp(item, "Screwdriver", true))
            {
                if(Inventory[playerid][Screwdriver] >= amount)
                {
                    TakeInventoryItem(playerid, SCREWDRIVER, amount);
                    GiveInventoryItem(player, SCREWDRIVER, amount);

                }
                else SendErrorMessage(playerid, "You don't have this item.");
                
			}
			else if(!strcmp(item, "Marijuana", true))
            {
                if(Inventory[playerid][Marijuana] >= amount)
                {
                    TakeInventoryItem(playerid, MARIJUANA, amount);
                    format(str, sizeof(str), "%s passes Marijuana to %s. ", GetRoleplayName(playerid), GetRoleplayName(player));
                    SetPlayerChatBubble(playerid, str, COLOR_RP, Range_Short, 7000);
                    GiveInventoryItem(player, MARIJUANA, amount);
                }
            }
            else if(!strcmp(item, "Xanax", true))
            {
                if(Inventory[playerid][Xanax] >= amount)
                {
                    TakeInventoryItem(playerid, XANAX, amount);
                    format(str, sizeof(str), "%s passes Xanax to %s. ", GetRoleplayName(playerid), GetRoleplayName(player));
                    SetPlayerChatBubble(playerid, str, COLOR_RP, Range_Short, 7000);
                    GiveInventoryItem(player, XANAX, amount);
                }
                else SendErrorMessage(playerid, "You don't have this item.");
            }
        }
        else SendErrorMessage(playerid, "You are too far away from this player.");
    }
    return 1;
}
Reply
#3

You missed a " } " bracket to close the Marijuana strcmp.
Reply
#4

If you would indent your code properly you'd noticed it straight away mate.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)