SA-MP Forums Archive
What is wrong with this? - 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: What is wrong with this? (/showthread.php?tid=328170)



What is wrong with this? - Luis- - 24.03.2012

I have a command which creates a house in the position set which works but it doesn't get added to the mysql database. I've checked the Debug text and it's successfully executed.
pawn Код:
CMD:createhouse(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5) {
        new Float:Pos[3], query[512], string[128];
        GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
        HouseInfo[houses][hX] = Pos[0];
        HouseInfo[houses][hY] = Pos[1];
        HouseInfo[houses][hZ] = Pos[2];
        HouseInfo[houses][hPrice] = random(100000)+555555;
        format(query, sizeof(query), "INSERT INTO `houses` (`X`, `Y`, `Z`, `Price`) VALUES (%f, %f, %f, %d)", Pos[0], Pos[1], Pos[2], HouseInfo[houses][hPrice]);
        mysql_query(query);
        print(query);
        SendClientMessageToAll(COLOR_WHITE, query);
        HouseInfo[houses][hPickup] = CreateDynamicPickup(1273, 1, Pos[0], Pos[1], Pos[2], -1, -1, -1, 50.0);
        format(string, sizeof(string), "[HOUSE]\n{FFFFFF}Owner: For Sale\nPrice: $%d\nID: %d", HouseInfo[houses][hPrice], houses);
        HouseInfo[houses][hLabel] = CreateDynamic3DTextLabel(string, COLOR_LIGHTBLUE, Pos[0], Pos[1], Pos[2], 50.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0);
        houses++;
        format(string, sizeof(string), "INFO: {FFFFFF}%s has created a house, house id: %d.", Name(playerid), houses);
        SendClientMessageToAll(COLOR_ORANGE, string);
    }
    else {
        SendClientMessage(playerid, COLOR_GREY, "ERROR: You don't seem to be an admin.");
    }
    return 1;
}



Re: What is wrong with this? - Luis- - 24.03.2012

Why would I do it again? I asked for help not to re-do it.


Re: What is wrong with this? - MP2 - 24.03.2012

Stupidest reply ever.

Are you sure it's not inserted correctly? (that's what she said)


Re: What is wrong with this? - fordawinzz - 24.03.2012

well, you should use something like this for inserting:
pawn Код:
new id = mysql_insert_id();
and then
pawn Код:
HouseInfo[id][hX] = Pos[0];
//etc