public OnPlayerUpdate(playerid)
{
if(InSumo[playerid] == 1)
{
new Float:pPos[3],RAND = random(sizeof(SUMO_SPAWNS)),RANDCARS = random(sizeof(SUMO_CARS));
GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
if (pPos[2] < 10.0)//If this further down the track
{
CreateVehicleEx(playerid, SUMO_CARS[RANDCARS][0], SUMO_SPAWNS[RAND][0], SUMO_SPAWNS[RAND][1], SUMO_SPAWNS[RAND][2], SUMO_SPAWNS[RAND][3]+5, -1, -1);//gives a new car > random
PutPlayerInVehicle(playerid, g_SPAWNED_VEHICLE[playerid], 0);
return 1;
}
if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)//if out of the car
{
CreateVehicleEx(playerid, SUMO_CARS[RANDCARS][0], SUMO_SPAWNS[RAND][0], SUMO_SPAWNS[RAND][1], SUMO_SPAWNS[RAND][2], SUMO_SPAWNS[RAND][3]+5, -1, -1);//gives a new car > random
PutPlayerInVehicle(playerid, g_SPAWNED_VEHICLE[playerid], 0);
}
}
return 1;
}
Use a timer for this purpose, OnPlayerUpdate is not appropriate and not regular as well symmetric!
Also why using RAND & RANDCARS variables for same purpose. Also you haven't placed the checks correctly. |