PDA

View Full Version : Little help on textdraws.


LazzyBoy
26/03/2017, 10:10 PM
okay so basicly what i was doing is trying to show all players name that are in table to a textdraw but it seems to be mixed up or it shows only one name anyway heres my code


for(new i, j=GetPlayerPoolSize(); i<=j; i++)
{
if(GetPVarInt(i,"ontable") == GetPVarInt(playerid,"ontable"))
{
new string[50];
format(string,sizeof(string),"%s",RoleName(i));
TextDrawSetString(Textdraw0[i],string);
TextDrawShowForPlayer(i,Textdraw0[i]);
}
}


RoleName


stock RoleName(playerid)
{
new string[24];
GetPlayerName(playerid,string,24);
new str[24];
strmid(str,string,0,strlen(string),24);
for(new i = 0; i < MAX_PLAYER_NAME; i++)
{
if (str[i] == '_') str[i] = ' ';
}
return str;
}

Nero_3D
26/03/2017, 11:21 PM
You never concatenate the strings, so only one name will be shown


new string[512];

for(new i, j=GetPlayerPoolSize(); i<=j; i++)
{
if(GetPVarInt(i,"ontable") == GetPVarInt(playerid,"ontable"))
{
strcat(string, "\n");
strcat(string, RoleName(i));
}
}
TextDrawSetString(Textdraw0[playerid], string);
TextDrawShowForPlayer(playerid, Textdraw0[playerid]);

You should switch to playertextdraws because the limit for global textdraws is 2048