SA-MP Forums Archive
block commands in jail help - 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: block commands in jail help (/showthread.php?tid=640984)



block commands in jail help - vegaltasendai - 09.09.2017

I need players in jail can not use any kind of commands I have this thanks


Код:
CMD:jail(playerid, params[])
{
 if(Player[playerid][Level] < 1) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}only level 1.");
 new string[128], Jugador[MAX_PLAYER_NAME], AdminJ[MAX_PLAYER_NAME];
 if(sscanf(params, "ui", params[0], params[1])) return SendClientMessage(playerid, -1, "Use: /Jail [id] [minutes]");
 if(IsPlayerConnected(params[0]))
 {
 SetPlayerPos(params[0], my cordinates xxx);
 ResetPlayerWeapons(playerid);
 SetPlayerVirtualWorld(params[0], 0);
 JailTiempo[params[0]] = SetTimer("Libre", params[1]*60*1000, false);
 JailSi[params[0]] = 1;
 GetPlayerName(playerid, AdminJ, sizeof(AdminJ));
 GetPlayerName(params[0], Jugador, sizeof(Jugador));
 format(string, sizeof(string), "- admi %s jailed to %s por %i minute.", AdminJ, Jugador, params[1]);
 SendClientMessageToAll(-1, string);
 }
 else SendClientMessage(playerid, -1, "player no online.");
 return 1;
}
//------------------------------------------------------------------------------
CMD:unjail(playerid, params[])
{
 new string1[128], Jugador1[MAX_PLAYER_NAME];
 if(sscanf(params, "u", params[0])) return SendClientMessage(playerid, -1, "Use: /UnJail [id]");
 if(IsPlayerConnected(params[0]))
 {
 if(JailSi[params[0]] == 0) return SendClientMessage(playerid, -1, "player is in jail.");
 SpawnPlayer(params[0]);
 SetPlayerInterior(params[0], 0);
 SetPlayerVirtualWorld(params[0], 0);
 KillTimer(JailTiempo[params[0]]);
 JailSi[playerid] = 0;
 GetPlayerName(params[0], Jugador1, sizeof(Jugador1));
 format(string1, sizeof(string1), "Liberaste a %s", params[0]);
 SendClientMessage(playerid, -1, string1);
 GameTextForPlayer(params[0], "~g~unjailed by admi", 5000, 4);
 PlayerPlaySound(params[0], 1057, 0.0, 0.0, 0.0);
 }
 else SendClientMessage(playerid, -1, "player no online.");
 return 1;
}
forward Libre(playerid);
public Libre(playerid)
{
  SpawnPlayer(playerid);
  SetPlayerInterior(playerid, 0);
  SetPlayerVirtualWorld(playerid, 0);
  KillTimer(JailTiempo[playerid]);
  JailSi[playerid] = 0;
  GameTextForPlayer(playerid, "~g~Descarcelado", 5000, 4);
  PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
}



Re: block commands in jail help - alanhutch - 09.09.2017

Put
pawn Код:
new InJail[MAX_PLAYERS];
On the top of the script
On top of every command:
pawn Код:
if(InJail[playerid] == 1) return SendClientMessage(playerid, -1, "You can't use this command, you are in jail.");
In /jail
pawn Код:
InJail[playerid] = 1;
And in /unjail
pawn Код:
InJail[playerid] = 0;



Re: block commands in jail help - AmarPlayer - 09.09.2017

On the top of your script type:
Код:
new IsJailed[MAX_PLAYERS];
Now in the jail CMD, above this line: SetPlayerPos(params[0], my cordinates xxx);
Type:
Код:
if(IsJailed[id] == 1) return SendClientMessage(playerid, -1, "That player is already in jail.");
else
{
     IsJailed[id] = 1;
}
And in OnPlayerText:
Код:
public OnPlayerText(playerid, text[])
{
	if(IsJailed[playerid] == 1)
	{
		return SendClientMessage(playerid, -1, "You are jailed");
	}
	return 0;
}
In OnPlayerConnect
Код:
public OnPlayerConnect(playerid, classid)
{
     IsJailed[playerid] = 0;
     return 1;
}
And in unjail CMD type:
Код:
if(IsJailed[playerid] == 0) return SendClientMessage(playerid, -1, "Player is not jailed");
else
{
     IsJailed[playerid] = 0
}
That's it.


Re: block commands in jail help - vegaltasendai - 09.09.2017

thanks to both I served the first but keep those scripts
solved +1 rep


Re: block commands in jail help - BadJih - 09.09.2017

if(JailSi[params[0]] == 1)
{
SendClientMessage(Playerid, "You cant use this command while you're jailed.")
}


Re: block commands in jail help - BadJih - 09.09.2017

Quote:
Originally Posted by BadJih
Посмотреть сообщение
if(JailSi[params[0]] == 1)
{
SendClientMessage(Playerid, "You cant use this command while you're jailed.")
}
put this in the command that you need to disallow for jailed players