All pastes #825013 Raw Edit

jail

public c v1 · immutable
#825013 ·published 2007-12-20 08:08 UTC
rendered paste body
// -- Simple Jailing system Filterscript --// --       By Donny / Donny_K (2007)    --// -- It has a basic jailing system for the Admins --// -- You can control how long the JailTime time   --// -- is by using the -- /jail [amount] command... --#include <a_samp>//Credit to DracoBlue and Y_Less for DCMD (http://forum.sa-mp.com/index.php?topic=1858.0)#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1dcmd_jail(playerid, params[]){	new id,		sentence_time;	if (!sscanf(params, "ii", id, sentence_time)) return SendClientMessage(playerid, 0xafafafff, "Usage: /jail [id] [time]"); //Grey colour	if (!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xafafafff, "*** Invalid Player ID ***");	if (sentence_time < 1) return SendClientMessage(playerid, 0xafafafff, "The sentence time needs to be greater than one second");	new str[96];	format(str, sizeof(str), "You have been Jailed %d seconds", sentence_time);	SendClientMessage(id, 0xffe600ff, str); //yellow (yolk) colour	format(str, sizeof(str), "You have Jailed %d for %d seconds", id, sentence_time);	SendClientMessage(playerid, 0xffe600ff, str); //yellow (yolk) colour	SetPlayerInterior(id, 3);	SetPlayerPos(id, 198.3797, 160.8905, 1003.0300);	SetPlayerFacingAngle(id, 177.0350);	SetPlayerCameraPos(id, 198.3797, 158.8905, 1008.0300);	SetPlayerCameraLookAt(id, 198.3797, 160.8905, 1003.0300);	TogglePlayerControllable(id, false);	SetCameraBehindPlayer(id);	new ii = sentence_time;	do	{		SetTimerEx("StayPut", (sentence_time - ii) * 1000, false, "ii", id, ii);		ii --;	}	while (ii != -1);	return 1;}public OnPlayerCommandText(playerid, cmdtext[]){	if (IsPlayerAdmin(playerid))	{		dcmd(jail, 4, cmdtext);	}	return 0;}forward StayPut(playerid, length);public StayPut(playerid, length){	new str[32];	if (length)	{		format(str, sizeof(str), "Time left ~n~ %i", length);		GameTextForPlayer(playerid, str, 1001, 6); //Orange/bronze colour (standard for style 4)	}	else	{	    SetPlayerInterior(playerid, 0);	    SpawnPlayer(playerid);		GameTextForPlayer(playerid, "~g~Released from jail", 4000, 4); //Green colour	}}stock sscanf(string[], format[], {Float,_}:...) //Credit to Y_Less (http://forum.sa-mp.com/index.php?topic=638.msg115720;topicseen#msg115720){	new		formatPos,		stringPos,		paramPos = 2,		paramCount = numargs();	while (paramPos < paramCount && string[stringPos])	{		switch (format[formatPos])		{			case '\0': break;			case 'i', 'd': setarg(paramPos, 0, strval(string[stringPos]));			case 'c': setarg(paramPos, 0, string[stringPos]);			case 'f': setarg(paramPos, 0, _:floatstr(string[stringPos]));			case 's':			{				new					i;				if(format[formatPos + 1] != '\0')					while (string[stringPos] != ' ' && string[stringPos] != '\0') setarg(paramPos, i++, string[stringPos++]);				else					while (string[stringPos] != '\0') setarg(paramPos, i++, string[stringPos++]);				setarg(paramPos, i, '\0');			}			default: goto skip;		}		while (string[stringPos] && string[stringPos] != ' ') stringPos++;		while (string[stringPos] == ' ') stringPos++;		paramPos++;		skip:		formatPos++;	}	return format[formatPos] ? 0 : 1;}