JAIL system -
Kudoz - 20.01.2013
Hey guys! I've made my own Jailsystem here, but I've obviously done something wrong! When a player kills another player, the 'killerid' gets jailed. But they never get unjailed! Only ID 0! no matter if id 0 did the kill or not. How can I fix this?
heres a bit of the code; ofc with forward...
Code:
public UnJail(playerid, killerid)
{
isJailed[playerid] = 0;
isJailed[killerid] = 0;
SetPlayerPos(killerid,-1898.6420,243.1353,41.0469);
SendClientMessage(killerid, COLOR_LIGHTRED, ".: You have been released! :.");
return 1;
}
Re: JAIL system -
Mr_Zlodei - 20.01.2013
you use a timer?
Re: JAIL system -
Kudoz - 20.01.2013
yes, 1 minute
EDIT;
Additional information, if it helps;
Code:
public OnPlayerDeath(playerid, killerid, reason)
{
isJailed[killerid] = 1;
SetTimer("UnJail", 100000, false); //False because we wont repeat timer...True if repeat.
SetPlayerPos(killerid,1760.0499,-1538.4115,9.3113);
SendClientMessage(killerid, COLOR_LIGHTRED,".: It's NOT tolerated to kill anyone here! Therefore, You've been put to jail!");
SendDeathMessage(killerid, playerid, reason);
GivePlayerMoney(killerid, -10000);
return 1;
Re: JAIL system -
Threshold - 20.01.2013
Yeah, show us where you SET, USE and CALL the function Unjail.
Re: JAIL system -
Kudoz - 20.01.2013
I edited above;
+++
[on top of script];
Code:
new isJailed[MAX_PLAYERS];
forward UnJail(playerid, killerid);
Re: JAIL system -
Mr_Zlodei - 20.01.2013
use
PHP Code:
SetTimerEx("UnJail", 100000, false, "ii", killerid, playerid );
Re: JAIL system -
Kudoz - 20.01.2013
Will that help against the problem i have? i mean, when players kill eachother, its all on id 0..
Re: JAIL system -
DaRk_RaiN - 20.01.2013
As Mr_Zlodei said its SetTimerEx that works in this case.
Re: JAIL system -
Threshold - 20.01.2013
This happens because you haven't given a value to 'killerid' or 'playerid', which is why you use SetTimerEx, to give a value to the parameters of a function. In this case, killerid and playerid. As shown in Mr_Zlodei's post.
https://sampwiki.blast.hk/wiki/SetTimerEx
EDIT: Why are you using a playerid parameter in the function anyway?
EDIT2: Below Post said it
Re: JAIL system -
Mr_Zlodei - 20.01.2013
I really, really do not know much English and I can not really make out your text. But I understood the code exactly what you need and I will write the sample code to your function.
sorry for my bad english, I hope to understand everything
PHP Code:
public OnPlayerDeath(playerid, killerid, reason)
{
if ( killerid != 0xFFFF )
{
isJailed[killerid] = 1;
SetTimerEx("UnJail", 100000, false, "i", killerid );
SetPlayerPos(killerid,1760.0499,-1538.4115,9.3113);
SendClientMessage(killerid, COLOR_LIGHTRED,".: It's NOT tolerated to kill anyone here! Therefore, You've been put to jail!");
SendDeathMessage(killerid, playerid, reason);
GivePlayerMoney(killerid, -10000);
}
return 1;
}
public UnJail(killerid)
{
isJailed[killerid] = 0;
SetPlayerPos(killerid,-1898.6420,243.1353,41.0469);
SendClientMessage(killerid, COLOR_LIGHTRED, ".: You have been released! :.");
return 1;
}
EDIT: 1 minute = 60,000 milliseconds, in your case (10000 milliseconds) = 1.6 minutes ....
I'm sure this is not so important
Re: JAIL system -
Kudoz - 20.01.2013
Thanks guys! +REP to you both!