Jump to content

(HELP)How to make a door that opens only for a group


Recommended Posts

but as the gang get the player because it is with getElementData but as would be the line?

To explain better what I did with the "Team" of a player not with the gang look:

function Funcion (source) 
    playerTeam = getPlayerTeam ( source ) 
    Clann = getTeamFromName ( "TeamName" ) 

As would be with the gang system?

sorry for my bad English :roll:

Link to comment
-- All gates and their data 
gate = { 
    -- ObjectID     closeX      closeY      closeZ      openX       openY       openZ       rotX    rotY    rotZ    colX    colY    colZ    colRad  Group   Scale 
    [1]={ 11327,    1587.7,     -1638.4,    14.8,       1587.7,     -1638.4,    20,         0,      0,      90,     1588,   -1638,  10,     10,     "ISA",  1 }, 
    [2]={ 10671,    -1631,      688.4,      9.587,      -1631,      688.4,      20.187,     0,      0,      90,     -1631,  688,    7.187,  10,     "ISA",  2 }, 
    [3]={ 11327,    2334.6,     2443.7,     7.70,       2334.6,     2443.7,     15.70,      0,      0,      -30,    2334.6, 2443.7, 5.70,   10,     "ISA",  1.3 }, 
    [4]={ 11327,    2294,       2497.4,     5.3,        2294,       2497.4,     14.3,       0,      0,      0,      2294,   2497.6, 4.3,    15,     "ISA",  1.2 }, 
} 
  
-- Global data members 
gates = { } 
cols =  { } 
ocpenSpeed = 3000 
  
-- Add all gates 
function mapLoad ( name ) 
    for k=1, #gate do 
        -- Create objects 
        local gat = createObject( gate[k][1], gate[k][2], gate[k][3], gate[k][4], gate[k][8], gate[k][9], gate[k][10] ) 
        local col = createColCircle( gate[k][11], gate[k][12], gate[k][13], gate[k][14] ) 
        setObjectScale( gat, gate[k][16] ) 
     
        -- Assign arrays of object pointers 
        gates[col] = gat 
        cols[col] = k 
         
        -- Add event handlers 
        addEventHandler("onColShapeHit", col, openGate ) 
        addEventHandler("onColShapeLeave", col, closeGate ) 
    end 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(), mapLoad ) 
  
-- Gates open                            
function openGate(player) 
    local ID = cols[source] 
    if isElement(player) and ( getElementData(player, "Group" ) == gate[ID][15] or  
        getElementData(player, "Group" ) == "ACRP" ) or getPlayerTeam(player) == getTeamFromName("Staff") then 
        moveObject(gates[source], ocpenSpeed, gate[ID][5], gate[ID][6], gate[ID][7] )  
    end 
end   
-- Gates close 
function closeGate(player) 
    local ID = cols[source] 
    if isElement(player) and ( getElementData(player, "Group" ) == gate[ID][15] or  
        getElementData(player, "Group" ) == "ACRP" ) or getPlayerTeam(player) == getTeamFromName("Staff") then 
        moveObject(gates[source], ocpenSpeed, gate[ID][2], gate[ID][3], gate[ID][4] )  
    end 
end 

A complete gate system with some predefined groups and gates on the police departments in all cities, source: http://forum.404rq.com/index.php/topic,242.0.html#forum

Edited by Guest
Link to comment

and how I can add these lines to my resource?

objeto = createObject (980 , 135.5255859375, 1940.83203125, 20.809717178345, 0, 0, 179.75 ) 
x,y,z = getElementPosition (objeto) 
Zona = createColCircle ( x,y, 5, 5 ) 
  
function Funcion (source) 
    playerTeam = getPlayerTeam ( source ) 
    Clann = getTeamFromName ( "ArmedForces" ) 
    if ( playerTeam ) == Clann then 
        moveObject ( objeto, 300, 135.7255859375, 1940.83203125, 15.309717178345, 0, 0, 0 ) 
    outputChatBox ( "", source, 0, 255, 0, true ) 
    else 
    outputChatBox ( "Tu no eres Un Militar!", source, 255, 0, 0, true ) 
end 
end 
addEventHandler ( "onColShapeHit", Zona, Funcion ) 
  
function Funcion2 () 
        moveObject ( objeto, 300, 135.7255859375, 1940.83203125, 21.309717178345, 0, 0, 0 ) 
        outputChatBox ( "Adios Soldado", source, 0, 255, 0, true ) 
end 
addEventHandler ( "onColShapeLeave", Zona, Funcion2 ) 
  

PD: this resource is Azno10

Link to comment

You don't need to add anything actually, it's a complete resource. What you can do is to copy the data of your createObject function to the table according to the description in order to create a gate in a place you already chosen. Or try it out as it is by visiting LSPD garage and observe the gate there how it works according to the script.

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