How to update textdraw information ?
#1

So i have this
PHP код:
public OnPlayerUpdate(playerid)
{
      new 
string[50];
    
format(stringsizeof(string), "Score:%d"GetPlayerScore(playerid));
    
TextDrawSetString(ScoreTextstring);
    return 
1;

PHP код:
public OnPlayerSpawn(playerid)
{
new 
str[100];
format(strsizeof(str), "Score:%d"GetPlayerScore(playerid));
ScoreText TextDrawCreate(503.500000108.062500"Score:");
TextDrawSetString(ScoreTextstr);
TextDrawLetterSize(ScoreText0.3000001.399999);
TextDrawAlignment(ScoreText1);
TextDrawColor(ScoreText, -1);
TextDrawSetShadow(ScoreText0);
TextDrawSetOutline(ScoreText1);
TextDrawBackgroundColor(ScoreText51);
TextDrawFont(ScoreText2);
TextDrawSetProportional(ScoreText1);
return 
1;

But the score is still the same i have to reconnect to see my real score.
Reply
#2

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;
}
Reply
#3

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");
}
Reply
#4

But when player kill player he gets score
Reply
#5

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.
Reply
#6

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.
Reply
#7

What if i want to make the same with kills and deaths textdraw ?
Reply
#8

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
Reply
#9

You need https://sampwiki.blast.hk/wiki/TextDrawShowForPlayer
Reply
#10

bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)