Problem with string + Mysql
#1

I made a house system but Now I want to buy the house.
So I went to a position and typed /buyproperty house Hoi (hoi is the address of the house)
Then it didn't do anything anymore.
Yes I am at the position, in case people ask.

pawn Код:
command(buyproperty, playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 6, 355.0121,171.4519,1025.7891))
    {
        new Usage[128], Address[128];
        if(sscanf(params, "zs", Usage, Address))
        {
            SendClientMessage(playerid, WHITE, "SYNTAX: /buyproperty [usage] [address]");
            SendClientMessage(playerid, GREY, "Usage: House, Business");
        }
        else
        {
            if(strcmp(Usage, "house", true) == 0)
            {
                if(Player[playerid][House] == 0)
                {
                    new query2[400];
                    format(query2, sizeof(query2), "SELECT * FROM `Houses` WHERE `hAddress` = %s", Address); // Selects all the information from the table
                    mysql_function_query(connectionHandle, query2, true, "BuyHouseCallback", "sd", Address, playerid);
                }
                else
                {
                    SendClientMessage(playerid, WHITE, "You already have a house, type /sellproperty house.");
                }
            }
        }
    }
    else
    {
        SCM(playerid, WHITE, "You are not at the property office");
    }
    return 1;
}
pawn Код:
public BuyHouseCallback(address[], playerid)
{
    new
        rows,
        fields,
        string[128];

    cache_get_data(rows, fields);
    if(rows == 1)
    {
        new temp[50], ID;
        cache_get_row(0, 0, temp); // #0 = #1 in the DB
        Houses[ID][HouseID] = strval(temp);
        cache_get_row(0, 16, Houses[ID][hOwner]);
        cache_get_row(0, 17, Houses[ID][hAddress]);
        cache_get_row(0, 18, temp);
        Houses[ID][HousePrice] = strval(temp);
        cache_get_row(0, 19, temp);
        Houses[ID][hLockStatus] = strval(temp);
        cache_get_row(0, 20, Houses[ID][hType]);
       
        if(!strcmp(Houses[ID][hOwner], "Nobody", true))
        {
            if(Houses[ID][HousePrice] == -1)
            {
                RemoveTextMessage(playerid);
                TextDrawShowForPlayer(playerid, Text:NotBuyAble);
                SetTimerEx("RemoveTextMessage", 3500, false, "d", playerid);
            }
            else
            {
                if(Player[playerid][Hotel] == 0)
                {
                    if(Player[playerid][Money] >= Houses[ID][HousePrice])
                    {
                        Player[playerid][Money] -= Houses[ID][HousePrice];
                        GivePlayerMoney(playerid, -Houses[ID][HousePrice]);
                        format(Houses[ID][hOwner], 128, "%s", GetName(playerid));
                        format(string, sizeof(string), "You bought the house with address %s for $%d.", address, Houses[ID][HousePrice]);
                        SendClientMessage(playerid, ADMINBLUE, string);
                        Player[playerid][House] = ID;
                        DestroyPickup(Houses[ID][HPickupID]);
                        Houses[ID][HPickupID] = CreateObject(1559,Houses[ID][hExteriorX],Houses[ID][hExteriorY],Houses[ID][hExteriorZ]+0.700, 0,0,0,250.0);
                        SaveHouse(ID);
                        SavePlayerData(playerid);
                    }
                    else
                    {
                        SendClientMessage(playerid, WHITE, "You do not have enough money to purchase this house.");
                    }
                }
                else
                {
                    SCM(playerid, RED, "You already live in a hotel");
                }
            }
        }
        else
        {
            RemoveTextMessage(playerid);
            TextDrawShowForPlayer(playerid, Text:HouseOwned);
            SetTimerEx("RemoveTextMessage", 3500, false, "d", playerid);
        }
    }
    else if(rows == 0)
    {
        RemoveTextMessage(playerid);
        TextDrawShowForPlayer(playerid, Text:HouseNotExist);
        SetTimerEx("RemoveTextMessage", 3500, false, "d", playerid);
    }
    else
    {
        //SendClientMessage(SavingVehiclePlayerID, COLOR_WHITE, "There was a "#COL_EMB_RED"fatal error "#COL_EMB_WHITE"during registration! Please contact a developer.");
        SendClientMessage(playerid, COLOR_WHITE, "There was a "#COL_EMB_RED"fatal error "#COL_EMB_WHITE"during registration! Please contact a developer.");
    }
    return 1;
}
Reply
#2

////
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)