Whats wrong with this command?
#1

I cant see whats is messing this code. Can someone give me a hand here please?

Command:
pawn Код:
CMD:jail(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 4)
{
new targetid, minutes; //define the player's name and the minutes of jailing
if(sscanf(params, "ri", targetid, minutes)) return SendClientMessage(playerid, -1,"Usage: /jail <playerid> <minutes>"); //detects the wrong params and show the usage
if(minutes <= 0 || minutes > 60) return SendClientMessage(playerid, -1, "Minutes can't be less than 0 or more than 60!"); //we won't let a player suffer more than 1 hour, and not less than 1 minute
if(targetid == playerid) return SendClientMessage(playerid, -1, "You can't jail yourself!"); //comment this line out, if you wanna test this command on yourself!
else
{

new str; //create a new string
format(str, sizeof(str), "Administrator %s has jailed %s for %d minutes!", Name(playerid), Name(targetid), minutes); //get the admin's name, the player's and show the minutes
SendClientMessageToAll(-1,str); //let everybody know what you did, this will send the message to everyone
JailTimer[targetid] = SetTimer("Unjail", minutes*60*1000, false); //now HERE we're setting the jailtimer from the variable created, it will calculate the milliseconds to seconds, multiplicated with the amount of minutes we gave
SetPlayerPos(targetid, 264.4176, 77.8930, 1001.0391); //Sets the player's position to the jail in LS
SetPlayerInterior(targetid, 6); //this will set the player's interior to an jail-interior
inJail[targetid] = true; //now, here we'll check, if the player's in jail, we'll set the value to "true", means that he IS in jail
GameTextForPlayer(targetid, "~p~JAILED", 10000, 6); //this is for decorating and writing a big "JAILED" for the player
PlayerPlaySound(targetid,1057,0.0,0.0,0.0); //that's also a small sound, for decoration
}
}
else return SendClientMessage(playerid, -1, "You have to be level 4 to use this command!"); //if he isn't allowed to use this command, send him this message
return 1;
}
Errors:
Код:
.pwn(1925) : error 035: argument type mismatch (argument 1)
.pwn(1925) : error 035: argument type mismatch (argument 1)
.pwn(1925) : warning 215: expression has no effect
.pwn(1925) : error 001: expected token: ";", but found ")"
.pwn(1925) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 Copyright © 1997-2006, ITB CompuPhase

4 Errors.
Error Line:
Код:
format(str, sizeof(str), "Administrator %s has jailed %s for %d minutes!", Name(playerid), Name(targetid), minutes); //get the admin's name, the player's and show the minutes
*I didn't make this.
Reply
#2

Change:
pawn Код:
new str;
to:
pawn Код:
new str[91];
It must be a string, not an integer.
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Change:
pawn Код:
new str;
to:
pawn Код:
new str[91];
It must be a string, not an integer.
Nop. Still getting the same errors.
Reply
#4

Quote:
Originally Posted by iDuckling
Посмотреть сообщение
Nop. Still getting the same errors.
That's the solution. You must create an array to store a text in it.

It also gave the error "argument type mismatch (argument 1)" because the first parameter of format is an array and not an integer that you used.
Reply
#5

Konstantinos is right,
pawn Код:
new str[144]; // 144 is the highest amount of characters that can be viewed for SendClientMessage
.
Reply
#6

Quote:
Originally Posted by iDuckling
Посмотреть сообщение
I cant see whats is messing this code. Can someone give me a hand here please?

