Problem with sscanf
#1

Hello guys, so I was making an admin command, but the compiler always gives me this error
Quote:

C:\Users\Oussama\Desktop\test serv - Copy\gamemodes\test.pwn(76) : error 035: argument type mismatch (argument 1)
This is my code
Код:
CMD:setlevel(playerid, params) {
	if(IsPlayerAdmin(playerid))
	{
	    new
			string[36],
			pname[MAX_PLAYER_NAME],
			tname[MAX_PLAYER_NAME];
		new id, level;
	    if(sscanf(params, "u", id, level)) return SendClientMessage(playerid, -1, "USAGE: /makeadmin (playerid) (level)");
		if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000, "[ERROR]: This player is not connected!");
		if(level < 1 || level > 3) return SendClientMessage(playerid, 0xFF0000, "Available levels (1-4)");
		GetPlayerName(playerid, pname, sizeof(pname));
	    GetPlayerName(id, tname, sizeof(tname));
		format(string, sizeof(string), "Administrator %s has promoted %s to level %i admin", pname, tname, level);
	    SendClientMessageToAll(-1, string);
		PlayerInfo[id][AdminLevel] = level;
		new INI:File = INI_Open(AdminPath(id));
		INI_SetTag(File, "AdminData");
		INI_WriteInt(File, "AdminLevel", PlayerInfo[id][AdminLevel]);
		INI_Close(File);
		return 1;
	}
	else {
		SendClientMessage(playerid, 0xFF00008, "[ERROR]: you are not authorized to use this command");
		return 1;
	}
}

the line in GREEN is the problem
Reply
#2

Код:
CMD:setlevel(playerid, params[])
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Код:
CMD:setlevel(playerid, params[])
OMG, how come didn't I see that,
mate thank you so much
Reply
#4

There is another problem which happens to me so often,
now the compiler scans the script just fine with no errors, but when I log in game to try these commands, they don't function as they should,
the server loads only ( if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, 0xFF0000, " USAGE: /setlevel (playerid) (level)); ) and every line below this doesn't execute, so no matter I did (whether I typed the command + all the params or not) It gives me the same USAGE message
Reply
#5

Looking again at your first post, you have 1 specifier ("u") and 2 arguments (id, level). In the above post, it is fixed but just make sure the number of specifiers is always equal to the number of arguments (excluding quite specifiers).
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Looking again at your first post, you have 1 specifier ("u") and 2 arguments (id, level). In the above post, it is fixed but just make sure the number of specifiers is always equal to the number of arguments (excluding quite specifiers).
thanks for the tip;
I just need a solution for the 2nd problem I stated above
Reply
#7

Even if I do ( /setlevel 5 2 ) to set's the player with the id 5 to level 2 It gives me the Client Message that's assigned to if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, 0xFF0000, "USAGE: /setlevel (playerid)(level)"); )
Reply
#8

Nvm Problem solved! Thanks everybody
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)