Hello, I use this code to generate a random checkpoint from an SQL table:
Код:
RandomGenerateCP(playerid)
{
new result[150], Float:x, Float:y, Float:z, streetname[50];
mysql_query( "SELECT * FROM `streetcorners` ORDER BY RAND( ) LIMIT 1;" );
mysql_store_result();
if(mysql_fetch_row_format(result))
{
sscanf( result, "p<|>{i}fffs[50]", x, y, z, streetname );
DestroyDynamicRaceCP(MissionCPMapicon[playerid][0]);
DestroyDynamicMapIcon(MissionCPMapicon[playerid][1]);
MissionCPMapicon[playerid][0] = CreateDynamicRaceCP(2, x, y, z, -2000.0, 2000.0, 0.0, 3.0, _, _, playerid );
MissionCPMapicon[playerid][1] = CreateDynamicMapIcon(x, y, z, 0, 0xFF0000FF, _, _, playerid, 2000.0, MAPICON_GLOBAL);
}
mysql_free_result();
return streetname;
}
Unfortunately, whenever this script runs with two or more players, their checkpoints (and sometimes their mapicons) seem to get destroyed as well.
For example: RandomGenerateCP(1) gets called when player #1 does some action. At the same time, all the other players who got a CP using this function have their CPs removed. What can be done to prevent this or what am I doing wrong?