PlayerTextDraw vanishes after updating string -
nerovani - 14.10.2016
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);
Re: PlayerTextDraw vanishes after updating string -
TheDrx - 14.10.2016
Quote:
SetTimerEx("UpdateShit",1000,true,"i",i)
|
Why would you set the timer to 1 second then?
Re: PlayerTextDraw vanishes after updating string -
nerovani - 14.10.2016
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.
Re: PlayerTextDraw vanishes after updating string -
TheDrx - 14.10.2016
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?
Re: PlayerTextDraw vanishes after updating string -
nerovani - 14.10.2016
It disappears completely.
Re: PlayerTextDraw vanishes after updating string -
TheDrx - 14.10.2016
Quote:
Originally Posted by nerovani
It disappears completely.
|
Try to restart your timer direct in your public function.
Re: PlayerTextDraw vanishes after updating string -
nerovani - 14.10.2016
The timer works fine. The only problem is
PlayerTextDrawSetString(playerid,timer,string);
PlayerTextDrawShow(playerid,timer);
Re: PlayerTextDraw vanishes after updating string -
TheDrx - 14.10.2016
Try to exact show the playerid your timer string.
PlayerTextDrawShow(playerid,timer[playerid]);
Re: PlayerTextDraw vanishes after updating string -
nerovani - 14.10.2016
That changes nothing, but tested it anyway, still nothing.
Re: PlayerTextDraw vanishes after updating string -
TheDrx - 14.10.2016
You inizialise your TextDraw by your CMD: showit, but how do you inizialise your UpdateShit function?