Setting a timer to unjail, 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Setting a timer to unjail, help (
/showthread.php?tid=239389)
Setting a timer to unjail, help -
ricardo178 - 13.03.2011
Hey guys, one more time i need help... I made my jail cmd but now i don't know how to set a timer that unjail after 3 minuts!
Here's the code, Thanks!
pawn Код:
COMMAND:cjail(playerid, params[])
{
if(GetPlayerColor(playerid) == 0x0259EAAA)
{
new toplayer;
if(!sscanf(params, "ui", toplayer))
{
if(IsPlayerConnected(toplayer))
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X,Y,Z);
if(IsPlayerInRangeOfPoint(toplayer, 20.0, X,Y,Z))
{
new string[64];
new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(toplayer, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "Cop %s Has UnStun You", name);
SendClientMessage(playerid, 0x0259EAAA, string);
format(string, sizeof(string), "You Has UnStun %s", PlayerName);
SendClientMessage(playerid, 0x0259EAAA, string);
SetPlayerPos(toplayer, 264.6288,77.5742,1001.0391);
return 1;
}
else return SendClientMessage(playerid, 0x0259EAAA, "You Are Not Near The Player.");
}
else return SendClientMessage(playerid, 0x0259EAAA, "Player Is Not Connected.");
}
else return SendClientMessage(playerid, 0x0259EAAA, "USAGE: /cjail [PlayerId/PartOfName]");
}
else return SendClientMessage(playerid, 0x0259, "You Are Not Cop!");
}
THANKS
Re: Setting a timer to unjail, help -
blackwave - 13.03.2011
A variable for jailing the player:
pawn Код:
new jailed[MAX_PLAYERS]; // Put it on script top (global variable)
forward UnJail();
On the command, after setting player position (jailing him), put that:
Also a timer:
pawn Код:
SetTimer("UnJail",180000,false); // 60000ms = 1min || 180000 = 3min
Also the cllback function:
pawn Код:
public UnJail()
{
for(new v; v < MAX_PLAYERS; v++)
{
if(jailed[v] == 1)
{
SetPlayerPos(v, x, y, z); // Change x y z for the position you want the players go after unjailed
jailed[v] = 0;
}
return 1;
}
Re: Setting a timer to unjail, help -
ricardo178 - 13.03.2011
Thanks man!