SA-MP Forums Archive
<TextDraw Update> - 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: <TextDraw Update> (/showthread.php?tid=166264)



<TextDraw Update> - xfelipex - 08.08.2010

Just made a textdraw, which shows score. I got put it as string, but needs to update.It just shows as "Score : 0"
Код:
public OnPlayerSpawn(playerid)
{
	
     
	new string[46];
	format(string,sizeof(string),"Score : %d", GetPlayerScore(playerid));
    TextDrawSetString(Text:Textdraw1, string);
    TextDrawHideForPlayer(playerid, Text:Textdraw1);
    TextDrawShowForPlayer(playerid, Text:Textdraw1);
    return 1;
}
Does someone how to make it updates? cause I just know how to do it with normal score :S.


Re: <TextDraw Update> - Toni - 08.08.2010

Quote:
Originally Posted by xfelipex
Посмотреть сообщение
Just made a textdraw, which shows score. I got put it as string, but needs to update.It just shows as "Score : 0"
Код:
public OnPlayerSpawn(playerid)
{
	
     
	new string[46];
	format(string,sizeof(string),"Score : %d", GetPlayerScore(playerid));
    TextDrawSetString(Text:Textdraw1, string);
    TextDrawHideForPlayer(playerid, Text:Textdraw1);
    TextDrawShowForPlayer(playerid, Text:Textdraw1);
    return 1;
}
Does someone how to make it updates? cause I just know how to do it with normal score :S.
Just set a timer; Going off maybe every 1.5 seconds or so.


Re: <TextDraw Update> - (.Aztec); - 08.08.2010

Quote:
Originally Posted by xfelipex
Посмотреть сообщение
Just made a textdraw, which shows score. I got put it as string, but needs to update.It just shows as "Score : 0"
Код:
public OnPlayerSpawn(playerid)
{
	
     
	new string[46];
	format(string,sizeof(string),"Score : %d", GetPlayerScore(playerid));
    TextDrawSetString(Text:Textdraw1, string);
    TextDrawHideForPlayer(playerid, Text:Textdraw1);
    TextDrawShowForPlayer(playerid, Text:Textdraw1);
    return 1;
}
Does someone how to make it updates? cause I just know how to do it with normal score :S.
On the top:

pawn Код:
new SpawnedOnce[MAX_PLAYERS] = 0;
forward UpdateTD(playerid);
OnPlayerSpawn:

pawn Код:
public OnPlayerSpawn(playerid)
{
     if(SpawnedOnce[playerid] == 0)
{
     new string[46];
     format(string,sizeof(string),"Score : %d", GetPlayerScore(playerid));
     TextDrawSetString(Text:Textdraw1, string);
     TextDrawHideForPlayer(playerid, Text:Textdraw1);
     TextDrawShowForPlayer(playerid, Text:Textdraw1);
     SpawnedOnce[playerid] = 1;
     return 1;
}
else
{
//your other non-textdraw related code.
}
}
Somewhere else:

pawn Код:
public UpdateTD(playerid)
{
TextDrawHideForPlayer(playerid, Text:Textdraw1);
new string[46];
     format(string,sizeof(string),"Score : %d", GetPlayerScore(playerid));
     TextDrawSetString(Text:Textdraw1, string);
     TextDrawShowForPlayer(playerid, Text:Textdraw1);
return 1;
}
Should work, I'm not positive, though.


Re: <TextDraw Update> - xfelipex - 08.08.2010

Dude, how to do it please? cause SetPlayerScore is different from a string from textdraw, and Idk how to do with textdraw


Re: <TextDraw Update> - xfelipex - 08.08.2010

Sorry, need to waits 120 sec. Worked, but had to add new SpawnedOnce[MAX_PLAYERS]; and a settimer ; Thanks.


Re: <TextDraw Update> - Toni - 08.08.2010

Quote:
Originally Posted by xfelipex
Посмотреть сообщение
Dude, how to do it please? cause SetPlayerScore is different from a string from textdraw, and Idk how to do with textdraw
pawn Код:
forward UpdateTD();
pawn Код:
public UpdateTD()
{
new str[128];
format(str, sizeof(str), "Score: %d", GetPlayerScore(playerid));
TextDrawSetString(TextdrawID, str);
return 1;
}
OnPlayerSpawn, just add TextDrawShowForPlayer.

and under OnGameModeInIt
pawn Код:
SetTimer("UpdateTD", 1500, 1);
Hope that helped