Jump to content

Lua Syntaxing


Recommended Posts

I want to block a vehicle for admins only... I want to have a list of blocked vehicles and have it not allow you to start the car if your not a admin. But I'm having a issue, heres the script:

local party = { Rhino = 432, Hydra = 520, Hunter = 425 } 
local model = getElementModel(veh) 
for key,value in pairs(party) do  
     if (model==value) and (getElementData(source, "admin")==1) then 
     -- start car 
     else 
     outputChatBox("You must be a admin to start this vehicle", source, 255, 0, 0) 
     end 
end 
  

The problem with it is, it will do all 3 of the values before ending the function. I just want it to stop if it finds out that the model==value. With this it will check, 432 then, 520, then 425, which means it will start the car twice and fail once if you were in a Hunter for example, which would still let you use the vehicle... I know I could do

  
if (model==432) then return end 
  

For them all, but I think this would be neater and better. Please help. Again to restate I want the function to check if the model = value and stop if 1 of the 3 = the model.

Link to comment
  
local Vehicles = { 
    [432] = true, 
    [520] = true, 
    [425] = true; 
}; 
  
if Vehicles[getElementModel(vehicle)] and getElementData(player,"admin") == 1 then 
    -- your code; 
else 
    outputChatBox("You are not an admin!",player); 
end; 
  

Link to comment
local acc = getAccountName (getPlayerAccount (source )) 
local Vehicles = { 
    [432] = true, 
    [520] = true, 
    [425] = true; 
}; 
  
if Vehicles[getElementModel(Vehicles)] then 
 if isObjectInACLGroup ("user."..acc, aclGetGroup ( "Admin" ) ) then 
    -- your code;. 
else 
    outputChatBox("Only Admins Are Allowed , Sorry !",source); 
end; 

You Can Use it insted of getElementData ,

it's Server Side ,

Edited by Guest
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...