PDA

View Full Version : Jail command.


Isolated
13/06/2013, 06:45 PM
Hey,

I was wondering, I've created a small jail system, and was wondering how I would record players spent minutes/seconds.

Below is the code of the system so far.

public SendPlayerToJail(playerid, minutes, seconds)
{
if(IsJailed[playerid]) return 0;
else
{
new rand = random(3);
SetPlayerInterior(playerid, 6);
switch(rand)
{
case 0: SetPlayerPos(playerid, 262.9825,77.4500,1001.0391);
case 1: SetPlayerPos(playerid, 193.6294,161.8236,1003.2417);
case 2: SetPlayerPos(playerid, 190.8504,161.0375,1003.2417);
}
GameTextForPlayer(playerid, "~r~JAILED", 3000, 6);
SetTimerEx("JailTimer", Minute(minutes) + Second(seconds), false, "d", playerid);
new String[70];
format(String, sizeof(String), "%s (ID: %d) has been jailed.", ReturnPlayerName(playerid), playerid);
SendClientMessageToAll(COLOR_YELLOW, String);
}
return 1;
}


public JailTimer(playerid)
{
GameTextForPlayer(playerid, "~g~FREEDOM", 3000, 6);
SpawnPlayer(playerid);
new String[70];
format(String, sizeof(String), "%s (ID: %d) has been released from jail.", ReturnPlayerName(playerid), playerid);
SendClientMessageToAll(COLOR_YELLOW, String);
return 1;
}

But, however if a player quits then reconnects they'd be free again.

Thanks,

-Mike.

LilBob
13/06/2013, 08:03 PM
Where is your player variable ? Like [pJailed] ?
After you should put on the public Setplayerspawn


if(PlayerInfo[playerid][pJailed] == 1)
{
SendPlayerToJail(playerid,1);
return 1;
}

Isolated
13/06/2013, 08:12 PM
Can you re-phrase that please?

Juanxz
13/06/2013, 08:17 PM
I think he means that it will be set on a save file that the person if jailed...so on spawn if the server sees that that person is supposed to be in jail, he will be sent straight to jail.

LilBob
13/06/2013, 08:18 PM
Put in pInfo: pJailed.

In your code add PlayerInfo[playerid][pJailed]=1;

After for fixing your bug while reconnect on server, put my code in SetplayerSpawn (the public).

Isolated
13/06/2013, 08:32 PM
It's not a bug. I'm looking for an answer so if the player logs out then reconnects, instead of being jailed for an infinate time, he will have minutes and seconds, which were the minutes and seconds that he disconnected with. Instead of reseting the clock.

LilBob
13/06/2013, 08:42 PM
I wrote that code in my gm (i have also a pJailTime in pInfo)

if(PlayerInfo[playerid][pJailTime] > 0 && PlayerInfo[playerid][pJailed] != 0)
{
PlayerInfo[playerid][pJailTime]-=2;
if(PlayerInfo[playerid][pJailTime] <= 0)
{unjail_player(playerid);}
}

Maybe could this help you

Isolated
13/06/2013, 09:38 PM
how do you update that ?

Isolated
14/06/2013, 12:33 PM
bump

Isolated
15/06/2013, 07:22 PM
bump