[URGENT]Help me guys!
#1

Help me guys, it doesn't works if the players has died by falling. It works only if the players has been killed. So this is the script:

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    TogglePlayerSpectating(playerid, 1);
    PlayerSpectatePlayer(playerid, killerid);
   
    if(gTeam[playerid] == TEAM_RED) RedCount--;
    if(gTeam[playerid] == TEAM_GREEN) GreenCount--;
    PlayerInfo[playerid][Latezor] = 1;
   
    new tmp[256];
        new tmp2[256];
        format(tmp, sizeof(tmp), "~r~%d", RedCount);
        TextDrawSetString(Text:Textdraw13, tmp);

       format(tmp2, sizeof(tmp2), "~g~%d", GreenCount);
       TextDrawSetString(Text:Textdraw14, tmp2);
       return 1;

}
Is there any possible way to make it works?
Thanks!
Reply
#2

If I understand your problem right, try these things:

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
new tmp[256];
        new tmp2[256];
if(gTeam[playerid] == TEAM_RED) { RedCount--;
        format(tmp, sizeof(tmp), "~r~%d", RedCount);
        TextDrawSetString(Text:Textdraw13, tmp);
}
    if(gTeam[playerid] == TEAM_GREEN)  { GreenCount--;
       format(tmp2, sizeof(tmp2), "~g~%d", GreenCount);
       TextDrawSetString(Text:Textdraw14, tmp2);
}
if(killerid != INVALID_PLAYER_ID) {
    TogglePlayerSpectating(playerid, 1);
    PlayerSpectatePlayer(playerid, killerid);
   
    PlayerInfo[playerid][Latezor] = 1;
}
       return 1;
}
Fixed your bug of spectating invalid player id, and I guess the falling thing should work. If it doesn't, after closing bracket of if(killerid != INVALID_PLAYER_ID) add else { code of count-- and textdrawstring.


EDIT: Also, if you want to spectate random player when player died himself, use a loop and then spectateplayer
Reply
#3

oh thanks for that!
But my main problem is when I fell and died, the textdraw doesnt changes.. but when my friend has killed me, it changes(-1). help me with this thing please
Reply
#4

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new
        str[7];
       
    if(gTeam[playerid] == TEAM_RED)
    {
        RedCount--;
        format(str, sizeof(str), "~r~%d", RedCount);
        TextDrawSetString(Textdraw13, str);
    }
    else if(gTeam[playerid] == TEAM_GREEN)  
    {
        GreenCount--;
        format(str, sizeof(str), "~g~%d", GreenCount);
        TextDrawSetString(Textdraw14, str);
    }
   
    if(killerid != INVALID_PLAYER_ID)
    {
        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, killerid);
       
        PlayerInfo[playerid][Latezor] = 1;
    }
   
    return 1;
}
Try this.
Reply
#5

WOW! IT WORKS! Thank you very much! +REP BOTH OF YOU
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)