Command returns unkown cmd
#1

Ok so i got this:
pawn Код:
COMMAND:createhouse(playerid, params[])
{
    new string[128], Float:X, Float:Y, Float:Z, HouseID, HPrice, string2[128];
    format(string, sizeof(string), "SELECT HouseID, Houseprice, Houseowner, X, Y, Z FROM Houses WHERE HouseID = '%i'", UserStats[playerid][Name]);
    mysql_query(string);
    mysql_store_result();
    if (sscanf(params, "i", HPrice)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/createhouse <price>\"");
    else
    {
        // Find the first free HouseID
        for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
            if (AHouseData[HouseID][PickupID] == 0) // Check if an empty house-index has been found (PickupID is 0)
                break; // Stop searching, the first free HouseID has been found now


        if(HouseID < MAX_HOUSES)
        {
            GetPlayerPos(playerid, X, Y, Z);
            AHouseData[HouseID][HouseX] = X;
            AHouseData[HouseID][HouseY] = Y;
            AHouseData[HouseID][HouseZ] = Z;
            AHouseData[HouseID][Owned] = false;
            AHouseData[HouseID][Houseprice] = HPrice;
            House_CreateEntrance(HouseID);
        }
        format(string2, sizeof(string2), "INSERT INTO Houses (HouseID, X, Y, Z, Owned, Houseprice) VALUES ('%i', '%f', '%f', '%f', '%s', '%i')",HouseID, AHouseData[HouseID][HouseX],AHouseData[HouseID][HouseY],AHouseData[HouseID][HouseZ], AHouseData[HouseID][Owned], AHouseData[HouseID][Houseprice]);
        mysql_query(string2);
    }
    mysql_free_result();
    return 1;
}
stock House_CreateEntrance(HouseID)
{
   
    // Setup local variables
    new Msg[128], Float:x, Float:y, Float:z;

    // Get the coordinates of the house's pickup (usually near the door)
    x = AHouseData[HouseID][HouseX];
    y = AHouseData[HouseID][HouseY];
    z = AHouseData[HouseID][HouseZ];
   
    if (AHouseData[HouseID][Owned] == true)
    {
        AHouseData[HouseID][PickupID] = CreateDynamicPickup(1272, 1, x, y, z, 0);
    }
    else
    {
        // Create a green house-pickup (house is free)
        AHouseData[HouseID][PickupID] = CreateDynamicPickup(1273, 1, x, y, z, 0);
        // Create the 3DText that appears above the house-pickup (displays the price of the house)
        format(Msg, 128, "{00FF00}House available for\n$%i\n/buyhouse", AHouseData[HouseID][Houseprice]);
        AHouseData[HouseID][DoorText] = CreateDynamic3DTextLabel(Msg, 0x008080FF, x, y, z + 1.0, 50.0);
        // Add a streamed icon to the map (green house), type = 31, color = 0, world = 0, interior = 0, playerid = -1, drawdist = 150.0
        AHouseData[HouseID][MapIconID] = CreateDynamicMapIcon(x, y, z, 31, 0, 0, 0, -1, 150.0);
    }
    return 1;
}
So everytime i use it it returns SERVER: Unkown Command. But when i dont put in the houseprice variable it returns the sscanf thingy. Anyone can see the problem? :S
Reply
#2

Ok so i got new info its not that code ABOVE... Its the Housing_loadall(); in ongamemodeinit... When i use the createhouse cmd when thats there the command isnt working... So anyone know whats wrong? This is the function where i DONT get any errors from :S
pawn Код:
Housing_LoadAll()
{
   
    for (new HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
    {
        new string[128];
        format(string, sizeof(string), "SELECT `HouseID` = '%i' FROM Houses", HouseID);
        mysql_query(string);
        mysql_store_result();
        // Loop through all houses and try to load them
        // Try to load the file and check if it was succesfully loaded (file exists)
        if (HouseFile_Load(HouseID) == 1)
        {
            // Add a pickup and 3DText for this house
            House_CreateEntrance(HouseID);
            // Count the amount of houses that are loaded
            TotalHouses++;
        }
    }
    return 1;
}
Reply
#3

Bump help please... :S
Reply
#4

It's because of your code. You are using too many returns.
Reply
#5

Ok i will try that thanks for your reaction
Reply
#6

Well i deleted the return out of the Housing_LoadAll(); but its still not working... HELP! OT: Sry for double post
Reply
#7

Have you tried deleting it from stock House_CreateEntrance(HouseID) too?
Reply
#8

Neither works... Tested Btw i have to put the HousesLoadall thingy on connect or gamemodeinit?
Reply
#9

Bump er sticker.. HELP!
Reply
#10

I know you don't know me try to replace return 1; to return 0; at stock, or just delete return.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)