jail bug
#1

Hello lads,


I have been experiencing an annoying problem with my jail command which i scripted by my self !

Okay, so after i jail my self i can't un jail my self or even before i jail someone. it says I don't have the privilege to use this command


But if i jail someone i can't jail anyone else after i already jailed my self even if i don't type any id or reason it says "The player is already jailed"

fixed.
Reply
#2

Hello!

You have the false order of the if-clause.

PHP код:
CMD:jail(playeridparams[])
{
      if(
pInfo[playerid][AdminLevel] < 1) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command.");
      {
           new 
idstring[128],reason[100], admin[24], name[24];
           if(
pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM[: {FFFFFF}You have to login before you can use commands !");
           if(
sscanf(params"ds[64]",idreason)) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM ERROR]: {FFFFFF}USAGE: /jail [id] [reason]");
           if(!
IsPlayerConnected(id)) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM ERROR]: The ID you have inputted is incorrect");
           if(
Jailed[id] == 1) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM]: The player is already jailed");
           
SetPlayerInterior(id7);
           
SetPlayerPos(id288.74350, -134.531221003.05688);
           
SetPlayerVirtualWorld(id10);
           
SetPlayerHealth(id9999999);
           
ResetPlayerWeapons(id);
           
GetPlayerName(playeridadmin,sizeof(admin));
           
GetPlayerName(idnamesizeof(name) ) ;
           
format(stringsizeof string"{FF0000}[SYSTEM]: %s has been jailed by %s | Reason: {FFFF00}%s"nameadminreason);
           
SendClientMessageToAll(-1string);
           
Jailed[id] = 1;
     }
     return 
1;
}
///////////
CMD:unjail(playeridparams[])
{
    if(
pInfo[playerid][AdminLevel] < 1) return SendClientMessage(playerid, -1,"{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command.");
    {
           new 
idstring[128],admin[24], name[24];
           if(
pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM[: {FFFFFF}You have to login before you can use commands !");
           if(
pInfo[playerid][AdminLevel] >= 1) return SendClientMessage(playerid, -1,"{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command.");
           if(
sscanf(params"d",id)) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM ERROR]: {FFFFFF}USAGE: /unjail [id]");
           if(!
IsPlayerConnected(id)) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM ERROR]: The ID you have inputted is incorrect");
           if(
Jailed[id] != 0) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM]: The player is not jailed");
           
SetPlayerVirtualWorld(id0);
           
SetPlayerInterior(id0);
           
SetPlayerHealth(id100);
           
GivePlayerMoney(id, -800);
           
GivePlayerWeapon(id24,60);
           
SpawnPlayer(id);
           
GetPlayerName(playeridadmin,sizeof(admin));
           
GetPlayerName(idnamesizeof(name) ) ;
           
format(stringsizeof string"{FF0000}[SYSTEM]: {FFFFFF}%s has been released from jail by %s",nameadmin);
           
SendClientMessageToAll(-1string);
           
Jailed[id] = 0;
    }
    return 
1;

Try this.


- Mencent
Reply
#3

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Hello!

You have the false order of the if-clause.

PHP код:
CMD:jail(playeridparams[])
{
      if(
pInfo[playerid][AdminLevel] < 1) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command.");
      {
           new 
idstring[128],reason[100], admin[24], name[24];
           if(
pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM[: {FFFFFF}You have to login before you can use commands !");
           if(
sscanf(params"ds[64]",idreason)) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM ERROR]: {FFFFFF}USAGE: /jail [id] [reason]");
           if(!
IsPlayerConnected(id)) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM ERROR]: The ID you have inputted is incorrect");
           if(
Jailed[id] == 1) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM]: The player is already jailed");
           
SetPlayerInterior(id7);
           
SetPlayerPos(id288.74350, -134.531221003.05688);
           
SetPlayerVirtualWorld(id10);
           
SetPlayerHealth(id9999999);
           
ResetPlayerWeapons(id);
           
GetPlayerName(playeridadmin,sizeof(admin));
           
GetPlayerName(idnamesizeof(name) ) ;
           
format(stringsizeof string"{FF0000}[SYSTEM]: %s has been jailed by %s | Reason: {FFFF00}%s"nameadminreason);
           
SendClientMessageToAll(-1string);
           
Jailed[id] = 1;
     }
     return 
1;
}
///////////
CMD:unjail(playeridparams[])
{
    if(
pInfo[playerid][AdminLevel] < 1) return SendClientMessage(playerid, -1,"{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command.");
    {
           new 
idstring[128],admin[24], name[24];
           if(
pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM[: {FFFFFF}You have to login before you can use commands !");
           if(
pInfo[playerid][AdminLevel] >= 1) return SendClientMessage(playerid, -1,"{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command.");
           if(
sscanf(params"d",id)) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM ERROR]: {FFFFFF}USAGE: /unjail [id]");
           if(!
IsPlayerConnected(id)) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM ERROR]: The ID you have inputted is incorrect");
           if(
Jailed[id] != 0) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM]: The player is not jailed");
           
SetPlayerVirtualWorld(id0);
           
SetPlayerInterior(id0);
           
SetPlayerHealth(id100);
           
GivePlayerMoney(id, -800);
           
GivePlayerWeapon(id24,60);
           
SpawnPlayer(id);
           
GetPlayerName(playeridadmin,sizeof(admin));
           
GetPlayerName(idnamesizeof(name) ) ;
           
format(stringsizeof string"{FF0000}[SYSTEM]: {FFFFFF}%s has been released from jail by %s",nameadmin);
           
SendClientMessageToAll(-1string);
           
Jailed[id] = 0;
    }
    return 
1;

Try this.


- Mencent
I still don't have the privilege to use unjail command, by the way what did u changed?
Reply
#4

