SA-MP Forums Archive
Strange pausing behaviour - 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)
+--- Thread: Strange pausing behaviour (/showthread.php?tid=663675)



Strange pausing behaviour - Proxus - 08.02.2019

Hey, me again.

I just encountered a weird thing on my server. It doesn't matter if they're driving or walking, they appear to be pausing on my screen but on their own, they're not pausing. You can see it Here. (in this, they're actually driving but to me they're stationary and paused). This affects players and causes multiple problems. The only code I added recently was:

Код:
public OnPlayerUpdate(playerid)
{
	new WantedLevel;

	WantedLevel = GetPlayerWantedLevel(playerid);
	if (WantedLevel > 0)
 	{
		new Text3D:PlayerLabel[MAX_PLAYERS];
		PlayerLabel[playerid] = CreateDynamic3DTextLabel("test", COLOR_RED, 0.0, 0.0, 0.5, 40.0, playerid);
	}
}
Does OnPlayerUpdate have anything to do with that because it is called when the player moves? Thanks in advance.


Re: Strange pausing behaviour - ComDuck - 08.02.2019

Err, I don't see any issues with the code itself. Besides that, I assume CreateDynamic3DTextLabel is not under SA-MP's built-in natives. Did you call the custom native using the right parameter values?


Re: Strange pausing behaviour - Calisthenics - 08.02.2019

You need to return 1 at the end of the callback otherwise it will not sync it for the other players.

There is a mistake in your code. You are creating a dynamic 3D label in every tick. You do not destroy the previous, you do not update the text and you overwrite the previous.

Do not use OnPlayerUpdate for this, hook SetPlayerWantedLevel and if wanted level goes from 0 to X, then create the label. If it is set back to 0, destroy the label and reset variable. If wanted level changes value above 0, update the text only without re-creating the label.


Re: Strange pausing behaviour - Proxus - 08.02.2019

Ah alright, thanks. I already identified creating the 3d text label and was going to use IsValidDynamicTextLabel but your way works too. Also, what is the TextDraw ID for DestroyDynamic3DTextLabel? It seems to return errors every time. +repped


Re: Strange pausing behaviour - Calisthenics - 08.02.2019

Move the variable outside of any callback to declare it as global.
pawn Код:
new Text3D:PlayerLabel[MAX_PLAYERS] = {Text3D:-1, ...};
When destroying the label:
pawn Код:
DestroyDynamic3DTextLabel(PlayerLabel[playerid]);
PlayerLabel[playerid] = Text3D:-1;
to make it even better:
pawn Код:
if (PlayerLabel[playerid] != Text3D:-1)
{
    DestroyDynamic3DTextLabel(PlayerLabel[playerid]);
    PlayerLabel[playerid] = Text3D:-1;
}



Re: Strange pausing behaviour - Proxus - 08.02.2019

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
Do not use OnPlayerUpdate for this, hook SetPlayerWantedLevel and if wanted level goes from 0 to X, then create the label. If it is set back to 0, destroy the label and reset variable. If wanted level changes value above 0, update the text only without re-creating the label.
I have multiple reasons that a player may get a wanted level. Do I just make a function and call the function every time a player gets a wanted level (detected when SetPlayerWantedLevel is used). Just making sure that I understood what you were saying.


Re: Strange pausing behaviour - Calisthenics - 08.02.2019

Yes. Hook SetPlayerWantedLevel or create your own custom function in which you set the wanted level and create/update/destroy the label.


Re: Strange pausing behaviour - Dayrion - 08.02.2019

Also, the frequency of the label is too high. You might update nor create a label when it you really need it only (a player kill another player, create a label nor update it, etc...). Not every 1/4 sec.


Re: Strange pausing behaviour - Proxus - 08.02.2019

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
Also, the frequency of the label is too high. You might update nor create a label when it you really need it only (a player kill another player, create a label nor update it, etc...). Not every 1/4 sec.
That's what we were just talking about. OnPlayerUpdate seems like a stupid choice now so we're changing it.


Re: Strange pausing behaviour - Dayrion - 08.02.2019

Quote:
Originally Posted by Proxus
Посмотреть сообщение
That's what we were just talking about. OnPlayerUpdate seems like a stupid choice now so we're changing it.
Oh yes lol, I haven't read correctly mb