Argument Type Mismatch (argument 1)
#1

Код:
***************************MAKEADMIN.pwn(175) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
I keep getting the argument typed mismatch and I cannot figure out how to fix it. Any assistance would be appreciated.


The code is quite messy, as this is one of my first commands I have made, so sorry for the messiness.


Код:
CMD:makeadmin(playerid, params[])
{
	new id, level;
	if(IsPlayerAdmin(playerid))
	{
	    if (sscanf(params, "ud", id, level)) return SendClientMessage(playerid, -1, "Syntax: /makeadmin [id] [level]");
		else
		{
		    new INI:File = INI_Open(UserPath(id));
		    INI_WriteInt(File, "Admin", level);
		    INI_Close(File);
		    SendClientMessage(playerid, -1, "Staff level has been set!");
		    new targetid[MAX_PLAYER_NAME+1];GetPlayerName(id, targetid, sizeof(targetid));
		    new promoter[MAX_PLAYER_NAME+1];GetPlayerName(playerid, promoter, sizeof(promoter));
		    new string[24+MAX_PLAYER_NAME+1];
		    new sTring[24+MAX_PLAYER_NAME+1];
		    new promoted[MAX_PLAYER_NAME+1];GetPlayerName(id, promoted, sizeof(promoted));
			format(string, sizeof(string), "AdmCmd: %s has made %s admin level %d", promoter, targetid, level);
	  		SendClientMessageToAll(0xAA3333AA, string);
			format(promoted, sizeof(promoted), "You have been promoted to admin level %d by %s!", level, promoter);
			SendClientMessage(promoted, 0x00CED1, sTring);
		}
  	}
	else return SendClientMessage(playerid, -1, "You are not a Staff Member!");
	return 1;
}
Reply
#2

What line exactly is line 175?
Reply
#3

pawn Код:
COMMAND:makeadmin(playerid, params[])
{
if(IsPlayerAdmin(playerid))//put what admin level ur gonna be allowed to use this!
{
new targetid,integ;//or u can use Params[]
if(sscanf(params,"ui", targetid,integ)) return SendClientMessage(playerid,COLOR_0xFFFFFFAA,"Usage: /Makeadmin [playerid] [AdminLevel]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,COLOR_WHITE,"Invalide Player ID"RED"(Player Is Not Connected)!");
new file[128],string[128];
new name[MAX_PLAYER_NAME];GetPlayerName(targetid, name, sizeof(name));
format(file,sizeof(file),"/LOcATION OF FILE/%s.ini",name);//make sure to hcange that !
new INI:Acc= INI_Open(file);
    {
        INI_WriteInt(Acc,"PlayerAdmin",PlayerInfo[targetid][PlayerAdmin] = integ);//use what ever u got for the admin level to save
        INI_Close(Acc);
    }
new player[MAX_PLAYER_NAME];GetPlayerName(playerid, player, sizeof(player));
format(string, sizeof(string), ""GREEN"You Have Given "BLUE"\"%s\""GREEN" level "YELLOW"%d"GREEN" Admin.", name, integ);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
return 1;
}
Reply
#4

I think MatriX is wrong. IsPlayerAdmin checks if the player id is a rcon admin, also known as if the player is logged into rcon. And it only checks for one parameter, the id of a player in this case the player typing /makeadmin, not any admin level. He maybe wanted /makeadmin to be only for rcon.

https://sampwiki.blast.hk/wiki/IsPlayerAdmin

Anyways, what line is 175?
Reply
#5

Код:
SendClientMessage(promoted, 0x00CED1, sTring);
That would be line 175
Reply
#6

I guess its because of your color code is wrong, use this color code 0x00CED1FF
Reply
#7

pawn Код:
CMD:makeadmin(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You are not a Staff Member!");

    new id, level;
    if (sscanf(params, "ud", id, level)) return SendClientMessage(playerid, -1, "Syntax: /makeadmin [id] [level]");
    if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Invalid player");
   
    new INI:File = INI_Open(UserPath(id));
    INI_WriteInt(File, "Admin", level);
    INI_Close(File);
   
    SendClientMessage(playerid, -1, "Staff level has been set!");
   
    new targetid[MAX_PLAYER_NAME], promoter[MAX_PLAYER_NAME], string[84];
    GetPlayerName(id, targetid, sizeof(targetid));
    GetPlayerName(playerid, promoter, sizeof(promoter));
   
    format(string, sizeof(string), "AdmCmd: %s has made %s admin level %d", promoter, targetid, level);
    SendClientMessageToAll(0xAA3333AA, string);
    format(string, sizeof(string), "You have been promoted to admin level %d by %s!", level, promoter);
    SendClientMessage(id, 0x00CED1, string);
    return 1;
}
Reply
#8

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
I think MatriX is wrong. IsPlayerAdmin checks if the player id is a rcon admin, also known as if the player is logged into rcon. And it only checks for one parameter, the id of a player in this case the player typing /makeadmin, not any admin level. He maybe wanted /makeadmin to be only for rcon.

https://sampwiki.blast.hk/wiki/IsPlayerAdmin

Anyways, what line is 175?
Yup, i wanted to make it only that RCON admins can give admins.
Reply
#9

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
CMD:makeadmin(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You are not a Staff Member!");

    new id, level;
    if (sscanf(params, "ud", id, level)) return SendClientMessage(playerid, -1, "Syntax: /makeadmin [id] [level]");
    if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Invalid player");
   
    new INI:File = INI_Open(UserPath(id));
    INI_WriteInt(File, "Admin", level);
    INI_Close(File);
   
    SendClientMessage(playerid, -1, "Staff level has been set!");
   
    new targetid[MAX_PLAYER_NAME], promoter[MAX_PLAYER_NAME], string[84];
    GetPlayerName(id, targetid, sizeof(targetid));
    GetPlayerName(playerid, promoter, sizeof(promoter));
   
    format(string, sizeof(string), "AdmCmd: %s has made %s admin level %d", promoter, targetid, level);
    SendClientMessageToAll(0xAA3333AA, string);
    format(string, sizeof(string), "You have been promoted to admin level %d by %s!", level, promoter);
    SendClientMessage(id, 0x00CED1, string);
    return 1;
}
Wow! Thanks! I'll try that out in a second, but I hope you could answer another question. On new you have string[84]

What is the number at the end of string mean, what number should I use when, and when should I use it at all?

Thanks in advance
Reply
#10

https://sampwiki.blast.hk/wiki/Scripting_Basics#Strings

It's the size of the string. It can get 83 characters and a NULL termination character. Those two messages will never go over 84 characters so there's not reason to make it bigger.

I'll show you an example:

String: "AdmCmd: %s has made %s admin level %d"

Characters in that string so far: "AdmCmd: has made admin level " -> 31 characters + NULL = 32 (size).

We have 2 names to be displayed (MAX_PLAYER_NAME = 24) so 32 (the above) + 48 = 80 (size).

The level left, so assuming the max lenght of it is 4 (max 1337 level) - the final size is 84! It's a good habbit to count the characters and optimize the code by not wasting pointless bytes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)