SA-MP Forums Archive
Spectating the player who killed. - 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: Spectating the player who killed. (/showthread.php?tid=185556)



Spectating the player who killed. - Haydz - 25.10.2010

First question,

Player who dies spectates the player who kills them for 5 seconds, it has the gametextforplayer saying "respawning in 5.. and does a countdown, how could i do this?

my attempt.

didn't really work, you spectated yourself and yes i had all of the forward timer stuff etc.
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    TogglePlayerSpectating(playerid, 1);
    PlayerSpectatePlayer(playerid, killerid);
    SetTimer("spectating",5000,false);
	new string[50];
    format(string, sizeof(string), "Repawning in 5");
    GameTextForPlayer(playerid, string, 5000, 4);
	TogglePlayerSpectating(playerid, 0);
    return 1;
}
Thanks in advance


Re: Spectating the player who killed. - SampStunta - 25.10.2010

pawn Код:
TogglePlayerSpectating(playerid, 1);
EDIT: Didn't see you already did that, sorry.


Re: Spectating the player who killed. - SampStunta - 25.10.2010

pawn Код:
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, specplayerid);
SetPlayerInterior(playerid,GetPlayerInterior(specplayerid));
gSpectateID[playerid] = specplayerid;
gSpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER;



Re: Spectating the player who killed. - Retardedwolf - 25.10.2010

pawn Код:
new spectateTimer[MAX_PLAYERS];
foward respawnCounter(playerid);
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    TogglePlayerSpectating(playerid, 1);
    PlayerSpectatePlayer(playerid, killerid);
    spectateTimer[playerid] = SetTimerEx("respawnCounter", 1000, true, "d" , playerid);
    return 1;
}
pawn Код:
public respawnCounter(playerid)
{
    new string[21];
    format(string, sizeof(string), "Respawning in %d", GetPVarInt(playerid, "rCount");
    GameTextForPlayer(playerid, string, 1000, 4);
    if(GetPVarInt(playerid, "rCount") == 0)
    {
        TogglePlayerSpectating(playerid, 0);
        KillTimer(spectateTimer[playerid]);
    }
    return 1;
}



Re: Spectating the player who killed. - Haydz - 25.10.2010

got 2 errors, fixed one of them tho couldn't figure out this one.

Код:
public respawnCounter(playerid)
{
    new string[21];
    format(string, sizeof(string), "Respawning in %d", GetPVarInt(playerid, "rCount");
    GameTextForPlayer(playerid, string, 1000, 4);
    if(GetPVarInt(playerid, "rCount") == 0)
    {
        TogglePlayerSpectating(playerid, 0);
        KillTimer(spectateTimer[playerid]);
    }
    return 1;
}
error:
C:\Documents and Settings\Hayden Bruin\Desktop\Haydz\Courtroom DM\gamemodes\CourtroomDM.pwn(405) : error 001: expected token: ",", but found ";"

(line 405) format(string, sizeof(string), "Respawning in %d", GetPVarInt(playerid, "rCount");


Re: Spectating the player who killed. - Retardedwolf - 25.10.2010

pawn Код:
new spectateTimer[MAX_PLAYERS];
foward respawnCounter(playerid);
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    TogglePlayerSpectating(playerid, 1);
    PlayerSpectatePlayer(playerid, killerid);
    spectateTimer[playerid] = SetTimerEx("respawnCounter", 1000, true, "d" , playerid);
    SetPVarInt(playerid, "rCount", 5);
    return 1;
}
pawn Код:
public respawnCounter(playerid)
{
    new string[21];
    format(string, sizeof(string), "Respawning in %d", GetPVarInt(playerid, "rCount"));
    GameTextForPlayer(playerid, string, 1000, 4);
    SetPVarInt(playerid, "rCount", GetPVarInt(playerid, "rCount")-1);    
    if(GetPVarInt(playerid, "rCount") == 0)
    {
        TogglePlayerSpectating(playerid, 0);
        KillTimer(spectateTimer[playerid]);
        SetPVarInt(playerid, "rCount", 0);
    }
    return 1;
}

Sorry, I fixed it now.