Text draw of max players. And show it all.
#1

PHP код:
new score[MAX_PLAYERS]
new 
scoreS[128][MAX_PLAYERS];
new 
Text:scoreT[MAX_PLAYERS];
new 
players;
public 
OnPlayerConnect(playerid)
{
    
players++;
    
scoreT[playerid] = TextDrawCreate(320.000091426.000009 +(players 10), scoreS[playerid]);
TextDrawLetterSize(scoreT[playerid], 0.6999982.000000);
TextDrawAlignment(scoreT[playerid], 1);
TextDrawColor(scoreT[playerid], -16776961);
TextDrawSetShadow(scoreT[playerid], 0);
TextDrawSetOutline(scoreT[playerid], -1);
TextDrawBackgroundColor(scoreT[playerid], 51);
TextDrawFont(scoreT[playerid], 1);
TextDrawSetProportional(scoreT[playerid], 1);
return 
1;
}
public 
OnPlayerUpdate(playerid)
{
    
format(scoreS[playerid],128,"%i",score[playerid]);
    
TextDrawSetString(scoreT[playerid],scoreS[playerid]);
    return 
1;
}
CMD:show(playerid,params[])
{
    for(new 
i=0,i<MAX_PLAYERS;i++)
    {
        
TextDrawShowForPlayer(playerid,scoreT[i]);
    }
    return 
1;
}
//Everything works fine but the sever connection is closed after using /show command. It say you are banned from //this sever 
Reply
#2

PHP код:
for(new i=0,i<MAX_PLAYERS;i++)
    {
        if(
IsPlayerConnected(i)) {
            
TextDrawShowForPlayer(playerid,scoreT[i]);
        }
    } 
Try checking if the player is connected before showing.
Reply
#3

Is ScoreT supposed to be the same for all players? Because if it is you're much better off creating ONE global textdraw instead of individual player textdraw.

I am also obliged to say that OnPlayerUpdate is a horrible way to update the score textdraw seeing as YOU are the only one that influences "score[playerid]"; the textdraw should be update as this variable is updated, not at any other time. OnPlayerUpdate is not a general purpose timer.

@Dark: I doubt this will have any effect, honestly.
Reply
#4

You are doing it all wrong, you should create global TextDras under OnGameModeInit. Player TextDraws go under OnPlayerConnect.

Also, did you know TextDrawShowForAll exists? https://sampwiki.blast.hk/wiki/TextDrawShowForAll
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)