how to spec player - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: how to spec player (
/showthread.php?tid=486453)
how to spec player -
MahdiGames - 08.01.2014
hello, how to spec player when the playerid death spec the killered for 5 seconds and write Your Killer: %s?
Re: how to spec player -
Seif- - 08.01.2014
You'll have to use TogglePlayerSpectating, PlayerSpectatePlayer, SetTimerEx and GameText or Textdraw.
Under OnPlayerDeath, check if the killerid is valid(IsPlayerConnected). If valid, store his ID inside a global variable. Now under OnPlayerSpawn, check if that global variable has a valid killerid(validate it). If the killerid is connected, use TogglePlayerSpectating and PlayerSpectatePlayer to spectate killerid, then set a timer to stop spectating(TogglePlayerSpectating again) and add a GameText to display for 5 seconds.
Re: how to spec player -
amirab - 09.01.2014
add this on the top of your script:
PHP код:
forward FinishPlayerSpectatePlayer(playerid);
and You can use these codes in OnPlayerDeath:
PHP код:
TogglePlayerSpectating(playerid, 1);
new str[128];
new pname;
GetPlayerName(killerid , pname , MAX_PLAYER_NAME);
format(str, sizeof(str),"Your Killer Is %s.", pname);
SendClientMessage(playerid , -1 , str);
PlayerSpectatePlayer(playerid, killerid);
SetTimerEx("FinishPlayerSpectatePlayer", 5000, 0, "i", playerid);
and then after that add this public/callback in your script
PHP код:
public FinishPlayerSpectatePlayer(playerid)
{
TogglePlayerSpectating(playerid, 0);
return 1;
}
Re: how to spec player -
Seif- - 09.01.2014
^ I'm not very sure myself, but I think you can't spectate others under OnPlayerDeath. Correct me if I'm wrong, because I think you automatically respawn after death.
Re: how to spec player -
MahdiGames - 09.01.2014
You can spec + rep and ill try out
Re: how to spec player -
Aliassassin123456 - 10.01.2014
pawn Код:
#defien SpectateTimer 5 // Second
forward DeathTimerFinished(playerid);
public OnPlayerDeath(playerid, killerid, reason)
{
if(IsPlayerConnected(killerid))
{
TogglePlayerSpectating(playerid, 1);
if(IsPlayerInAnyVehicle(killerid)) PlayerSpectateVehicle(playerid, GetPlayerVehicleID(killerid));
else PlayerSpectatePlayer(playerid, killerid);
SetTimerEx("DeathTimerFinished", SpectateTime*1000, 0, "d", playerid);
new KillerName[MAX_PLAYER_NAME];
GetPlayerName(killerid, KillerName, sizeof KillerName);
new string[70];
format(string, sizeof string, "%s has been killed you.", KillerName);
GameTextForPlayer(playerid, string, SepctateTimer*1000, 6);
}
return 1;
}
public DeathTimerFinished(playerid)
{
return TogglePlayerSpectating(playerid, 0);
}