Jump to content

Vehicle locked for class Help?


Bean666

Recommended Posts

tried this but all can enter:

function cars () 
    c1 = createVehicle ( 520, 227.69921875, 1882.142578125, 17.640625, 0, 0, 90 ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, cars ) 
  
function onEnter(thePlayer) 
    if source == c1 and ( getElementData(source, "gang") == "Alpha Team" ) then 
        outputChatBox("This Vehicle Is Locked for the Class:Admin", thePlayer, 0, 255, 0) 
        cancelEvent() 
    end 
end 
addEventHandler("onVehicleStartEnter", root, onEnter) 

Link to comment

that's wrong you must replace source with thePlayer

try this

function cars () 
    c1 = createVehicle ( 520, 227.69921875, 1882.142578125, 17.640625, 0, 0, 90 ) 
   addEventHandler("onVehicleStartEnter", root, onEnter) 
end 
addEventHandler ( "onResourceStart", resourceRoot, cars ) 
  
function onEnter(thePlayer) 
    if ( getElementData(thePlayer, "gang") == "Alpha Team" ) then 
        outputChatBox("Sorry you can't enter this vehicle", thePlayer, 0, 255, 0) 
        cancelEvent() 
    end 
end 
  

Edited by Guest
Link to comment
function cars () 
    c1 = createVehicle ( 520, 227.69921875, 1882.142578125, 17.640625, 0, 0, 90 ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, cars ) 
  
function onEnter(thePlayer) 
    if source == c1 and ( getElementData(thePlayer, "gang") == "Alpha Team" ) then 
        outputChatBox("This Vehicle Is Locked for the Class:Admin", thePlayer, 0, 255, 0) 
        cancelEvent() 
    end 
end 
addEventHandler("onVehicleStartEnter", root, onEnter) 

Link to comment
I'm in the Alpha Team gang and still doesnt work , only people in Alpha Team gang can't enter the vehicle

but people not in the Alpha Team gang can enter it , e.e

it's very easy but i don't know why you still asking for help as i told in the last code you prevent players in Alpha Team from entering this vehicle , so to change it you must change your code like this :

== : Equal

~= : Different

function cars () 
    c1 = createVehicle ( 520, 227.69921875, 1882.142578125, 17.640625, 0, 0, 90 ) 
   addEventHandler("onVehicleStartEnter", root, onEnter) 
end 
addEventHandler ( "onResourceStart", resourceRoot, cars ) 
  
function onEnter(thePlayer) 
    if ( getElementData(thePlayer, "gang") ~= "Alpha Team" ) then 
        outputChatBox("Sorry you can't enter this vehicle", thePlayer, 0, 255, 0) 
        cancelEvent() 
    end 
end 

Now Only Players in Alpha Team group can enter the c1 vehicle.

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