PDA

View Full Version : String problem


Mijata
01/07/2017, 12:29 AM
Why i can't see full player name who type command

new string[128], name[75];
GetPlayerName(playerid, name, 75);
format(string,sizeof(string),"{B5B5B5}%s(%d): has used command %s",name[playerid],playerid,cmdtext);
for(new i=0;i<MAX_PLAYERS;i++)
{
if(pInfo[i][pLevel] > 1)
SendClientMessage(i,-1,string);
}
return 1;
}

oMa37
01/07/2017, 12:33 AM
MAX_PLAYER_NAME = 24.
You're defining the player's name size as 75, Make it 24 and to show it just use 'name', without '[playerid]'.

Eoussama
01/07/2017, 12:36 AM
Why are you using a 75 long string? Player names are not longer than 24 characters, so you should just use name[24] or name[MAX_PLAYER_NAME] MAX_PLAYER_NAME = 24 by default

format(string,sizeof(string),"{B5B5B5}%s(%d): has used command %s",name[playerid],playerid,cmdtext);

you declared the variable as name[75] and you use name[playerid]? It doesn't make any sense,
use this instead

format(string,sizeof(string),"{B5B5B5}%s(%d): has used command %s",name,playerid,cmdtext);


EDIT: sorry oMa37, didn't refresh the page