Need help with a function
#2

put somewhere on the top of the script (global variable):
pawn Код:
CurrentVehicle[MAX_PLAYERS]
and use it in your function and callback:
pawn Код:
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);
}
-----------------------

oh I've just looked more closely at your code.... you need vehicle MODEL, not the ID, also theres no need to store player vehicle model since your RespawnPlayerVehicle has model parameter (if you don't use its model anywhere else), so thy this:
pawn Код:
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);
}

Reply


Messages In This Thread
Need help with a function - by Vollzeitfan - 12.09.2009, 15:15
Re: Need help with a function - by Zeex - 12.09.2009, 15:41
Re: Need help with a function - by Vollzeitfan - 12.09.2009, 15:55
Re: Need help with a function - by Zeex - 12.09.2009, 16:05
Re: Need help with a function - by Vollzeitfan - 12.09.2009, 16:12
Re: Need help with a function - by Zeex - 12.09.2009, 16:19
Re: Need help with a function - by Vollzeitfan - 12.09.2009, 16:43
Re: Need help with a function - by Vollzeitfan - 12.09.2009, 19:15
Re: Need help with a function - by Zeex - 12.09.2009, 19:30
Re: Need help with a function - by Vollzeitfan - 12.09.2009, 19:47
Re: Need help with a function - by Vollzeitfan - 12.09.2009, 20:20

Forum Jump:


Users browsing this thread: 1 Guest(s)