Junim Posted April 1, 2018 Share Posted April 1, 2018 Hi guys, i have a problem with this code: --------------------------------------------------------------------------------------------------------------------------------------------------------- function JoinVehicleCar (player, seat) local acc = getAccountName(getPlayerAccount(player)) if seat == 0 then if (getElementModel(player) == "Automobile" or "Bike") then if not (isObjectInACLGroup("user."..acc, aclGetGroup("HABCARMOTO"))) then cancelEvent() return outputChatBox("#000000[ #FFFF00CNH#000000 ] #FFFFFFVocê não possui #ff0000Habilitação #ffffff para conduzir este veiculo!",player,255,255,255, true) end end if (getElementModel(player) == "Helicopter" or "Plane") then if not (isObjectInACLGroup("user."..acc, aclGetGroup("HABAERO"))) then cancelEvent() return outputChatBox("#000000[ #FFFF00CNH#000000 ] #FFFFFFVocê não possui #ff0000Habilitação #ffffff para conduzir este veiculo!",player,255,255,255, true) end end if (getElementModel(player) == "Boat") then if not (isObjectInACLGroup("user."..acc, aclGetGroup("HABBOAT"))) then cancelEvent() return outputChatBox("#000000[ #FFFF00CNH#000000 ] #FFFFFFVocê não possui #ff0000Habilitação #ffffff para conduzir este veiculo!",player,255,255,255, true) end end end end addEventHandler("onVehicleStartEnter",root,JoinVehicleCar) ------------------------------------------------------------------------------------------------------------------------- The problem is: When I am inside an ACL for example "HABCARMOTO" that would be only car and motorcycle, I can get into planes and boats too and I did not want this. And when I enter the ACL "HABAERO" or "HABBOAT" I can not get into any vehicle, why does this happen? SORRY MY ENGLISH, I AM FROM BRAZIL! Link to comment
[MTA]Weed Posted April 1, 2018 Share Posted April 1, 2018 because you are canceling the event as i seen in your script cancelEvent() Link to comment
Junim Posted April 1, 2018 Author Share Posted April 1, 2018 This do not the player not enter in the vehicle? Link to comment
[MTA]Weed Posted April 1, 2018 Share Posted April 1, 2018 this will not allow the player in that acl group to use any of the specified vehicles above. at least i think. Link to comment
Junim Posted April 1, 2018 Author Share Posted April 1, 2018 Ok, i will make a test and back with breaking news! Link to comment
Junim Posted April 1, 2018 Author Share Posted April 1, 2018 This cancel the event when the player join in car. I take and continue with problem! But the player join the car same with mensage saying "you can't join the car" Link to comment
LLCoolJ Posted April 1, 2018 Share Posted April 1, 2018 (edited) function JoinVehicleCar (player, seat) local acc = getAccountName(getPlayerAccount(player)) if seat == 0 then if (getVehicleType(source) == "Automobile" or getVehicleType(source) == "Bike") then if not (isObjectInACLGroup("user."..acc, aclGetGroup("HABCARMOTO"))) then cancelEvent() return outputChatBox("#000000[ #FFFF00CNH#000000 ] #FFFFFFVocê não possui #ff0000Habilitação #ffffff para conduzir este veiculo!",player,255,255,255, true) end end if (getVehicleType(source) == "Helicopter" or getVehicleType(source) == "Plane") then if not (isObjectInACLGroup("user."..acc, aclGetGroup("HABAERO"))) then cancelEvent() return outputChatBox("#000000[ #FFFF00CNH#000000 ] #FFFFFFVocê não possui #ff0000Habilitação #ffffff para conduzir este veiculo!",player,255,255,255, true) end end if (getVehicleType(source) == "Boat") then if not (isObjectInACLGroup("user."..acc, aclGetGroup("HABBOAT"))) then cancelEvent() return outputChatBox("#000000[ #FFFF00CNH#000000 ] #FFFFFFVocê não possui #ff0000Habilitação #ffffff para conduzir este veiculo!",player,255,255,255, true) end end end end addEventHandler("onVehicleStartEnter",root,JoinVehicleCar) Edited April 1, 2018 by IRBIS Link to comment
myonlake Posted April 1, 2018 Share Posted April 1, 2018 That script doesn't make much sense where you compare the vehicle type. You're also repeating a lot of code, which isn't good. Try this. Not tested. function JoinVehicleCar(player, seat) if (seat == 0) then local accountName = getAccountName(getPlayerAccount(player)) local hasAccess = true if (getVehicleType(source) == "Automobile") or (getVehicleType(source) == "Bike") then hasAccess = accountName and isObjectInACLGroup("user." .. accountName, aclGetGroup("HABCARMOTO")) elseif (getVehicleType(source) == "Helicopter") or (getVehicleType(source) == "Plane") then hasAccess = accountName and isObjectInACLGroup("user." .. accountName, aclGetGroup("HABAERO")) elseif (getVehicleType(source) == "Boat") then hasAccess = accountName and isObjectInACLGroup("user." .. accountName, aclGetGroup("HABBOAT")) end if (not hasAccess) then cancelEvent() outputChatBox("#000000[ #FFFF00CNH#000000 ] #FFFFFFVocê não possui #ff0000Habilitação #ffffff para conduzir este veiculo!", player, 255, 255, 255, true) end end end addEventHandler("onVehicleStartEnter", root, JoinVehicleCar) Link to comment
Junim Posted April 1, 2018 Author Share Posted April 1, 2018 Yes, I tested and it worked! Thank you guy! 1 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