Jail / Unjail ?
#1

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 !
Reply
#2

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.
Reply
#3

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?
Reply
#4

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
Reply
#5

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


Forum Jump:


Users browsing this thread: 1 Guest(s)