SA-MP Forums Archive
Jail - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Jail (/showthread.php?tid=582696)



Jail - Glossy42O - 22.07.2015

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;




Re: Jail - DarkLored - 22.07.2015

new admin[MAX_PLAYER_NAME];

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


Re: Jail - SilentSoul - 22.07.2015

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;
}



Re: Jail - Glossy42O - 22.07.2015

Thanks mate.

2 problems.

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


Re: Jail - SilentSoul - 22.07.2015

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];



Re: Jail - DarkLored - 22.07.2015

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;
}



Re: Jail - Glossy42O - 22.07.2015

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