SA-MP Forums Archive
Jail / Unjail ? - 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: Jail / Unjail ? (/showthread.php?tid=328990)



Jail / Unjail ? - petrux - 26.03.2012

Hello !
First ,sorry for my bad English , I'm french
I've got a problem in my script :

Код:
//Commande JAIL
new pid; //Joueur ban
CMD:jail(playerid, params[])
{
 if(IsPlayerAdmin(playerid))
 {
	new Raison[60]; // Raison
	new Temps
	new string[150],name[25],NameAdmin[25];
	if(sscanf(params,"ufs",pid,Temps,Raison))
	 {
		SendClientMessage(playerid,Color_Red,"Usage: /jail [ID] [Temps] [Raison]");
	 }
	else
	{
	GetPlayerName(pid,name,20);
	GetPlayerName(playerid,NameAdmin,20);
	format(string,sizeof(string),"%s a йtй jail par %s pour %f ! (Raison : %s)",name,NameAdmin,Temps,Raison);
	SendClientMessageToAll(Color_Red,string)
	SetPlayerPos(pid,2458.89990234,-1623.40002441,1015.38);
	TogglePlayerControllable(pid, 0);
	SetTimer("TimerJail", Temps, 0);
	}
 }
return 0
}
public TimerJail()
{
	SetPlayerPos(pid,1742.07, -1863.63, 13.57);
	TogglePlayerControllable(pid, 1)
	GameTextForPlayer(pid, "Vous etes libre, evitez maintenant d'enfreindre les regles", 3000, 3);
}
//Fin Commande Jail
This script is a jail script, when an Admin type "/jail [ID] [Time] [Reason]", It jail the person for x seconds normally
But It didn't Unjail... Why?
And, when the "Jailled" person disconnect and reconnect, He's not in jail...
How I Can do ?
Thanks !


Re: Jail / Unjail ? - yugecin - 26.03.2012

First, you should put new pid; inside the cmd:Jail
Because if you jail multiple players, it would only take the lastest player that is put in jail.

To fix it use this:
pawn Код:
forward TimerJail(pid);
public TimerJail(pid)
{
    SetPlayerPos(pid,1742.07, -1863.63, 13.57);
    TogglePlayerControllable(pid, 1)
    GameTextForPlayer(pid, "Vous etes libre, evitez maintenant d'enfreindre les regles", 3000, 3);
}
and

pawn Код:
SetTimer("TimerJail", Temps, 0);
becomes:
pawn Код:
SetTimerEx("TimerJail", Temps, 0, "i", pid");
With SetTimerEx you can use paramaters (the pid thing in TimerJail) https://sampwiki.blast.hk/wiki/SetTimerEx

About the disconnect/connect thingy, then you should save how much time left, and when he reconnects, check if his time left is 0, if not, rejail.


Re : Jail / Unjail ? - petrux - 26.03.2012

Thanks , but It didn't work :
Код:
CMD:jail(playerid, params[])
{
 if(IsPlayerAdmin(playerid))
 {
	new pid; //Joueur ban
	new Raison[60]; // Raison
	new Temps
	new string[150],name[25],NameAdmin[25];
	if(sscanf(params,"ufs",pid,Temps,Raison))
	 {
		SendClientMessage(playerid,Color_Red,"Usage: /jail [ID] [Temps] [Raison]");
	 }
	else
	{
	GetPlayerName(pid,name,20);
	GetPlayerName(playerid,NameAdmin,20);
	format(string,sizeof(string),"%s a йtй jail par %s pour %.0f secondes ! (Raison : %s)",name,NameAdmin,Temps,Raison);
	SendClientMessageToAll(Color_Red,string)
	SetPlayerPos(pid,2458.89990234,-1623.40002441,1015.38);
	TogglePlayerControllable(pid, 0);
	SetTimerEx("TimerJail", Temps, 0, "i", "pid");
	}
 }
return 0
}
public TimerJail(pid)
{
    SetPlayerPos(pid,1742.07, -1863.63, 13.57);
    TogglePlayerControllable(pid, 1)
    GameTextForPlayer(pid, "Vous etes libre, evitez maintenant d'enfreindre les regles", 3000, 3);
}
//Fin Commande Jail
It didn't unjail... Do you have a solution please?


Re: Re : Jail / Unjail ? - yugecin - 26.03.2012

Quote:
Originally Posted by petrux
Посмотреть сообщение
Thanks , but It didn't work :
-code-

It didn't unjail... Do you have a solution please?
Little guess: add return 1; at the end in TimerJail


Re : Jail / Unjail ? - petrux - 28.03.2012

It didn't work , but I'll find another solution ^^
Thanks for your help !