I need a setrank command
#1

Hey guys i need help about this if you could give me some help thanks!! I just wanna make a /setrank wich would set the rank of the player to the amount you want! It is for an zombie server!!! Thanks

Код:
CMD:setrank(playerid, params[])
{
 	if(pInfo[playerid][pLogged] == 1)
	{
		if(pInfo[playerid][pAdminLevel] >= 2)
		{
                        new INI:File = INI_Open(UserPath(playerid));
			INI_WriteInt(File,"pRank", "s%");
			return 1;
		}
	}
        else if(pInfo[playerid][pLogged] == 0)
	{
		SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" You are not logged in!");
		printf("%s has been kicked for trying to use a command without being logged in!", PlayerName(playerid));
		Kick(playerid);
	}

	return 1;
}
And im getting this error when i compile it
Код:
error 035: argument type mismatch (argument 3)
The error shows at the line : INI_WriteInt(File,"pRank", "s%");
Reply
#2

This is totally wrong .___. you didn't set any parameters dats why
a command:
pawn Код:
CMD:setrank(playerid, params[])
{
          new id, rank;
          if(pInfo[playerid][pAdminLevel] >= 2)
          {
               if(sscanf(params, "ui", id, rank)) return SendClientMessage(playerid, red, "ERROR: use /setrank [ID] [Rank]"      
               if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "Not connected or invalid id!");
               new INI:File = INI_Open(UserPath(playerid));
           INI_WriteInt(File,"pRank", rank); // rank is the paramter ( 1, 2, 3 ,etc integer) to set the value of "Prank" row
               pInfo[playerid][pRank]  = rank; // setting his rank
         }
         else return SendClientMessage(playerid, red, "ERROR: you should be level 2+!");
         return 1;
}
Correct usage of INI_WriteInt:
Код:
 INI_WriteInt(The file, the row to edit, value of editing row ( setting the row's value)
You can use sscanf
Reply
#3

Quote:
Originally Posted by Sawalha
Посмотреть сообщение
This is totally wrong .___. you didn't set any parameters dats why
a command:
pawn Код:
CMD:setrank(playerid, params[])
{
          new id, rank;
          if(pInfo[playerid][pAdminLevel] >= 2)
          {
               if(sscanf(params, "ui", id, rank)) return SendClientMessage(playerid, red, "ERROR: use /setrank [ID] [Rank]"      
               if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "Not connected or invalid id!");
               new INI:File = INI_Open(UserPath(playerid));
           INI_WriteInt(File,"pRank", rank); // rank is the paramter ( 1, 2, 3 ,etc integer) to set the value of "Prank" row
               pInfo[playerid][pRank]  = rank; // setting his rank
         }
         else return SendClientMessage(playerid, red, "ERROR: you should be level 2+!");
         return 1;
}
Correct usage of INI_WriteInt:
Код:
 INI_WriteInt(The file, the row to edit, value of editing row ( setting the row's value)
You can use sscanf
Dude i am getting this error
Код:
(3437 -- 3438) : error 001: expected token: ",", but found "if"
At the line:
Код:
if(sscanf(params, "ui", id, rank)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Use /setrank [ID] [Rank]"
               if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Not connected or invalid id!");
And this at the end of the command
Код:
(3449) : warning 209: function "cmd_setrank" should return a value
Reply
#4

Add ); to the SendClientMessage
Reply
#5

Quote:

CMDetrank(playerid, params[])
{
new id, rank;
if(pInfo[playerid][pAdminLevel] >= 2)
{
if(sscanf(params, "ui", id, rank)) return SendClientMessage(playerid, red, "ERROR: use /setrank [ID] [Rank]");
if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "Not connected or invalid id!");
new INI:File = INI_Open(UserPath(playerid));
INI_WriteInt(File,"pRank", rank); // rank is the paramter ( 1, 2, 3 ,etc integer) to set the value of "Prank" row
pInfo[playerid][pRank] = rank; // setting his rank
}
else return SendClientMessage(playerid, red, "ERROR: you should be level 2+!");
return 1;
}
Try it like this
Reply
#6

Also close the file.
INI_Close();
Reply
#7

Thanks guys it worked! BTW Stinged i don't really know where to attack INI_Close() please include it in the code up...
Reply
#8

Under INI_WriteInt
Reply
#9

Also, when using sscanf with the "u" specifier, never check if IsPlayerConnected - it's useless as sscanf already does the check internally, we only have to check if the ID returned is INVALID_PLAYER_ID, if it is, the player is disconnected.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)