GetPlayerName error
#1

Код:
new pname[MAX_PLAYER_NAME];
CMD:credits(playerid, params[])
{
	ShowPlayerDialog(playerid, creditdialog, DIALOG_STYLE_MSGBOX, "Credits", ""cgreen">"cred"Elvis"cblue" server main scripter\n"cgreen">"cred"RaiN_HawK"cblue" server founder", "Ok", "");
	SendAdminCMD(playerid, "credits");
	return 1;
}

stock SendAdminCMD(playerid, command[])
{
	for(new i = 0; i <= MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i) && pdata[i][admin] > 0)
		format(String, sizeof(String), "%s has used command %s", GetPlayerName(playerid, pname, sizeof(pname)), command);
		SendClientMessage(i, blue, String);
	}
}
Can anyone tell what is error in this it shows only has used command credits and it happens everywhere except in dialog register and login
Reply
#2

You store the name in a variable and use the variable to print it.

pawn Код:
new
    pname[ MAX_PLAYER_NAME ]
;
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);

// blablabla..

format(String, sizeof(String), "%s has used command %s", pname, command);
SendClientMessage(i, blue, String);
Reply
#3

Woow konstantinous thank u it worked but can you tell me why was it not working as i have done
Reply
#4

What you did returns the length of the player's name - you can only store the name somewhere and then use it.
Reply
#5

Ok i got it this cause my whole script to be bugged now i will be warned about it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)