25.02.2013, 17:21
Hello there dear community, I've run into a problem regarding my death system on my server and can't figure out how to get it to work. I've tried most ways but it still returns problems.
This is my timer callback. Earlier it looped through all players and decided which of those had the variable pDeath as 1. Everything worked until I tried putting two players on the same time in death mode. It resulted in that when the second player died it first saw the other players timer textdraw and then it's own,
After that I tried making it like this.. instead of looping through all players I just added playerid on every single one and then put the SetTimerEx in OnPlayerDeath. That resulted in that both timers were mixed up and everything went wrong.
In OnPlayerDeath
[code] PlayerInfo[playerid][pDeadTimer] = 60;
TextDrawShowForPlayer(playerid,Textdraw0);[code]
So do you have any suggestions on how to fix this problem?
This is my timer callback. Earlier it looped through all players and decided which of those had the variable pDeath as 1. Everything worked until I tried putting two players on the same time in death mode. It resulted in that when the second player died it first saw the other players timer textdraw and then it's own,
Код:
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); } } }
In OnPlayerDeath
[code] PlayerInfo[playerid][pDeadTimer] = 60;
TextDrawShowForPlayer(playerid,Textdraw0);[code]
So do you have any suggestions on how to fix this problem?