#1

How can i make a command that jails players and they can't get out with relog they will get out when the time is gone .. If somone have the command please give me it and instructions ..
Reply
#2

Create a boolean variable that you set to true when you jail a player.
Save the var in the player stats, load it when the player connects, and when he connects, if it's "true", re-jail him.
Set the var to "false" when you unjail the player.
Reply
#3

Quote:
Originally Posted by S4t3K
Посмотреть сообщение
Create a boolean variable that you set to true when you jail a player.
Save the var in the player stats, load it when the player connects, and when he connects, if it's "true", re-jail him.
Set the var to "false" when you unjail the player.
It shouldnt be a boolean var

it should be a normal var that saves the time for example

pawn Код:
new jailtime[MAX_PLAYERS];
when u jail him set the jail time with this var like if u wanna jail him for 30 seconds do

pawn Код:
jailtime[targetid] = 30;
create a timer that repeat every second

if the jailtime > 0 then do jailtime --; to decrease the jail time

and when jailtime = 0 release him

when the player disconnect save the jailtime var

and when he connects load the jailtime var.

now when he spawns check if the jailtime var of the player is higher than 0 if yes set him in jail.
Reply
#4

In my mind, it would be

PHP код:

new bool:jailed;
if(
jailed// Save the var to 1 in the player stats
else // Save the var to 0 in the player stats 
Another method working, which reffer to yours but which wastes less performances : (I consider that the "time" var already contains the jailtime in minutes)

PHP код:

new jailtime[MAX_PLAYERS] = 0;
// In the jail command
jailtime[targetid] = gettime() + time*60// If time is already in seconds, don't multiply per 60
// Save the jailtime var in the targetid stats, and when he connects, after data loading
if(jailtime[playerid] > gettime()) Jail(playerid); 
I guess you know the gettime() function, so of course it's better performances than setting a timer whichs repeats every seconds.
Reply
#5

i didn't understand nothing im a begginer :S Can somone meke it for me i now to set cordinates .. and with instructions ..
Reply
#6

I won't make a ready-made code, and I hope nobody will.

Instead, try to make it by yourself :

gettime + SetPlayerPos + eventually SetPlayerVirtualWorld will do the job.

For the saving system, I recommend you either y_ini or djson for ini systems, or BlueG's mysql plugin (now developped by Pain123/Maddinat0r) for the mysql.
Reply
#7

Okey , i make it and now how to make when he will get out from jail to spawn ?
Reply
#8

Then use a timer.
When you jail him, use SetTimerEx to call a function which will unjail the player.
Reply
#9

Quote:
Originally Posted by S4t3K
Посмотреть сообщение
Then use a timer.
When you jail him, use SetTimerEx to call a function which will unjail the player.
Spawn location not that ..
Reply
#10

Oh, if you want to set him to his pre-jail position, simply get and store the position of the player before jailing him, in a global var or a static one.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)