Spectating the player who killed.
#1

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
Reply
#2

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

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

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;
}
Reply
#5

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");
Reply
#6

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)