/createhouse problem
#1

Hey guys, I tryed to rescript a command it all compiled smooth but then:
when I type /createhouse <price> <houselevel> <max-houselevel>

pawn Код:
if (sscanf(params, "ii", HPrice, HouseLevel1, MaxLevel)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/createhouse <price> <maxlevel (1-10)>\"");
It/s gives me the error in-game that Usage: \"/createhouse <price> <maxlevel (1-10)> But the sscript is compiled normally. Can someone make a fix for this?

pawn Код:
COMMAND:createhouse(playerid, params[])
{
    // Setup local variables
    new HPrice, MaxLevel, HouseID, HouseLevel1;

    // Send the command to all admins so they can see it
    SendAdminText(playerid, "/createhouse", params);

    // Check if the player has logged in
    if (APlayerData[playerid][LoggedIn] == true)
    {
        // Check if the player's admin-level is at least 5
        if (APlayerData[playerid][PlayerLevel] >= 5)
        {
            // Check if the player isn't inside a vehicle
            if (GetPlayerVehicleSeat(playerid) == -1)
            {
                if (sscanf(params, "ii", HPrice, HouseLevel1, MaxLevel)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/createhouse <price> <maxlevel (1-10)>\"");
                else
                {
                    // Check if the player entered a proper maxlevel
                    if ((HouseLevel1 >= 1) && (HouseLevel1 <= 10) || (MaxLevel >= 1) && (MaxLevel <= 10))
                    {
                        // 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

                        // Check if the house-limit hasn't been reached yet
                        if (HouseID < MAX_HOUSES)
                        {
                            // Setup some local variables
                            new Float:x, Float:y, Float:z, Msg[128];
                            // Get the player's position
                            GetPlayerPos(playerid, x, y, z);
                            // Set some default data
                            AHouseData[HouseID][HouseX] = x;
                            AHouseData[HouseID][HouseY] = y;
                            AHouseData[HouseID][HouseZ] = z;
                            AHouseData[HouseID][HouseLevel] = HouseLevel1;
                            AHouseData[HouseID][HouseMaxLevel] = MaxLevel;
                            AHouseData[HouseID][HousePrice] = HPrice;
                            AHouseData[HouseID][Owned] = false;

                            // Add the pickup and 3DText at the location of the house-entrance (where the player is standing when he creates the house)
                            House_CreateEntrance(HouseID);

                            // Save the house
                            HouseFile_Save(HouseID);

                            // Inform the player that he created a new house
                            format(Msg, 128, "{00FF00}You've succesfully created house {FF00FF}%i{00FF00}", HouseID);
                            SendClientMessage(playerid, 0xFFFFFFFF, Msg);
                        }
                        else
                            SendClientMessage(playerid, 0xFF0000FF, "The maximum amount of houses has been reached");
                    }
                    else
                        SendClientMessage(playerid, 0xFF0000FF, "You have to use a max-level from 1 to 10");
                }
            }
            else
                SendClientMessage(playerid, 0xFF0000FF, "You can't be inside a vehicle to create a house");
        }
    }
    else
        return 0;

    // Let the server know that this was a valid command
    return 1;
}
Reply
#2

You use 2 integers, but expect 3
"ii" add one more i in there at the sscanf line.

This forum requires that you wait 120 seconds between posts. Please try again in 55 seconds.
... Please make it only for persons with not much rep or posts.
Reply
#3

pawn Код:
COMMAND:createhouse(playerid, params[])
{
    // Setup local variables
    new HPrice, MaxLevel, HouseID, HouseLevel1;

    // Send the command to all admins so they can see it
    SendAdminText(playerid, "/createhouse", params);

    // Check if the player has logged in
    if (APlayerData[playerid][LoggedIn] == true)
    {
        // Check if the player's admin-level is at least 5
        if (APlayerData[playerid][PlayerLevel] >= 5)
        {
            // Check if the player isn't inside a vehicle
            if (GetPlayerVehicleSeat(playerid) == -1)
            {
                if (sscanf(params, "iii", HPrice, HouseLevel1, MaxLevel)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/createhouse <price> <maxlevel (1-10)>\"");
                else
                {
                    // Check if the player entered a proper maxlevel
                    if ((HouseLevel1 >= 1) && (HouseLevel1 <= 10) || (MaxLevel >= 1) && (MaxLevel <= 10))
                    {
                        // 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

                        // Check if the house-limit hasn't been reached yet
                        if (HouseID < MAX_HOUSES)
                        {
                            // Setup some local variables
                            new Float:x, Float:y, Float:z, Msg[128];
                            // Get the player's position
                            GetPlayerPos(playerid, x, y, z);
                            // Set some default data
                            AHouseData[HouseID][HouseX] = x;
                            AHouseData[HouseID][HouseY] = y;
                            AHouseData[HouseID][HouseZ] = z;
                            AHouseData[HouseID][HouseLevel] = HouseLevel1;
                            AHouseData[HouseID][HouseMaxLevel] = MaxLevel;
                            AHouseData[HouseID][HousePrice] = HPrice;
                            AHouseData[HouseID][Owned] = false;

                            // Add the pickup and 3DText at the location of the house-entrance (where the player is standing when he creates the house)
                            House_CreateEntrance(HouseID);

                            // Save the house
                            HouseFile_Save(HouseID);

                            // Inform the player that he created a new house
                            format(Msg, 128, "{00FF00}You've succesfully created house {FF00FF}%i{00FF00}", HouseID);
                            SendClientMessage(playerid, 0xFFFFFFFF, Msg);
                        }
                        else
                            SendClientMessage(playerid, 0xFF0000FF, "The maximum amount of houses has been reached");
                    }
                    else
                        SendClientMessage(playerid, 0xFF0000FF, "You have to use a max-level from 1 to 10");
                }
            }
            else
                SendClientMessage(playerid, 0xFF0000FF, "You can't be inside a vehicle to create a house");
        }
    }
    else
        return 0;

    // Let the server know that this was a valid command
    return 1;
}
pawn Код:
if (sscanf(params, "ii", HPrice, HouseLevel1, MaxLevel)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/createhouse <price> <maxlevel (1-10)>\"");
changed to
pawn Код:
if (sscanf(params, "iii", HPrice, HouseLevel1, MaxLevel)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/createhouse <price> <maxlevel (1-10)>\"");
Reply
#4

Yes. This was what i meant. Is it working ok now?
Reply
#5

Half, when i /createhouse <price> <houselevel> <maxlevel> it creates the house, but when I buy it, the houselevel resets to 1 but in the /buyhouse command is nothing wrong.
Reply
#6

Search your script for "[HouseLevel] = 1" and you may find what or how this can happen.
Reply
#7

Already found it, anyways thanks for the help. Fixed now.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)