SA-MP Forums Archive
Build query [MYSQL] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Build query [MYSQL] (/showthread.php?tid=306862)



Build query [MYSQL] - thimo - 28.12.2011

Ok so i try to make a house with mysql and i got this:
pawn Код:
BuildHouse(HPrice, Float:X, Float:Y, Float:Z)
{
    new Message[128];
    mysql_query("SELECT NULL FROM Houses");
    mysql_store_result();
    new rows = mysql_num_rows();
    mysql_free_result();
    new HouseID = rows++;
    if(HouseID < MAX_HOUSES)
    {
        CheckMySQL();
        new string[128];
        format(string, sizeof(string), "INSERT INTO Houses (HouseID, Houseprice, Houseowner, Owned, X, Y, Z) VALUES ('%d', '%d', 'None', 'false', '%f', '%f', '%f')", HouseID, HPrice, X, Y, Z);
        mysql_query(string);
        CreatePickup(1273, 1, X, Y, Z, 1);
        printf("House %d created", HouseID);
        AHouseData[HouseID][ID] = HouseID;
        AHouseData[HouseID][Houseprice] = HPrice;
        AHouseData[HouseID][HouseX] = X;
        AHouseData[HouseID][HouseY] = Y;
        AHouseData[HouseID][HouseZ] = Z;
        format(Message, sizeof(Message), "This house is for sale!\nHouseprice: %i\n Type /buyhouse to buy this house", AHouseData[HouseID][Houseprice]);
        CreateDynamic3DTextLabel(Message, 0xFFFFFFF, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ], 100.0);
    }
   
    return 1;
}
And it was working before i thought but not it wont work can anyone see a mistake here? if you need the CMD:
pawn Код:
COMMAND:createhouse(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        new HPrice;
        if (sscanf(params, "i", HPrice)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/createhouse <price>\"");
        else
        {
            GetPlayerPos(playerid, AHouseData[playerid][HouseX], AHouseData[playerid][HouseY], AHouseData[playerid][HouseZ]);
            BuildHouse(HPrice, AHouseData[playerid][HouseX], AHouseData[playerid][HouseY], AHouseData[playerid][HouseZ]);
        }
    }
    else SendClientMessage(playerid, 0xFFFFFF, "{FF0000}You are not authorized to use this command!");
    return 1;
}
Weird thing is when i try to query it on mysql server itself it does put in a new row :S
Help please