mtamaster97 Posted January 15, 2015 Share Posted January 15, 2015 This is the whole code but idk why I get error 2 line = expected account at argument 1 got nil 4 line = expected element at argument 1 got nil 7 line = expected ped at argument 1 got nil accName = getAccountName (account) -- get his account name me = getRootElement() account = getPlayerAccount(source) --local admin = isObjectInACLGroup ( "user."..getAccountName ( getPlayerAccount ( source ) ), aclGetGroup ( "Admin" ) ) mass = 100000 veh = getPedOccupiedVehicle (ped) --local oldmass = getVehicleHandlingProperty ( element, "mass" ) function show(msg) outputChatBox(msg,source, 0,81,255,true) end function turnOn(player, cmd, option) if option == "yes" then function babaking_tankYes ( me ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) and veh then bindKey ( me, "handbrake" or "space", "both", function(key,state) if state == "down" then setVehicleHandling ( veh, "mass", mass ) setVehicleHandling ( veh, "brakeDeceleration", mass ) show(tostring(getVehicleHandlingProperty ( element, "mass" ))) elseif state == "up" then setVehiceHandling (veh, "mass", true) setVehicleHandling ( veh, "brakeDeceleration", true ) show(tostring(getVehicleHandlingProperty ( element, "mass" ))) end end) addEventHandler ( "onResourceStart", getRootElement(), babaking_tankYes ) elseif not veh then return false end end elseif option == "no" then function babaking_tankNo ( me ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) and veh then bindKey ( me, "handbrake", "both", function(key,state) if state == "down" then setVehicleHandling ( veh, "mass", true ) show(tostring(getVehicleHandlingProperty ( element, "mass" ))) elseif state == "up" then setVehiceHandling (veh, "mass", true) show(tostring(getVehicleHandlingProperty ( element, "mass" ))) end end) addEventHandler ( "onResourceStart", getRootElement(), babaking_tankNo ) elseif not veh then return false end end else return false end end addCommandHandler("fpskickon", turnOn) function getVehicleHandlingProperty ( element, property ) if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then local handlingTable = getVehicleHandling ( element ) local value = handlingTable[property] if value then return value end end return false end Link to comment
Et-win Posted January 15, 2015 Share Posted January 15, 2015 Where is 'account' defined? 'getPlayerAccount(source)' 'source' is not defined or where else is it? 'getPedOccupiedVehicle(ped)' 'ped' is not defined or where else is it? Link to comment
Dealman Posted January 15, 2015 Share Posted January 15, 2015 Nil means the variables you're referring to have nothing - they're nil, null, void, empty. You will have to define the variables you use at the top of the script. Link to comment
mtamaster97 Posted January 15, 2015 Author Share Posted January 15, 2015 (edited) ik whats nil lol, but aren't "source","thePlayer","player","ped" already defined at MTA Source codes? thats the whole script there I tryed this too but doesn't work accName = getAccountName (source) -- get his account name source = getAccountPlayer(theAccount) account = getPlayerAccount(source) --local admin = isObjectInACLGroup ( "user."..getAccountName ( getPlayerAccount ( source ) ), aclGetGroup ( "Admin" ) ) mass = 100000 veh = getPedOccupiedVehicle (ped) --local oldmass = getVehicleHandlingProperty ( element, "mass" ) any hint? which function should I use to define source ? Edited January 15, 2015 by Guest Link to comment
Et-win Posted January 15, 2015 Share Posted January 15, 2015 ...I advise you to read the tutorials first. Link to comment
mtamaster97 Posted January 15, 2015 Author Share Posted January 15, 2015 Man but atleast explain me what is wrong there? I don't see any mistake , i replaced source in 1,3 lines with "player" element and still don''t work I don't see any forking Idea why it shouldn't work not logic man I made few small scripts and I'm not totally noob at scripting, but idk whats wrong with this.. just tell me if u know Link to comment
Moderators Citizen Posted January 15, 2015 Moderators Share Posted January 15, 2015 I'm not totally noob at scripting, but idk whats wrong with this.. just tell me if u know Yes you are ! as you didn't understand that predefined variable like client and source are only available into functions that are handlers for events and that the value of source is different depending on the event it is handling. You asked again to tell you what is wrong so here is your answer: - You are trying to use undefined variables as arguments (source, theAccount and I can see ped aswell) You are obviously not understanding what you are doing so read and follow the tutorials from the wiki first: https://wiki.multitheftauto.com/wiki/Scr ... troduction Here is a working example I could make from your code: function changeMass(thePlayer, cmd, newMass) local account = getPlayerAccount(thePlayer) -- get his account local accName = getAccountName(account) -- get his account name local isAdmin = isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) if isAdmin then local veh = getPedOccupiedVehicle(thePlayer) if veh then local oldMass= getVehicleHandlingProperty (veh, "mass") setVehicleHandling(veh, "mass", tonumber(newMass)) outputChatBox("The mass of the car changed from "..oldMass.." to "..newMass..".", thePlayer, 0, 200, 0) else outputChatBox("You must be in a car first !", thePlayer, 200, 0, 0) end else outputChatBox("You are not allowed to use this command !", thePlayer, 200, 0, 0) end end addCommandHandler("changeMass", changeMass, false, false) Use /changeMass 20 to set the vehicle's mass to 20. 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