Jump to content

jail script


Recommended Posts

i am trying to make a script that jails people for being noobs. i will let you know firsthand that x,y,z and interiornumber is something that i will figure out later, im too lazy to check now lol. i need to figure out how to make this syntax work. /jail playername. does anyone have any pointers? my aim is to have the person warped to a jail cell and released in two minutes.

function jailPlayer ( thePlayer ) 
  
     setElementInterior ( thePlayer, interiorNumber ) 
  
     setElementPostion ( thePlayer, x, y, z ) 
  
     toggleAllControls ( thePlayer, false ) 
  
     showCursor ( thePlayer, true ) 
  
     outputChatBox ( "You have been jailed and will be released in two minutes", thePlayer, 255, 0, 0 ) 
  
end 
  
function freePlayer ( thePlayer ) 
  
     if isCursorShowing ( thePlayer, true ) then     
  
          setElementPosition ( thePlayer, x, y, z ) 
  
          setElementInterior ( thePlayer, 0 ) 
  
          toggleAllControls ( thePlayer, true ) 
  
          showCursor ( thePlayer, false ) 
  
          outputChatBox ( "You have been released, behave next time", thePlayer, 255, 0, 0 ) 
   end 
  
end 
  
addCommandHandler ( "jail", jailPlayer ) 
setTimer ( freePlayer, 120000, 0 ) 

Link to comment

I believe something like this would work, but I haven't tried - although I hope it will give you a clue.

function jailPlayer(thePlayer, commandName, jailTarget) 
    target = getPlayerFromNick(jailTarget) 
     
    if (target) then 
        -- Jail the player 
    else 
        -- Tell the "jailer" that the nick was invalid or something 
    end 
end 
addCommandHandler("jail", jailPlayer) 

Feel free to correct me if I'm wrong.

Link to comment

xit is right i just added the jail lines and the function to free the player

function jailPlayer(thePlayer, commandName, jailTarget) 
    target = getPlayerFromNick(jailTarget) 
    if (target) then 
        setElementInterior ( target, interiorNumber ) 
        setElementPostion ( target, x, y, z ) 
        toggleAllControls ( target, false ) 
        showCursor ( target, true ) --why do you want the cursor to be shown?! 
        outputChatBox ( "You have been jailed and will be released in two minutes", target, 255, 0, 0 ) 
        setTimer (unjail, 120000, 1, target) 
    else 
        outputChatBox ("Error: This player doesn't exist", thePlayer, 255, 100, 100) 
    end 
end 
  
function unjail (target) 
     if target then 
          setElementInterior ( target, 0) 
          setElementPosition (target, x, y, z) 
          toggleAllControls (target, true) 
          showCursor (target, false) 
          outputChatBox ("You've been released.", target, 255, 100, 100) 
     end 
end 
  
addCommandHandler("jail", jailPlayer) 

Link to comment

I got it working. since you guys were so kind i will shaw it with you.

to jail a person, use /jail playername

to free a person use /free playername

(if you feel the need to jail yourself, to get out of it, use the console and type unjail yourname :P)

the noob gets warped to a SFPD jail cell and when freed, gets warped outside the LVPD HQ (yes, i know, the cities are different, but SFPD has better jail cells, and the reason that you are freed at LVPD is becasue that is close to the spawnpoint, you can change the script if you feel inclined to, i dont really mind. just dont claim this as your own)

function jailPlayer(thePlayer, commandName, jailTarget) 
    theNoob = getPlayerFromNick(jailTarget) 
     
    if (theNoob) then 
        setElementInterior ( theNoob, 10 ) 
        setElementPosition (theNoob, 215.24324035645, 110.02223205566, 999.015625) 
        setElementDimension ( theNoob, 10 ) 
        toggleAllControls ( theNoob, false ) 
        outputChatBox ( "You have been jailed", theNoob, 193, 13, 13 ) 
        outputChatBox ( "You jailed a player", thePlayer, 193, 13, 13 ) 
         
    else 
        outputChatBox ("Error: This player doesn't exist", thePlayer, 193, 13, 13) 
    end 
end 
  
function unJail (thePlayer, commandName, jailTarget) 
     theNoob = getPlayerFromNick(jailTarget) 
     if (theNoob) then 
          setElementInterior ( theNoob, 0) 
          setElementPosition (theNoob, 2290.2666015625, 2431.1103515625, 10.8203125) 
          setElementDimension ( theNoob, 0 ) 
          toggleAllControls (theNoob, true) 
          outputChatBox ("You've been released, please behave next time", theNoob, 193, 13, 13) 
          outputChatBox ("You released a player", thePlayer, 193, 13, 13) 
     end 
end 
  
addCommandHandler("jail", jailPlayer) 
addCommandHandler("unjail", unJail ) 

cheers! :D

Link to comment

Hey,

Thanks for sharing this. It works well other than 2 problems.

You put you have to type to release a player;- /free name

But that doesn't work. Only /unjail name works.

2nd it appears everyone who is not an admin can use this.

Apart from that, great work :D

Link to comment

You put you have to type to release a player;- /free name

But that doesn't work. Only /unjail name works.

Put in or change the command handler:

  
addCommandHandler("free", unJail ) 
  

2nd it appears everyone who is not an admin can use this.

That's were the ACL comes in - to restrict access to commands. You'll probably find you need other situation handling code in there too e.g. if you jail someone, make sure they can't get out - by /kill or similar.

Link to comment

That's were the ACL comes in - to restrict access to commands. You'll probably find you need other situation handling code in there too e.g. if you jail someone, make sure they can't get out - by /kill or similar.

We got round it by adding:-

admin = getClientName(thePlayer) 
  if (admin == "name") or (admin == "name") then 
    if (theNoob) then 

So that it only works for certain people.

Ive no idea how to do acl stuff and i have no idea how to do anything about people doin /kil lol

Link to comment

I don't think the name method is going to work well - can't I just come along and rename myself and then be able to jail someone ? You really do need to add this into the ACL for more control.

Regarding the /kill : I was just talking generally (and to the OP). I've done a jailer ("sinbin") and I was saying that you need to make sure they can't escape (I had to block all commands for the user, for example).

Link to comment
I don't think the name method is going to work well - can't I just come along and rename myself and then be able to jail someone ? You really do need to add this into the ACL for more control.

Indeed you could. But until i know how to do this ACL thing then its gonna have to be like that. I have changed the 'jail' 'free' to something most people wouldn't think about so i think its safe for now.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...