Killcam Help!
#1

public OnPlayerDeath(playerid, killerid, reason)
{
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, killerid);
return 1;
}

I have this and when someone kill me it doesn't respawn. I need timer for it can you help please?
Reply
#2

pawn Код:
forward timer(playerid)
public OnPlayerDeath(playerid, killerid, reason)
{
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, killerid);
return 1;
}
public timer(playerid)
{
SpawnPlayer(playerid)
}
Reply
#3

Quote:
Originally Posted by Skillet`
Посмотреть сообщение
pawn Код:
forward timer(playerid)
public OnPlayerDeath(playerid, killerid, reason)
{
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, killerid);
return 1;
}
public timer(playerid)
{
SpawnPlayer(playerid)
}
Chap, you really have no idea what you're doing? Yeah, if so, then don't post in these topics without doing some research beforehand.

You will need to call the timer and pass the specific player ID to the timer as well, so you'll be using SetTimerEx. An example of this would be:
pawn Код:
// When player dies
SetTimerEx("RespawnPlayer", 3000, false, "i", playerid); // 3 seconds

// On the top of your script
forward RespawnPlayer(playerid);

// The timer itself
public RespawnPlayer(playerid)
{
    SpawnPlayer(playerid);
}
What you also should consider is killing the timer when the player disconnects so the next player that joins within the 3 seconds time frame does not get respawned instantly for a reason which will seem awkward for them (as they just have the same ID as the player who disconnected prior to them joining).

pawn Код:
// Top of your script
new pRespawnTimer[MAX_PLAYERS];
forward RespawnPlayer(playerid);

// When the player dies
pRespawnTimer[playerid] = SetTimerEx(...); // The SetTimerEx line from above

// When the player disconnects (OnPlayerDisconnect)
if(pRespawnTimer[playerid] != 0)
{
    KillTimer(pRespawnTimer[playerid]);
}

// The timer itself
public RespawnPlayer(playerid)
{
    SpawnPlayer(playerid);
    pRespawnTimer[playerid] = 0;
}
I hope you understand the basic of this.

Good luck scripting!
Reply
#4

@AndreT Thanks i got it working. rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)