What is wrong with this?
#1

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;
}
Reply
#2

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

Stupidest reply ever.

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)