Setadminoff
#1

I've been trying to make a /setadminoff command, basically setting the admin level to a player which is offline.
I have come here so far:
Код:
CMD:setadminoff(playerid, params[])
{
	new target[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME], string[128];
	new para1, level;
	
	if(Player[playerid][pAdmin] < 1338) return SCM(pid, ADMIN_COLOR, ADMIN_MESSAGE);
	
	if(sscanf(params, "ud", para1, level))
	{
		SCM(pid, COLOR_WHITE, "{00E6FF}USAGE:{FFFFFF} /setadminoff [EXACT PLAYER NAME] [LEVEL]");
		return 1;
	}
	
	GetPlayerName(playerid, sendername, sizeof(sendername));
	GetPlayerName(para1, target, sizeof(target));
	
	
	Player[playerid][pAdmin] = level;
	INI_ParseFile(UserPath(para1), "LoadUser_%s", .bExtra = true, .extra = para1);
	INI_Int("Admin", Player[playerid][pAdmin]);
	INI_WriteInt(File, "Admin", Player[playerid][pAdmin]);
	INI_Close(File);
	format(string, sizeof(string), "{D11515}[AdmWarning]: {FF9203}%s {FFFFFF}has set {FF9203}%s's {FFFFFF}account to a level{FF9203}%d {FFFFFF}admin.", target, sendername, level);
	SendAdminMessage(-1, string);
	return 1;
}
The errors that it gives me are:
Код:
GM.pwn(900) : error 017: undefined symbol "name"
GM.pwn(900) : error 017: undefined symbol "value"
GM.pwn(901) : error 017: undefined symbol "File"
GM.pwn(902) : error 017: undefined symbol "File"
I don't know if this will work even if it compiles, I feel that it is incomplete.
Reply
#2

That makes absolutely no sense.
I'll start off with something that doesn't fix the problem:
Why do you create your arrays before checking if the player did something wrong? (Not an admin, wrong syntax etc..)
It's a waste of memory if they don't get used.

Now fixing the problem:
The "u" specifier in sscanf is for playerids or names that are online.

How are you using GetPlayerName(para1..) if the player is supposed to be offline?

You're setting the the player that wrote the command's admin level.. why?
Код:
Player[playerid][pAdmin] = level;
Why are you parsing the file if you want to just edit it? You're not reading anything.

Код:
INI_WriteInt(File, "Admin", Player[playerid][pAdmin]);
You're writing the player that entered the command's admin level, and not the new level.
Reply
#3

I have edited it like this so far:
Код:
if(sscanf(params, "si", level))
	{
		SCM(pid, COLOR_WHITE, "{00E6FF}USAGE:{FFFFFF} /setadminoff [EXACT PLAYER NAME] [LEVEL]");
		return 1;
	}
	
	GetPlayerName(playerid, sendername, sizeof(sendername));

	INI_Int("Admin", Player[para1][pAdmin]);  
	INI_WriteInt(File, "Admin", Player[para1][pAdmin]);
	INI_Close(File);
	format(string, sizeof(string), "{D11515}[AdmWarning]: {FF9203}%s {FFFFFF}has set {FF9203}%s's {FFFFFF}account to a level{FF9203}%i {FFFFFF}admin.", sendername, string, level);
	SendAdminMessage(-1, string);
	return 1;
}
I don't know what else to do. What would I put in he arrays apart from para1 or playerid?
Reply
#4

Код:
CMD:setadminoff(playerid, params[])
{
	if(Player[playerid][pAdmin] < 1338) return SCM(pid, ADMIN_COLOR, ADMIN_MESSAGE);
	
	new tName[24], level;
	if(sscanf(params, "s[24]i", tName, level)) return SCM(pid, COLOR_WHITE, "{00E6FF}USAGE:{FFFFFF} /setadminoff [EXACT PLAYER NAME] [LEVEL]");
	
	new string[140];
	format(string, sizeof (string), "YOUR USER FILE HERE", tName);
	if (!fexist(string)) return SCM(playerid, 0xFF0000FF, "Invalid player name.");
	
	new INI: File = INI_Open(string);
	INI_WriteInt(File, "Admin", level);
	INI_Close(File);
	
	GetPlayerName(playerid, string, 24);
	format(string, sizeof(string), "{D11515}[AdmWarning]: {FF9203}%s {FFFFFF}has set {FF9203}%s's {FFFFFF}account to a level{FF9203}%d {FFFFFF}admin.", string, tName, level);
	SendAdminMessage(-1, string);
	return 1;
}
Reply
#5

I appreciate your effort and your tips.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)