Command results in "Unknown command"
#1

Hello, I got this command scripted:

pawn Код:
CMD:createhouse(playerid, params[])
{
    new type[20], price;
    if(!IsOnDutyAdmin(playerid))
    {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "You must be on admin duty to use this command!");
        return 1;
    }
    if(sscanf(params, "si", type, price))
    {
        if(PlayerInfo[playerid][pAdmin] >= 1)
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: {FFFFFF}/createhouse [type] [price]");
            SendClientMessage(playerid, COLOR_WHITE, "TYPES: small - medium - villa");
        }
    }
    else
    {
        if(strcmp(type, "small", true) == 0)
        {

            new Float:x,Float:y,Float:z;
            GetPlayerPos(playerid,x,y,z);
            new newhouse;
            newhouse = SpawnedHouses += 1;

            HouseInfo[newhouse][EntranceX] = x;
            HouseInfo[newhouse][EntranceY] = y;
            HouseInfo[newhouse][EntranceZ] = z;
            HouseInfo[newhouse][InsideX] = x;
            HouseInfo[newhouse][InsideY] = y;
            HouseInfo[newhouse][InsideZ] = z;
            HouseInfo[newhouse][Owned] = 0;
            HouseInfo[newhouse][Locked] = 0;
            HouseInfo[newhouse][Price] = price;
            HouseInfo[newhouse][AlarmInstalled] = 0;
            HouseInfo[newhouse][DoorRammed] = 0;
            HouseInfo[newhouse][CustomInt] = 0;
            HouseInfo[newhouse][CustomExt] = 0;
            format(HouseInfo[newhouse][Owner], 255, "Nobody");

            new string[255];
            format(string, sizeof(string), "House: ID %d\n FOR SALE\nPrice: %d", newhouse, price);
            HouseInfo[newhouse][hTextID] = CreateDynamic3DTextLabel(string, COLOR_GREEN, HouseInfo[newhouse][EntranceX], HouseInfo[newhouse][EntranceY], HouseInfo[newhouse][EntranceZ]+0.5,30.0, 0);
            Update3DTextLabelText(HouseInfo[newhouse][hTextID], COLOR_GREEN, string);
            SaveHouse(newhouse);
            UpdateHouse(newhouse);
        }
    }
    return 1;
}

When I just type "/createhouse" without parameters or just one, I get the syntax shown: "USAGE: /createhouse [type] [price]"

But when I insert them correctly, and in this case "small" and any price, I get "SERVER: Unknown Command" in-game. What would be the issue with the command?
Reply
#2

pawn Код:
CMD:createhouse(playerid, params[])
{
    new type[20], price;
    if(!IsOnDutyAdmin(playerid))
    {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "You must be on admin duty to use this command!");
        return 1;
    }
    if(sscanf(params, "si", type, price))
    {
        if(PlayerInfo[playerid][pAdmin] >= 1)
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: {FFFFFF}/createhouse [type] [price]");
            SendClientMessage(playerid, COLOR_WHITE, "TYPES: small - medium - villa");
        }
    }
    else
    {
        if(strcmp(type, "small", true) == 0)
        {
            new Float:x,Float:y,Float:z;
            GetPlayerPos(playerid,x,y,z);
            new newhouse;
            newhouse = SpawnedHouses += 1;
            HouseInfo[newhouse][EntranceX] = x;
            HouseInfo[newhouse][EntranceY] = y;
            HouseInfo[newhouse][EntranceZ] = z;
            HouseInfo[newhouse][InsideX] = x;
            HouseInfo[newhouse][InsideY] = y;
            HouseInfo[newhouse][InsideZ] = z;
            HouseInfo[newhouse][Owned] = 0;
            HouseInfo[newhouse][Locked] = 0;
            HouseInfo[newhouse][Price] = price;
            HouseInfo[newhouse][AlarmInstalled] = 0;
            HouseInfo[newhouse][DoorRammed] = 0;
            HouseInfo[newhouse][CustomInt] = 0;
            HouseInfo[newhouse][CustomExt] = 0;
            format(HouseInfo[newhouse][Owner], 255, "Nobody");
            new string[255];
            format(string, sizeof(string), "House: ID %d\n FOR SALE\nPrice: %d", newhouse, price);
            HouseInfo[newhouse][hTextID] = CreateDynamic3DTextLabel(string, COLOR_GREEN, HouseInfo[newhouse][EntranceX], HouseInfo[newhouse][EntranceY], HouseInfo[newhouse][EntranceZ]+0.5,30.0, 0);
            Update3DTextLabelText(HouseInfo[newhouse][hTextID], COLOR_GREEN, string);
            SaveHouse(newhouse);
            UpdateHouse(newhouse);
            return 1;
            }
        }
    }
    return 0;
}
Try this
Reply
#3

