Pause label bug. - 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: Pause label bug. (
/showthread.php?tid=225570)
Pause label bug. -
Richie - 13.02.2011
Trying to make a 3d text label attatched to a player that is paused.
But the labels gets bugged, there is no warnings or errors on compile, so i dont understand what is wrong.
Here is the code
http://pastebin.com/FmQ8jwfL
Here is the result:
/imageshack/f/samp033i.png/
Random pause labels gets attached to players that are not paused.
ANyone that can see whats wrong with it?
Re: Pause label bug. -
JaTochNietDan - 13.02.2011
Well, for one thing, there is a far easier way to see if someone is paused using OnPlayerUpdate and a Timer, for example:
pawn Код:
new bool:bPaused[MAX_PLAYERS];
public OnGameModeInit()
{
SetTimer("pauseCheck", 1000, true);
return 1;
}
public pauseCheck()
{
for(new i; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(bPaused[i]) SetPlayerChatBubble(playerid, "Paused", 0xFF0000FF, 100.0, 1000);
bPaused[i] = true;
}
}
return 1;
}
public OnPlayerUpdate(playerid)
{
bPaused[playerid] = false;
return 1;
}
This works because OnPlayerUpdate is no longer called when the player is paused, however the timer is still being called, which means that the variable isn't being set to false, but it will be set to true, so within 2 runs of the timer, the player will be recognized as paused.
Note that this is only an example.
Also if I were you, I'd forget about the 3D Text Labels and just use
SetPlayerChatBubble for the pause message
Re: Pause label bug. -
Richie - 13.02.2011
Thanks JaTochNietDan. I will try that.