#1
https://sampwiki.blast.hk/wiki/OnPlayerExitVehicle
https://sampwiki.blast.hk/wiki/SetVehicleToRespawn
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(vehicleid == specificvehicle) //Replace this with your vehicle variable
{
SetVehicleToRespawn(vehicleid);
}
return 1;
}
EDIT:
#2
https://sampwiki.blast.hk/wiki/SetPlayerRaceCheckpoint
https://sampwiki.blast.hk/wiki/OnPlayerEnterRaceCheckpoint
pawn Код:
new Checkpointcount[MAX_PLAYERS]; //At the top of your script
new CheckNext[MAX_PLAYERS];
new Checks[MAX_CHECKPOINTS][3] = {
{x1, y1, z1},
{x2, y2, z2},
{x3, y3, z3},
//etc...
{x24, y24, z24}
};
public OnPlayerConnect(playerid)
{
Checkpointcount[playerid] = 0;
CheckNext[playerid] = -1;
return 1;
}
CMD:beginrace(playerid, params[])
{
if(Checkpointcount[playerid] > 0) return SendClientMessage(playerid, 0xFF0000FF, "You are already racing! Use /stoprace to end it.");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, 0xFF0000FF, "You must be the driver of a vehicle to begin the race.");
Checkpointcount[playerid] = 1;
new rand = random(sizeof(Checks));
new rand2 = random(sizeof(Checks));
SetPlayerRaceCheckpoint(playerid, 0, Checks[rand][0], Checks[rand][1], Checks[rand][2], Checks[rand2][0], Checks[rand2][1], Checks[rand2][2], 5.0);
CheckNext[playerid] = rand2;
SendClientMessage(playerid, 0xFFFF00FF, "The race has begun!");
return 1;
}
CMD:stoprace(playerid, params[])
{
if(Checkpointcount[playerid] == 0) return SendClientMessage(playerid, 0xFF0000FF, "You are not racing! Type /beginrace to start.");
DisablePlayerRaceCheckpoint(playerid);
Checkpointcount[playerid] = 0;
CheckNext[playerid] = -1;
SendClientMessage(playerid, 0xFFFF00FF, "You are no longer racing.");
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
if(Checkpointcount[playerid] >= 4)
{
DisablePlayerRaceCheckpoint(playerid);
SendClientMessage(playerid, 0xFFFF00FF, "You have finished the race!");
//Give reward here, optional.
Checkpointcount[playerid] = 0;
return 1;
}
if(Checkpointcount[playerid] > 0 && Checkpointcount[playerid] < 3)
{
new rand = random(sizeof(Checks));
DisablePlayerRaceCheckpoint(playerid);
SetPlayerRaceCheckpoint(playerid, 0, Checks[CheckNext[playerid]][0], Checks[CheckNext[playerid]][1], Checks[CheckNext[playerid]][2], Checks[rand][0], Checks[rand][1], Checks[rand][2], 5.0);
Checkpointcount[playerid]++;
CheckNext[playerid] = rand;
return 1;
}
if(Checkpointcount[playerid] == 3)
{
DisablePlayerRaceCheckpoint(playerid);
SetPlayerRaceCheckpoint(playerid, 1, Checks[CheckNext[playerid]][0], Checks[CheckNext[playerid]][1], Checks[CheckNext[playerid]][2], 0.0, 0.0, 0.0, 5.0);
Checkpointcount[playerid]++;
CheckNext[playerid] = -1;
return 1;
}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(Checkpointcount[playerid] > 0)
{
Checkpointcount[playerid] = 0;
CheckNext[playerid] = -1;
SendClientMessage(playerid, 0xFF0000FF, "You have left your vehicle and the race has ended!");
DisablePlayerRaceCheckpoint(playerid);
}
return 1;
}
This took me a really long time to make, because I had to do it in the quick reply box, so if there is any errors, I apologise, but other than changing the 'x1, y1, z1', 'x2, y2, z2' etc. with your own coordinates, everything here should work. (With the ZCMD includes of course)