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; }
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; } |
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; } |
new SpawnedOnce[MAX_PLAYERS] = 0;
forward UpdateTD(playerid);
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.
}
}
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;
}
Dude, how to do it please? cause SetPlayerScore is different from a string from textdraw, and Idk how to do with textdraw
|
forward UpdateTD();
public UpdateTD()
{
new str[128];
format(str, sizeof(str), "Score: %d", GetPlayerScore(playerid));
TextDrawSetString(TextdrawID, str);
return 1;
}
SetTimer("UpdateTD", 1500, 1);