How to update textdraw information ? -
SandKing94 - 08.08.2014
So i have this
PHP код:
public OnPlayerUpdate(playerid)
{
new string[50];
format(string, sizeof(string), "Score:%d", GetPlayerScore(playerid));
TextDrawSetString(ScoreText, string);
return 1;
}
PHP код:
public OnPlayerSpawn(playerid)
{
new str[100];
format(str, sizeof(str), "Score:%d", GetPlayerScore(playerid));
ScoreText = TextDrawCreate(503.500000, 108.062500, "Score:");
TextDrawSetString(ScoreText, str);
TextDrawLetterSize(ScoreText, 0.300000, 1.399999);
TextDrawAlignment(ScoreText, 1);
TextDrawColor(ScoreText, -1);
TextDrawSetShadow(ScoreText, 0);
TextDrawSetOutline(ScoreText, 1);
TextDrawBackgroundColor(ScoreText, 51);
TextDrawFont(ScoreText, 2);
TextDrawSetProportional(ScoreText, 1);
return 1;
}
But the score is still the same i have to reconnect to see my real score.
Re: How to update textdraw information ? -
[XST]O_x - 08.08.2014
pawn Код:
new updateTimer[ MAX_PLAYERS ] ;
forward UpdatePlayer(playerid);
public OnPlayerConnect(playerid)
{
updateTimer[playerid] = SetTimerEx("UpdatePlayer", 1000, true, "i", playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
KillTimer(updateTimer[playerid]);
return 1;
}
public UpdatePlayer(playerid)
{
new string[24];
format(string, sizeof string, "Score: %d", GetPlayerScore(playerid));
TextDrawSetString(ScoreText[playerid], string);
return 1;
}
Re: How to update textdraw information ? -
arakuta - 08.08.2014
You can create a function that gives score and automatically update the textdraw.
pawn Код:
GivePlayerScore(playerid,scr)
{
SetPlayerScore(playerid,GetPlayerScore(playerid) + score);
PlayerTextDrawSetString(playerid,text[playerid],"String");
}
Re: How to update textdraw information ? -
SandKing94 - 08.08.2014
But when player kill player he gets score
Re: How to update textdraw information ? -
Vince - 08.08.2014
And? You can update the textdraw in OnPlayerDeath. Using a timer to listen for an event that is initiated by the scripter (giving score) is frankly pretty dumb.
Re: How to update textdraw information ? -
[XST]O_x - 08.08.2014
Quote:
Originally Posted by arakuta
You can create a function that gives score and automatically update the textdraw.
pawn Код:
GivePlayerScore(playerid,scr) { SetPlayerScore(playerid,GetPlayerScore(playerid) + score); PlayerTextDrawSetString(playerid,text[playerid],"String"); }
|
That is actually genuis. Can save a timer usage.
Re: How to update textdraw information ? -
SandKing94 - 08.08.2014
What if i want to make the same with kills and deaths textdraw ?
Re: How to update textdraw information ? -
SandKing94 - 08.08.2014
Quote:
Originally Posted by [XST]O_x
pawn Код:
new updateTimer[ MAX_PLAYERS ] ;
forward UpdatePlayer(playerid);
public OnPlayerConnect(playerid) { updateTimer[playerid] = SetTimerEx("UpdatePlayer", 1000, true, "i", playerid); return 1; }
public OnPlayerDisconnect(playerid, reason) { KillTimer(updateTimer[playerid]); return 1; }
public UpdatePlayer(playerid) { new string[24]; format(string, sizeof string, "Score: %d", GetPlayerScore(playerid)); TextDrawSetString(ScoreText[playerid], string); return 1; }
|
Dont works
Re: How to update textdraw information ? -
caoraivoso3 - 08.08.2014
You need
https://sampwiki.blast.hk/wiki/TextDrawShowForPlayer
Re: How to update textdraw information ? -
SandKing94 - 08.08.2014
bump