Controlled Posted June 3, 2014 Share Posted June 3, 2014 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
Castillo Posted June 3, 2014 Share Posted June 3, 2014 Why are you even using a loop? you can do it without using one. Link to comment
Controlled Posted June 3, 2014 Author Share Posted June 3, 2014 Why are you even using a loop? you can do it without using one. I figured it would be easier to add and remove IDs from if I need to. Then its not one big "if" statement. If you know a better way to do it then please let me know. Link to comment
cheez3d Posted June 3, 2014 Share Posted June 3, 2014 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
Max+ Posted June 3, 2014 Share Posted June 3, 2014 (edited) 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 June 3, 2014 by Guest Link to comment
#RooTs Posted June 3, 2014 Share Posted June 3, 2014 not working, any of the types debug error line 8 if Vehicles[getElementModel(vehicle)] then Link to comment
Max+ Posted June 3, 2014 Share Posted June 3, 2014 it's Server Side , i Edited my Post , Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now