public DeathTimer(playerid) { if(PlayerInfo[playerid][pDead] == 1){ if(PlayerInfo[playerid][pDeadTimer] == 0){ PlayerInfo[playerid][pDead] = 0; SpawnPlayer(playerid); GivePlayerMoney(playerid, 100); SendClientMessage(playerid, COLOR_LIGHTBLUE, "You died, remember that you can't remember getting killed.!"); TextDrawHideForPlayer(playerid, Textdraw0); } else if(PlayerInfo[playerid][pDeadTimer] < 61){ if(PlayerInfo[playerid][pDeadAnim] == 1) { PlayerInfo[playerid][pDeadAnim] = 0; TogglePlayerControllable(playerid,false); ApplyAnimation(playerid,"CRACK","crckdeth2",4.1,0,1,1,1,0,1); } PlayerInfo[playerid][pDeadTimer]--; new string[128]; format(string,sizeof(string),"Time until \nrespawn:\n%d seconds",PlayerInfo[playerid][pDeadTimer]); TextDrawShowForPlayer(playerid, Textdraw0); TextDrawSetString(Textdraw0, string); } } }
Textdraw0 - you are using single TextDraw variable. You need to create array of textdraws (Text:Textdraw0[MAX_PLAYERS]) and use Textdraw0[playerid] instead
|
new Timers[MAX_PLAYERS];
new Text:Textdraw0[MAX_PLAYERS] = { Text:INVALID_TEXT_DRAW, ... };
//OPD:
PlayerInfo[playerid][pDeadTimer] = 60;
TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
Timers[playerid] = SetTimerEx(...);
public DeathTimer(playerid)
{
if(PlayerInfo[playerid][pDead] == 1){
if(PlayerInfo[playerid][pDeadTimer] == 0){
KillTimer(Timers[playerid]);
PlayerInfo[playerid][pDead] = 0;
SpawnPlayer(playerid);
GivePlayerMoney(playerid, 100);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You died, remember that you can't remember getting killed.!");
TextDrawHideForPlayer(playerid, Textdraw0[playerid]);
}
else if(PlayerInfo[playerid][pDeadTimer] < 61){
if(PlayerInfo[playerid][pDeadAnim] == 1)
{
PlayerInfo[playerid][pDeadAnim] = 0;
TogglePlayerControllable(playerid,false);
ApplyAnimation(playerid,"CRACK","crckdeth2",4.1,0,1,1,1,0,1);
}
PlayerInfo[playerid][pDeadTimer]--;
new string[128];
format(string,sizeof(string),"Time until \nrespawn:\n%d seconds",PlayerInfo[playerid][pDeadTimer]);
TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
TextDrawSetString(Textdraw0[playerid], string);
}
}
}
pawn Код:
#e2: In fact - rebuild the system. Create array with users which are dead (I strongly recommend y_iterate to handle looping), and have only global timer - then loop only through dead players, not all |
Textdraw0 = TextDrawCreate(557.000000, 120.000000, ""); TextDrawAlignment(Textdraw0, 2); TextDrawBackgroundColor(Textdraw0, 255); TextDrawFont(Textdraw0, 1); TextDrawLetterSize(Textdraw0, 0.440000, 1.600000); TextDrawColor(Textdraw0, -16776961); TextDrawSetOutline(Textdraw0, 1); TextDrawSetProportional(Textdraw0, 1); TextDrawUseBox(Textdraw0, 1); TextDrawBoxColor(Textdraw0, 255); TextDrawTextSize(Textdraw0, 50.000000, 150.000000);
//Global variables
static Timers[MAX_PLAYERS];
static Text:Textdraw0[MAX_PLAYERS] = { Text:INVALID_TEXT_DRAW, ... };
//OnPlayerDeath
PlayerInfo[playerid][pDeadTimer] = 60;
if(Text:Textdraw0[playerid] == Text:INVALID_TEXT_DRAW) DrawStuff(Textdraw0[playerid]);
TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
Timers[playerid] = SetTimerEx("DeathTimer", XXX, "i", playerid);
//Later
public DeathTimer(playerid)
{
if(PlayerInfo[playerid][pDead] == 1){
if(PlayerInfo[playerid][pDeadTimer] == 0){
KillTimer(Timers[playerid]);
PlayerInfo[playerid][pDead] = 0;
SpawnPlayer(playerid);
GivePlayerMoney(playerid, 100);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You died, remember that you can't remember getting killed.!");
TextDrawHideForPlayer(playerid, Textdraw0[playerid]);
}
else if(PlayerInfo[playerid][pDeadTimer] < 61){
if(PlayerInfo[playerid][pDeadAnim] == 1)
{
PlayerInfo[playerid][pDeadAnim] = 0;
TogglePlayerControllable(playerid,false);
ApplyAnimation(playerid,"CRACK","crckdeth2",4.1,0,1,1,1,0,1);
}
PlayerInfo[playerid][pDeadTimer]--;
new string[128];
format(string,sizeof(string),"Time until \nrespawn:\n%d seconds",PlayerInfo[playerid][pDeadTimer]);
TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
TextDrawSetString(Textdraw0[playerid], string);
}
}
}
stock DrawStuff(&Text:td) {
td = TextDrawCreate(557.000000, 120.000000, "_");
TextDrawAlignment(td, 2);
TextDrawBackgroundColor(td, 255);
TextDrawFont(td, 1);
TextDrawLetterSize(td, 0.440000, 1.600000);
TextDrawColor(td, -16776961);
TextDrawSetOutline(td, 1);
TextDrawSetProportional(td, 1);
TextDrawUseBox(td, 1);
TextDrawBoxColor(td, 255);
TextDrawTextSize(td, 50.000000, 150.000000);
}