SA-MP Forums Archive
Text draw of max players. And show it all. - 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)
+--- Thread: Text draw of max players. And show it all. (/showthread.php?tid=616329)



Text draw of max players. And show it all. - Maheerali - 03.09.2016

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 



Re: Text draw of max players. And show it all. - DarkSkull - 03.09.2016

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.


Re: Text draw of max players. And show it all. - Vince - 03.09.2016

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.


Re: Text draw of max players. And show it all. - SickAttack - 03.09.2016

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