Jump to content

Vehicle locked for class Help?


Bean666

Recommended Posts

Posted

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) 

Aftermath

Posted (edited)

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

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
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) 

 

 

Posted
BOTH DON'T WORK OMFG.

are you serious man , it's working fine are you sure that your gang is Alpha Team.

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted (edited)

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

Edited by Guest

Aftermath

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

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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