PHP код:
stock SaveObjects(playerid, id)
{
new DB_Query[256];
mysql_format(Database2, DB_Query, sizeof DB_Query, "SELECT * FROM `usersobjectsinfo` WHERE `USERNAME` = '%e'", P[playerid][Name]);
mysql_tquery(Database2, DB_Query, "OnPlayerSaveObjects", "ii", playerid, id);
print("query sent. Calling OnPlayerSaveObjects");
return 1;
}
forward OnPlayerSaveObjects(playerid, id);
public OnPlayerSaveObjects(playerid, id){
print("OnPlayerSaveObjects called");
new Cache: rand = cache_save(), tempid0;
cache_set_active(rand);
new DB_Query[256];
while(cache_num_rows())
{
print("cache num rows are != 0");
cache_get_value_int(0, "OBJECTID", tempid0);
printf("id= %d tempid0= %d", id, tempid0);
// CODE BELOW DOESN'T GET EXECUTED
if(id == tempid0){
mysql_format(Database2, DB_Query, sizeof DB_Query, "UPDATE `usersobjectsinfo` SET `POSX`=%0.4f,`POSY`=%0.4f,`POSZ`=%0.4f,`ROTX`=%0.4f,`ROTY`=%0.4f,`ROTZ`=%0.4f,`OBJECTID`=%d WHERE `USERNAME`= '%e' LIMIT 1",
Obj[id][PosX], Obj[id][PosY], Obj[id][PosZ], Obj[id][RX], Obj[id][RY], Obj[id][RX], id, Obj[id][ObjOwner]);
printf("%s tempid0 = id", Obj[id][ObjOwner]);
mysql_tquery(Database2, DB_Query);
cache_delete(rand);
return 1;
}
mysql_format(Database2, DB_Query, sizeof DB_Query, "INSERT INTO `usersobjectsinfo` (`USERNAME`,`POSX`,`POSY`,`POSZ`,`ROTX`,`ROTY`,`ROTZ`,`OBJECTID`) VALUES ('%e','%0.3f','%0.3f','%0.3f','%0.3f','%0.3f','%0.3f','%d')",
P[playerid][Name],Obj[id][PosX], Obj[id][PosY], Obj[id][PosZ], Obj[id][RX], Obj[id][RY], Obj[id][RX], id);
printf("%s tempid0 != id", Obj[id][ObjOwner]);
mysql_tquery(Database2, DB_Query);
cache_delete(rand);
return 1;
}
return print("Couldnt execute any object-saving queries");
}