#1

Hello lads,

I'm experiencing a problem with my jail command.

So basically i cannot see the name who jailed the person i cannot see the jailed person itself and i can't see the reason.

I got one more problem, i can jail myself twice? I tried to fix it but i couldn't

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[64],reason[100], admin;
           if(
sscanf(params"ds",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");
           
SetPlayerInterior(id18);
           
SetPlayerPos(id1710.433715,-1669.379272,20.225049);
           
SetPlayerVirtualWorld(id10);
           
SetPlayerHealth(id9999999);
           
ResetPlayerWeapons(id);
           
GetPlayerName(idreason,(admin));
           
format(stringsizeof string"{FF0000}[SYSTEM]: %s has been jailed by %s | Reason: %s"idreasonadmin);
           
SendClientMessageToAll(-1string);
    }
    return 
1;

Reply
#2

new admin[MAX_PLAYER_NAME];

GetPlayerName(playerid, admin, 24); this should work replace it with your current one.
Reply
#3

pawn Код:
CMD:jail(playerid, params[])
{
    if(pInfo[playerid][AdminLevel] >= 1) return SendClientMessage(playerid, -1,"{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command.");
    {
           new id, string[64],reason[100], admin[24], name[24];
           if(sscanf(params, "ds[64]",id, reason)) 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");

           SetPlayerInterior(id, 18);
           SetPlayerPos(id, 1710.433715,-1669.379272,20.225049);
           SetPlayerVirtualWorld(id, 10);
           SetPlayerHealth(id, 9999999);
           ResetPlayerWeapons(id);

           GetPlayerName(playerid, admin,sizeof(admin));
           GetPlayerName(id, name, sizeof(name) ) ;
           format(string, sizeof string, "{FF0000}[SYSTEM]: %s has been jailed by %s | Reason: %s", name, admin, reason);
           SendClientMessageToAll(-1, string);
    }
    return 1;
}
EDIT:
pawn Код:
stock GetPlayerNameEx(playerid)
{
     new pName[25];
     GetPlayerName(playerid, pName, sizeof(pName));
     return pName;
}
This function will help you to get the player name more easier later, just with the "player id", example:
pawn Код:
CMD:test( playerid )
{
    new
            str[ 64 ];
    format( str, sizeof( str ) , "Your name is %s", GetPlayerNameEx( playerid ) );
    return true;
}
Reply
#4

Thanks mate.

2 problems.

I can jail myself twice and the reason when i wrote Test it said Reas
Reply
#5

Well, you'll use the getplayernameex function? if yes i will change the whole code. and I've changed the following.


CMD:jail(playerid, params[])
{
if(pInfo[playerid][AdminLevel] >= 1) return SendClientMessage(playerid, -1,"{FF0000}[SYSTEM ERROR]: You don't have the privilege to use that command.");
{
new id, string[64],reason[100], admin[24], name[24];
if(sscanf(params, "ds[64]",id, reason)) 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");

SetPlayerInterior(id, 1;
SetPlayerPos(id, 1710.433715,-1669.379272,20.225049);
SetPlayerVirtualWorld(id, 10);
SetPlayerHealth(id, 9999999);
ResetPlayerWeapons(id);

GetPlayerName(playerid, admin,sizeof(admin));
GetPlayerName(id, name, sizeof(name) ) ;

format(string, sizeof string, "{FF0000}[SYSTEM]: %s has been jailed by %s | Reason: %s", name, admin, reason);
SendClientMessageToAll(-1, string);
}
return 1;
}

EDIT: The Reas thing happen because your string size is too small update this line
pawn Код:
new id, string[64],reason[100], admin[24], name[24];
to
pawn Код:
new id, string[144],reason[64], admin[24], name[24];
Reply
#6

If you don't want to jail yourself twice create a variable that checks if you are jailed or not for example:

pawn Код:
new Jailed[MAX_PLAYERS];
inside your command
pawn Код:
if(Jailed[ID] == 1)
{
     SendClientMessage(playerid, -1, "Player is already jailed.");
     return 1;
}
pretty basic, increase the string size to see the reason, increase it to about 128.

I'd recommend using a stock to get a players name instead of using GetPlayerName over and over again.

pawn Код:
stock GetName(playerid)
{
       new pname[MAX_PLAYER_NAME];
       GetPlayerName(playerid, pname, 24);
       return pname;
}
Reply
#7

Thanks everything works execpt i can still jail him twice mate.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)