UTurn Posted April 20, 2014 Share Posted April 20, 2014 (edited) I downloaded and adapted to my needs a free resource made by lLinux that enables cars to fly by using the 'setWorldSpecialPropertyEnabled' function. Is there anyway that I can let each admin use the '/carsfly' command to toggle their cars ability to fly? I realize the 'setWorldSpecialPropertyEnabled' sets that ability for every user on the server. I just started learning to create a server the other day, the syntax of Lua was easy to figure out, but I don't know the API very well. First, I tried to put the car-flight resource in the "Admin" group in the ACL, then I tried defining the rights for the Access groups, 'false' for anything other than the "Admin" group. It still let normal players use the command. I also tried doing a check in the Lua script but I'm pretty sure I went about it all wrong. Is it possible to allow each individual admin to decide if they want their cars to fly? Here's the scripts: c_fly.lua --[[ .:Fly:. By lLinux --INFORMATION-- The code of this resource is free, you can use it and edit when you want it. --Instructions-- 1. Put the resource in the resources folder. 2. Start the resource 3. Use the command: /fly ]]-- carsCanFly = false function toggleCarFlight() local accName = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then -- Never evaluates to 'true' when 'Admin' if (carsCanFly == false) then carsCanFly = true setWorldSpecialPropertyEnabled("aircars", true) triggerServerEvent("carFlightOn", getLocalPlayer()) else carsCanFly = false setWorldSpecialPropertyEnabled("aircars", false) triggerServerEvent("carFlightOff", getLocalPlayer()) end else outputChatBox("#ffff00Dude, only admins can do that.", source, 255, 255, 255) -- Never gets displayed when 'Default' end end addCommandHandler("carsfly", toggleCarFlight) s_fly.lua --[[ .:Fly:. By lLinux --INFORMATION-- The code of this resource is free, you can use it and edit when you want it. --Instructions-- 1. Put the resource in the resources folder. 2. Start the resource 3. Use the command: /fly ]]-- function enableCarFlight() outputChatBox("#ffff00Car flight is now enabled.", source, 255, 255, 255, true) end addEvent("carFlightOn", true) addEventHandler("carFlightOn", getRootElement(), enableCarFlight) function disableCarFlight(thePlayer) outputChatBox("#ffff00Car flight is now disabled.", source, 255, 255, 255, true) end addEvent("carFlightOff", true) addEventHandler("carFlightOff", getRootElement(), disableCarFlight) Also, if you knew any resources that allows players to fly while on foot, or if you could help me a little bit on creating the script myself, that'd be awesome. Thanks in advance. Edited April 20, 2014 by Guest Link to comment
Bonsai Posted April 20, 2014 Share Posted April 20, 2014 Actually its a clientside function, therefore it only affects the player who uses that function/command. Link to comment
UTurn Posted April 20, 2014 Author Share Posted April 20, 2014 Actually its a clientside function, therefore it only affects the player who uses that function/command. Ahh, wow it's in big red letters in the wiki, idk how I missed that or what I was thinking. Thank you! Well, the check for admin access doesn't work, with it in place the script doesn't work at all, it doesn't turn on car flight when 'Admin' or notify of denied access when 'Default'. Am I doing the check wrong? Also, is there a strict separation of client-side and server-side scripts? Can I have both client-side and server-side functions in the same script? I notice the resource separated it in 2 scripts, client and server. Link to comment
Bonsai Posted April 20, 2014 Share Posted April 20, 2014 Some functions are server side, some are client side and some are shared. This function "isObjectInACLGroup" is server side only. If you want to restrict commands to admins only you should set the 3rd argument of addCommandHandler to "true" and add that command in the acl groups that should be able to use it. addCommandHandler ( string commandName, function handlerFunction, [bool restricted = false, bool caseSensitive = true] ) EDIT: I noticed this 3rd argument isn't existing client side, but still try to do this acl stuff. Not sure if it only works for admin then. Else you would have to attach a server side command to an function that triggers a client side event that enables this flying cars stuff I guess. Link to comment
UTurn Posted April 20, 2014 Author Share Posted April 20, 2014 Some functions are server side, some are client side and some are shared.This function "isObjectInACLGroup" is server side only. If you want to restrict commands to admins only you should set the 3rd argument of addCommandHandler to "true" and add that command in the acl groups that should be able to use it. addCommandHandler ( string commandName, function handlerFunction, [bool restricted = false, bool caseSensitive = true] ) EDIT: I noticed this 3rd argument isn't existing client side, but still try to do this acl stuff. Not sure if it only works for admin then. Else you would have to attach a server side command to an function that triggers a client side event that enables this flying cars stuff I guess. I just tried what you said, and even with the command rights defined in the ACL to only allow admins access, it still allows everyone to use the command. Link to comment
MIKI785 Posted April 20, 2014 Share Posted April 20, 2014 Thats because client cant check ACL. What would i do is to set element data for player on onPlayerLogin if hes admin set data admin to true and then check this clientsided. Link to comment
UTurn Posted April 21, 2014 Author Share Posted April 21, 2014 Thats because client cant check ACL. What would i do is to set element data for player on onPlayerLogin if hes admin set data admin to true and then check this clientsided. Thank You! That worked perfectly Link to comment
MohamedZeka Posted August 28, 2017 Share Posted August 28, 2017 didn't work for me ;-; 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