Doesn't work, in fact it returns 1 to avoid the message "Unknown command". I used some prints to see where it goes wrong, and the issue is when the variables are assigned, so probably an error is in this part:

pawn Код:
HouseInfo[newhouse][EntranceX] = x;
            HouseInfo[newhouse][EntranceY] = y;
            HouseInfo[newhouse][EntranceZ] = z;
            HouseInfo[newhouse][InsideX] = x;
            HouseInfo[newhouse][InsideY] = y;
            HouseInfo[newhouse][InsideZ] = z;
            HouseInfo[newhouse][Owned] = 0;
            HouseInfo[newhouse][Locked] = 0;
            HouseInfo[newhouse][Price] = price;
            HouseInfo[newhouse][AlarmInstalled] = 0;
            HouseInfo[newhouse][DoorRammed] = 0;
            HouseInfo[newhouse][CustomInt] = 0;
            HouseInfo[newhouse][CustomExt] = 0;
            format(HouseInfo[newhouse][Owner], 255, "Nobody");
Reply
#4

Quote:
Originally Posted by Mado
Посмотреть сообщение
Doesn't work, in fact it returns 1 to avoid the message "Unknown command". I used some prints to see where it goes wrong, and the issue is when the variables are assigned, so probably an error is in this part:

pawn Код:
HouseInfo[newhouse][EntranceX] = x;
            HouseInfo[newhouse][EntranceY] = y;
            HouseInfo[newhouse][EntranceZ] = z;
            HouseInfo[newhouse][InsideX] = x;
            HouseInfo[newhouse][InsideY] = y;
            HouseInfo[newhouse][InsideZ] = z;
            HouseInfo[newhouse][Owned] = 0;
            HouseInfo[newhouse][Locked] = 0;
            HouseInfo[newhouse][Price] = price;
            HouseInfo[newhouse][AlarmInstalled] = 0;
            HouseInfo[newhouse][DoorRammed] = 0;
            HouseInfo[newhouse][CustomInt] = 0;
            HouseInfo[newhouse][CustomExt] = 0;
            format(HouseInfo[newhouse][Owner], 255, "Nobody");
Show me the enum of HouseInfo
Reply
#5

pawn Код:
enum hInfo
{
    float:EntranceX,
    float:EntranceY,
    float:EntranceZ,
    float:InsideX,
    float:InsideY,
    float:InsideZ,
    InsideInt,
    Owned,
    Owner[255],
    Price,
    AlarmInstalled,
    Locked,
    DoorRammed,
    CustomInt,
    CustomExt,
    Text3D:hTextID,
    PickupID
}
new HouseInfo[MAX_HOUSES][hInfo];
Reply
#6

Okay so I just fixed the error, and houses can be created again!

but that leads to another problem; the dynamic 3d textdraws won't be created:

pawn Код:
format(string, sizeof(string), "House: ID %d\n FOR SALE\nPrice: %d", newhouse, price);
            HouseInfo[newhouse][hTextID] = CreateDynamic3DTextLabel(string, COLOR_GREEN, HouseInfo[newhouse][EntranceX], HouseInfo[newhouse][EntranceY], HouseInfo[newhouse][EntranceZ]+0.5,30.0, .testlos = 1, .streamdistance = 30);
I did a printf to see the content of the string which was good.
I did another printf to see the content of "HouseInfo[newhouse][hTextID]" which was in the console just a smiley, so it appears to be empty..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)