PlayerTextDraw vanishes after updating string
#1

I have a problem with my PlayerTextDraw and I made a filterscript to try and debug it, but nothing I tried worked so I figured why not ask the good old SAMP community for help.

The problem is this; executing /showit shows the text draw as "0" for one second, but when updated it scrambles a few numbers which I can see on the screen and vanishes in the next second. I placed a "SendClientMessage" for debugging, if maybe the variable didn't work right, but it all works as it should.. Except the updating, ofcourse.

Any suggestions that might help? Code below

Код:
#include <a_samp>
#include <zcmd>

new PlayerText:timer,time[MAX_PLAYERS],ptimer[MAX_PLAYERS];

public OnFilterScriptInit()
{
	for(new i = 0; i < MAX_PLAYERS; i++) ptimer[i] = SetTimerEx("UpdateShit",1000,true,"i",i);
	return 1;
}
public OnFilterScriptExit()
{
	for(new i = 0; i < MAX_PLAYERS; i++) KillTimer(ptimer[i]);
	return 1;
}

forward UpdateShit(playerid);
public UpdateShit(playerid)
{
time[playerid]++;
new string[10];
format(string,sizeof(string),"%d t",time[playerid]);
SendClientMessage(playerid,-1,string);
PlayerTextDrawSetString(playerid,timer,string);
PlayerTextDrawShow(playerid,timer);
return 1;
}

CMD:showit(playerid)
{
timer = CreatePlayerTextDraw(playerid,320,19,"0");
PlayerTextDrawShow(playerid,timer);
return 1;
}

CMD:removeit(playerid) return PlayerTextDrawDestroy(playerid,timer);
Reply
#2

Quote:

SetTimerEx("UpdateShit",1000,true,"i",i)

Why would you set the timer to 1 second then?
Reply
#3

Quote:
Originally Posted by TheDrx
Посмотреть сообщение
Why would you set the timer to 1 second then?
I want it to update the PlayerTextDraw every second with a different value shown as you can see in the public function.
Reply
#4

Quote:
Originally Posted by nerovani
Посмотреть сообщение
I want it to update the PlayerTextDraw every second with a different value shown as you can see in the public function.
What happends when you set the variable you would like to show either than "0"? Do it dissapears complete or just remains visible without updating itself?
Reply
#5

It disappears completely.
Reply
#6

Quote:
Originally Posted by nerovani
Посмотреть сообщение
It disappears completely.
Try to restart your timer direct in your public function.
Reply
#7

The timer works fine. The only problem is
PlayerTextDrawSetString(playerid,timer,string);
PlayerTextDrawShow(playerid,timer);
Reply
#8

Try to exact show the playerid your timer string.

PlayerTextDrawShow(playerid,timer[playerid]);
Reply
#9

That changes nothing, but tested it anyway, still nothing.
Reply
#10

You inizialise your TextDraw by your CMD: showit, but how do you inizialise your UpdateShit function?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)