Command:
pawn Код:
CMD:jail(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 4)
{
new targetid, minutes; //define the player's name and the minutes of jailing
if(sscanf(params, "ri", targetid, minutes)) return SendClientMessage(playerid, -1,"Usage: /jail <playerid> <minutes>"); //detects the wrong params and show the usage
if(minutes <= 0 || minutes > 60) return SendClientMessage(playerid, -1, "Minutes can't be less than 0 or more than 60!"); //we won't let a player suffer more than 1 hour, and not less than 1 minute
if(targetid == playerid) return SendClientMessage(playerid, -1, "You can't jail yourself!"); //comment this line out, if you wanna test this command on yourself!
else
{

new str; //create a new string
format(str, sizeof(str), "Administrator %s has jailed %s for %d minutes!", Name(playerid), Name(targetid), minutes); //get the admin's name, the player's and show the minutes
SendClientMessageToAll(-1,str); //let everybody know what you did, this will send the message to everyone
JailTimer[targetid] = SetTimer("Unjail", minutes*60*1000, false); //now HERE we're setting the jailtimer from the variable created, it will calculate the milliseconds to seconds, multiplicated with the amount of minutes we gave
SetPlayerPos(targetid, 264.4176, 77.8930, 1001.0391); //Sets the player's position to the jail in LS
SetPlayerInterior(targetid, 6); //this will set the player's interior to an jail-interior
inJail[targetid] = true; //now, here we'll check, if the player's in jail, we'll set the value to "true", means that he IS in jail
GameTextForPlayer(targetid, "~p~JAILED", 10000, 6); //this is for decorating and writing a big "JAILED" for the player
PlayerPlaySound(targetid,1057,0.0,0.0,0.0); //that's also a small sound, for decoration
}
}
else return SendClientMessage(playerid, -1, "You have to be level 4 to use this command!"); //if he isn't allowed to use this command, send him this message
return 1;
}
Errors:
Код:
.pwn(1925) : error 035: argument type mismatch (argument 1)
.pwn(1925) : error 035: argument type mismatch (argument 1)
.pwn(1925) : warning 215: expression has no effect
.pwn(1925) : error 001: expected token: ";", but found ")"
.pwn(1925) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 Copyright © 1997-2006, ITB CompuPhase

4 Errors.
Error Line:
Код:
format(str, sizeof(str), "Administrator %s has jailed %s for %d minutes!", Name(playerid), Name(targetid), minutes); //get the admin's name, the player's and show the minutes
*I didn't make this.
Use this, i got it from a script i use, but not made by me ofc

Код:
CMD:jail(playerid,params[]) {
	if(PlayerInfo[playerid][LoggedIn] == 1) {
		if(PlayerInfo[playerid][Level] >= 4) {
		    new tmp[256], tmp2[256], tmp3[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index), tmp3 = strtok(params,Index);
		    if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /jail [playerid] [minutes] [reason]");
	    	new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
			player1 = strval(tmp);

		 	if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && (PlayerInfo[player1][Level] != ServerInfo[MaxAdminLevel]) ) {
				if(PlayerInfo[player1][Jailed] == 0) {
					GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
					new jtime = strval(tmp2);
					if(jtime == 0) jtime = 9999;

			       	CMDMessageToAdmins(playerid,"JAIL");
					PlayerInfo[player1][JailTime] = jtime*1000*60;
    			    JailPlayer(player1);
    			    Jail1(player1);
		        	PlayerInfo[player1][Jailed] = 1;

					if(jtime == 9999) {
						if(!strlen(params[strlen(tmp2)+1])) format(string,sizeof(string),"Administrator %s has jailed %s ",adminname, playername);
						else format(string,sizeof(string),"[JAIL] Administrator %s sent %s to jail. Reason: %s",adminname, playername, params[strlen(tmp)+1] );
   					} else {
						if(!strlen(tmp3)) format(string,sizeof(string),"[JAIL] Administrator %s sent %s to jail for %d minutes",adminname, playername, jtime);
						else format(string,sizeof(string),"[JAIL] Administrator %s sent %s to jail for %d minutes. Reason: %s",adminname, playername, jtime, params[strlen(tmp2)+strlen(tmp)+1] );
					}
	    			return SendClientMessageToAll(0xFF00FFFF,string);
				} else return SendClientMessage(playerid, red, "Player is already in jail");
			} else return SendClientMessage(playerid, red, "Player is not connected or is the highest level admin");
		} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
	} else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
Reply
#7

Quote:
Originally Posted by Ralfie
Посмотреть сообщение
Use this, i got it from a script i use, but not made by me ofc
I wouldn't recommend it.. he uses ZCMD and sscanf which is a great combination so why would someone want to downdate?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)