MohamedZeka Posted August 27, 2017 Share Posted August 27, 2017 when i make my script it doesn't work message shown [14:21:25] WARNING: test\c_fly.lua:15: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [14:21:25] WARNING: test\c_fly.lua:15: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] [14:21:25] ERROR: test\c_fly.lua:17: attempt to concatenate local 'accName' (a boolean value) it's flying mode car i made it by my self s_fly.lua 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) c._fly.lua 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("zekafly", toggleCarFlight) meta file <meta> <info author="zeka" type="script" version="1.1.0" description="Flying Admins" /> <script src="s_fly.lua" type="client" /> <script src="c_fly.lua" type="server" /> </meta> please tell me how to solve this problem Link to comment
Administrators Lpsd Posted August 28, 2017 Administrators Share Posted August 28, 2017 I assume this is the line the error is happening on (hard to tell since you have removed some of the code) local accName = getAccountName(getPlayerAccount(source)) source isn't returning a valid player element. You should read the Wiki for command handlers. https://wiki.multitheftauto.com/wiki/AddCommandHandler function toggleCarFlight(playerSource) local accName = getAccountName(getPlayerAccount(playerSource)) end addCommandHandler("zekafly", toggleCarFlight) Link to comment
MohamedZeka Posted August 28, 2017 Author Share Posted August 28, 2017 i'm new to mta i'm not coder or like that i don't under stand Link to comment
Administrators Lpsd Posted August 29, 2017 Administrators Share Posted August 29, 2017 That's exactly why I gave you the solution and linked to more information on the Wiki If you are new to coding entirely you really should do yourself a favour and take some tutorials on basic computer science or general programming. This will give you an overview of how pretty much every programming language works (but don't get confused, it won't tell you how to code in all programming langauges, just the inner workings / behind the scenes) - ie data types, logical constructs, etc. After that, you can move on-to a basic Lua tutorial (https://www.tutorialspoint.com/lua/) and MTA Lua introduction (https://wiki.multitheftauto.com/wiki/Scripting_Introduction) 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