Problem with spectating - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with spectating (
/showthread.php?tid=75157)
Problem with spectating -
dice7 - 29.04.2009
I made this
Код:
//-----------------------------death
new Plookingforkiller[MAX_PLAYERS];
new death[MAX_PLAYERS];
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(IsPlayerInDM[playerid] != 0)
{
GetPlayerName(killerid, name, sizeof(name));
format(string, sizeof(string), "%s has killed you", name );
GameTextForPlayer(playerid, string, 3000, 4);
SetCameraBehindPlayer(killerid);
TogglePlayerControllable(playerid, 0);
Plookingforkiller[playerid] = 1;
}
}
Код:
public OnPlayerSpawn(playerid)
{
if (Plookingforkiller[playerid]==1)
{
death[playerid] = SetTimerEx("deathspec", 3000, false, "i", playerid);
Plookingforkiller[playerid]=0;
}
}
Код:
forward deathspec(playerid);
public deathspec(playerid)
{
TogglePlayerControllable(playerid, 1);
SetCameraBehindPlayer(playerid);
}
It should spectate your killer for 3 seconds and then returning to normal, but when I'm killed or I suicide, my game crashes.
Re: Problem with spectating -
Joe Staff - 29.04.2009
SetCameraBehindPlayer(killerid);
TogglePlayerControllable(playerid, 0);
SetCameraBehindPlayer(killerid) only affects the person that is the killer.
Why are you using TogglePlayerControllable(playerid,0) if the player is dead and can't move anyway?
and do a check to make sure killerid != 255 incase the player killed himself or died of other means.