public OnPlayerExitVehicle(playerid, vehicleid) { if(RaceParticipant[playerid]>0) { if (EnableRespawn == 1) { new currentvehicle = (GetPlayerVehicleID(playerid)); new lastCP = (CurrentCheckpoint[playerid]-1); DestroyVehicle(currentvehicle); SetPlayerHealth(playerid, 0); SetRaceCheckpoint(playerid,lastCP,CurrentCheckpoint[playerid]); RespawnTimer = SetTimer("RespawnPlayerInVehicle", RespawnDelay, false); RespawnPlayerInVehicle(playerid, currentvehicle); } } return 1; } stock RespawnPlayerInVehicle(playerid, vehicleid) { new lastCP = (CurrentCheckpoint[playerid]-1); SpawnPlayer(playerid); SetPlayerPos(playerid, lastCP); CreateVehicle(currentvehicle, lastCP, 2, 4, 600); PutPlayerInVehicle(playerid, currentvehicle, 0); KillTimer(RespawnTimer); }
CurrentVehicle[MAX_PLAYERS]
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(RaceParticipant[playerid]>0)
{
if (EnableRespawn == 1)
{
CurrentVehicle[playerid] = vehicleid;
new lastCP = (CurrentCheckpoint[playerid]-1);
DestroyVehicle(vehicleid);
SetPlayerHealth(playerid, 0);
SetRaceCheckpoint(playerid,lastCP,CurrentCheckpoint[playerid]);
RespawnTimer = SetTimer("RespawnPlayerInVehicle", RespawnDelay, false);
RespawnPlayerInVehicle(playerid, CurrentVehicle[playerid] );
}
}
return 1;
}
stock RespawnPlayerInVehicle(playerid, vehicleid)
{
new lastCP = (CurrentCheckpoint[playerid]-1);
SpawnPlayer(playerid);
SetPlayerPos(playerid, lastCP);
CreateVehicle(vehicleid , lastCP, 2, 4, 600);
PutPlayerInVehicle(playerid, vehicleid, 0);
KillTimer(RespawnTimer);
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(RaceParticipant[playerid]>0)
{
if (EnableRespawn == 1)
{
new lastCP = (CurrentCheckpoint[playerid]-1);
SetPlayerHealth(playerid, 0.0);
SetRaceCheckpoint(playerid,lastCP,CurrentCheckpoint[playerid]);
RespawnTimer = SetTimerEx("RespawnPlayerInVehicle", RespawnDelay, false, "ii", playerid, GetVehicleModel(vehicleid));
DestroyVehicle(vehicleid);
// RespawnPlayerInVehicle(playerid, CurrentVehicle[playerid] ); why do you do it twice?
}
}
return 1;
}
stock RespawnPlayerInVehicle(playerid, vehicleid)
{
new lastCP = (CurrentCheckpoint[playerid]-1);
new vehicleid = CreateVehicle(model, /*here should be x, y and z, not cp id */, 2, 4, 600);
SpawnPlayer(playerid);
SetPlayerPos(playerid, /* and here too */);
PutPlayerInVehicle(playerid, vehicleid, 0);
KillTimer(RespawnTimer);
}
CurrentVehicle[MAX_PLAYERS]
new CurrentVehicle[MAX_PLAYERS];
Originally Posted by ZeeX
I guess there is a checkpoint array which stores their coords and LastCP is the index of some checkpoint, and you can extract its coords using that index.
|
YRACE 1 Yagu 1 2 Yagu 227212 Yagu 233628 Yaguslave 372568 A 0 A 0 Yagu 112007 Yagu 112784 Yagu 115205 Yagu 120844 Yaguslave 127753 2096.481689 834.807189 6.446568 2466.802001 835.230346 6.441473 2725.932861 1182.561035 6.440519 2725.099365 2293.141113 6.440557 2545.458984 2588.155761 4.565608 2023.114746 2565.392822 6.498682 1326.486450 2451.088134 6.442695 1207.436279 2045.341796 6.444301 1214.165039 994.541076 6.518639 1976.803100 834.880798 6.445075
Originally Posted by ZeeX
OK, yrace has Float:RaceCheckpoints[MAX_RACECHECKPOINTS][3] - this is checkpoint array.
And are you sure you need to kill player, destroy his car and spawn him? Why not just put him back in the car? |
new RespawnDelay = 100; //The time the player will be frozen after respawned in ms.
new RespawnTimer; //DO NOT CHANGE!!!
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(RaceParticipant[playerid] == 4)
{
if (EnableRespawn == 1)
{
new model = (GetVehicleModel(vehicleid));
SetPlayerHealth(playerid, 100.0);
SetRaceCheckpoint(playerid, CurrentCheckpoint[playerid]-1 ,CurrentCheckpoint[playerid]);
DestroyVehicle(vehicleid);
SetPlayerPos(playerid, lastCPx, lastCPy, lastCPz);
new currentvehicleID = CreateVehicle(model, lastCPx, lastCPy, lastCPz, lastCPa, 2, 4, 600);
PutPlayerInVehicle(playerid, currentvehicleID, 0);
RespawnTimer = SetTimer("RespawnFreeze", RespawnDelay, false);
TogglePlayerControllable(playerid,0);
}
}
return 1;
}
stock RespawnFreeze(playerid)
{
TogglePlayerControllable(playerid,1);
KillTimer(RespawnTimer);
}
forward RespawnFreeze(playerid);
public RespawnFreeze(playerid)
{
TogglePlayerControllable(playerid,1);
KillTimer(RespawnTimer);
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(RaceParticipant[playerid] == 4)
{
if (EnableRespawn == 1)
{
new model = (GetVehicleModel(vehicleid));
SetPlayerHealth(playerid, 100.0);
SetRaceCheckpoint(playerid, CurrentCheckpoint[playerid],CurrentCheckpoint[playerid]+1);
DestroyVehicle(vehicleid);
SetPlayerPos(playerid, lastCPx, lastCPy, lastCPz);
new currentvehicleID = CreateVehicle(model, lastCPx, lastCPy, lastCPz, lastCPa, 2, 4, 600);
PutPlayerInVehicle(playerid, currentvehicleID, 0);
RespawnTimer = SetTimer("RespawnFreeze", RespawnDelay, false);
TogglePlayerControllable(playerid,0);
}
}
return 1;
}
public RespawnFreeze(playerid)
{
TogglePlayerControllable(playerid,1);
KillTimer(RespawnTimer);
}