Jump to content

[REL] Faction gates


furruz

Recommended Posts

server:

col  = createColTube (-871.99, 1638.93, 28.7, 10, 3) -- enter your cooderates here for your colshape please note 10 and 3 is to do with the size of the shape. 
root = getRootElement () 
  
door = createObject ( 980, -871.990234375, 1638.9345703125, 28.7, 0, 0, 212.5) -- enter the ID of the object followed by the coordinates 
                                                    -- note the rotx y and z may not be required so you just remove these. x y and z is where you would put your cordinates. 
  
addEvent ( "Open", true ) 
function Open ( pla ) 
  
        if getElementType ( pla ) == "player" then 
        if vehicle or not vehicle then 
            if --here you can alter the group from Admin to whatever you require in your server but remember the rest must be the same i.e change everything where it says Admin to your desired group and add the users to that group. 
        exports.factions:isPlayerInFaction(pla,1) then 
        moveObject (door, 2200, -875.990234375, 1638.9345703125, 28.7) -- here is where you enter the coordinatess of the new location of the object, 2200 = the speed of the movent. 
                else          
                return 0 
             
                end 
            end 
        end 
    end 
     
addEventHandler ( "onColShapeHit", col, Open)  
addEventHandler ( "Open", root, Open) 
  
function Close ( pla ) 
    if getElementType ( pla ) == "player" then 
        if vehicle or not vehicle then 
            if 
          exports.factions:isPlayerInFaction(pla,1) then 
             moveObject (door, 2951, -871.990234375, 1638.9345703125, 28.7) -- here is where you copy the coordinates of the orginal location of the object, 2951 = the timer of movent. 
            else  
            return 0 
            end 
        end 
    end 
end 
  
  
addEventHandler ( "onColShapeLeave", col, Close ) 
addEventHandler ( "Close", root, Close) 
  
  
  
  

xml:

<meta> 
    <info author="x" description="x" version="1.0" type="script" /> 
    <script src="script.lua"  /> 
    <include resource="factions"/> 
</meta> 

EDIT: It is working. The door is open when a character with factionID 1 hits the ColShape

Edited by Guest
Link to comment
col  = createColTube ( -871.99, 1638.93, 28.7, 10, 3 ) 
-- enter your cooderates here for your colshape please note 10 and 3 is to do with the size of the shape.  
door = createObject ( 980, -871.990234375, 1638.9345703125, 28.7, 0, 0, 212.5 ) -- enter the ID of the object followed by the coordinates 
-- note the rotx y and z may not be required so you just remove these. x y and z is where you would put your cordinates. 
  
function Open ( pla ) 
    if ( getElementType ( pla ) == "player" ) then 
        if ( not isPedOnVehicle ( pla ) ) then 
            if exports.factions:isPlayerInFaction ( pla, 1 ) then --here you can alter the group from Admin to whatever you require in your server but remember the rest must be the same i.e change everything where it says Admin to your desired group and add the users to that group. 
                moveObject ( door, 2200, -875.990234375, 1638.9345703125, 28.7 ) -- here is where you enter the coordinatess of the new location of the object, 2200 = the speed of the movent. 
            end 
        end 
    end 
end 
addEventHandler ( "onColShapeHit", col, Open ) 
  
function Close ( pla ) 
    if ( getElementType ( pla ) == "player" ) then 
        if ( not isPedOnVehicle ( pla ) ) then 
            if exports.factions:isPlayerInFaction ( pla, 1 ) then 
                moveObject ( door, 2951, -871.990234375, 1638.9345703125, 28.7 ) -- here is where you copy the coordinates of the orginal location of the object, 2951 = the timer of movent. 
            end 
        end 
    end 
end 
addEventHandler ( "onColShapeLeave", col, Close ) 

1: There was no need to use addEvent.

2: "if vehicle or not vehicle then" that check was useless, see my code I added:

if ( not isPedOnVehicle ( pla ) ) then 

3: No need to return '0'.

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...