Код:
  if(pInfo[playerid][AdminLevel] == 0) return SendClientMessage(playerid, -1,"{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command.");
That should sort your problem. You were restricting anyone Admin Level 1 or higher from using the command, used the wrong sign.
Reply
#5

I moved this:
PHP код:
if(Jailed[id] == 1) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM]: The player is already jailed"); 
after sscanf.


What is printing in the console here?
PHP код:
CMD:unjail(playeridparams[])
{
    
printf("Adminlevel: %i",pInfo[playerid][AdminLevel]);
    if(
pInfo[playerid][AdminLevel] < 1) return SendClientMessage(playerid, -1,"{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command.");
    {
           new 
idstring[128],admin[24], name[24];
           if(
pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM[: {FFFFFF}You have to login before you can use commands !");
           if(
pInfo[playerid][AdminLevel] >= 1) return SendClientMessage(playerid, -1,"{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command.");
           if(
sscanf(params"d",id)) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM ERROR]: {FFFFFF}USAGE: /unjail [id]");
           if(!
IsPlayerConnected(id)) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM ERROR]: The ID you have inputted is incorrect");
           if(
Jailed[id] != 0) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM]: The player is not jailed");
           
SetPlayerVirtualWorld(id0);
           
SetPlayerInterior(id0);
           
SetPlayerHealth(id100);
           
GivePlayerMoney(id, -800);
           
GivePlayerWeapon(id24,60);
           
SpawnPlayer(id);
           
GetPlayerName(playeridadmin,sizeof(admin));
           
GetPlayerName(idnamesizeof(name) ) ;
           
format(stringsizeof string"{FF0000}[SYSTEM]: {FFFFFF}%s has been released from jail by %s",nameadmin);
           
SendClientMessageToAll(-1string);
           
Jailed[id] = 0;
    }
    return 
1;

- Mencent
Reply
#6

This no nonsense,
pawn Код:
if(pInfo[playerid][AdminLevel] < 1) return SendClientMessage(playerid, -1, "{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command.");
      {
should be
pawn Код:
if(pInfo[playerid][AdminLevel] > 1)
{

}
else return SendClientMessage(playerid, -1, "{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command.");
or as Vlad showed you
Reply
#7

Try this
Код:
CMD:unjail(playerid, params[]) 
{ 
    if(pInfo[playerid][AdminLevel] < 1) return SendClientMessage(playerid, -1,"{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command."); 
else 
   { 
           new id, string[128],admin[24], name[24]; 
           if(pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, -1, "{FF0000}[SYSTEM[: {FFFFFF}You have to login before you can use commands !"); 
           if(pInfo[playerid][AdminLevel] >= 1) return SendClientMessage(playerid, -1,"{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command."); 
           if(sscanf(params, "d",id)) return SendClientMessage(playerid, -1, "{FF0000}[SYSTEM ERROR]: {FFFFFF}USAGE: /unjail [id]"); 
           if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "{FF0000}[SYSTEM ERROR]: The ID you have inputted is incorrect"); 
           if(Jailed[id] == 0) return SendClientMessage(playerid, -1, "{FF0000}[SYSTEM]: The player is not jailed"); 
           else if(Jailed[id] == 1)
{
           SetPlayerVirtualWorld(id, 0); 
           SetPlayerInterior(id, 0); 
           SetPlayerHealth(id, 100); 
           GivePlayerMoney(id, -800); 
           GivePlayerWeapon(id, 24,60); 
           SpawnPlayer(id); 

           GetPlayerName(playerid, admin,sizeof(admin)); 
           GetPlayerName(id, name, sizeof(name) ) ; 
           format(string, sizeof string, "{FF0000}[SYSTEM]: {FFFFFF}%s has been released from jail by %s",name, admin); 
           SendClientMessageToAll(-1, string); 
           Jailed[id] = 0; 
 }
    } 
    return 1; 
}
Reply
#8

Quote:
Originally Posted by Mencent
Посмотреть сообщение
I moved this:
PHP код:
if(Jailed[id] == 1) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM]: The player is already jailed"); 
after sscanf.


What is printing in the console here?
PHP код:
CMD:unjail(playeridparams[])
{
    
printf("Adminlevel: %i",pInfo[playerid][AdminLevel]);
    if(
pInfo[playerid][AdminLevel] < 1) return SendClientMessage(playerid, -1,"{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command.");
    {
           new 
idstring[128],admin[24], name[24];
           if(
pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM[: {FFFFFF}You have to login before you can use commands !");
           if(
pInfo[playerid][AdminLevel] >= 1) return SendClientMessage(playerid, -1,"{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command.");
           if(
sscanf(params"d",id)) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM ERROR]: {FFFFFF}USAGE: /unjail [id]");
           if(!
IsPlayerConnected(id)) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM ERROR]: The ID you have inputted is incorrect");
           if(
Jailed[id] != 0) return SendClientMessage(playerid, -1"{FF0000}[SYSTEM]: The player is not jailed");
           
SetPlayerVirtualWorld(id0);
           
SetPlayerInterior(id0);
           
SetPlayerHealth(id100);
           
GivePlayerMoney(id, -800);
           
GivePlayerWeapon(id24,60);
           
SpawnPlayer(id);
           
GetPlayerName(playeridadmin,sizeof(admin));
           
GetPlayerName(idnamesizeof(name) ) ;
           
format(stringsizeof string"{FF0000}[SYSTEM]: {FFFFFF}%s has been released from jail by %s",nameadmin);
           
SendClientMessageToAll(-1string);
           
Jailed[id] = 0;
    }
    return 
1;

- Mencent
still can't unjail
Reply
#9

Yes, but what printing in the console (server.log)?


- Mencent
Reply
#10

Alright guys, i fixed it i found the problem !


Thanks for trying to help !
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)