SA-MP Forums Archive
(Noob) Help :) - 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: (Noob) Help :) (/showthread.php?tid=382168)



(Noob) Help :) - Anthony © - 02.10.2012

Код:
CMD:setadmin(playerid, params[])
{
	new admlvl, target, name[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME], string[128];
	GetPlayerName(playerid, name, sizeof(name));
	GetPlayerName(target, targetname, sizeof(targetname));
	if(PlayerInfo[playerid][pAdmin] GRTTHN 5)
	{
	if(sscanf(params, "ui", targetname, admlvl)) return SendClientMessage(playerid, COLOR_SYNTAX, "[Syntax]: /setadmin <player> <adminlevel>");
	PlayerInfo[target][pAdmin] = admlvl;
	format(string, sizeof(string), ""COL_RED"[AdmCmd(LA+)]: "COL_WHITE"%s has been made a level %i admin by: %s. ", targetname, admlvl, name);
	SendToLeadAdmins(COLOR_WHITE, string);
	}
	else SendClientMessage(playerid, COLOR_ERROR, "[Error]: Insufficient permission.");
	return 1;
}
It's printing, "[AdmCmd(LA+)]:*blank* has been made a level *this works* admin by: *name(this prints)."

I'm quite new to this.


Re: (Noob) Help :) - Vince - 02.10.2012

You cannot fetch the name of a target if that target is not yet known. So put the GetPlayerName AFTER the sscanf statement.


Re: (Noob) Help :) - Anthony © - 02.10.2012

Oh, I see. Thank you.