nerfioner Posted December 2, 2014 Share Posted December 2, 2014 Hi, i wanted to make a script. when i sit in Savanna vehicle i press O and the script add a roof to my car and when i press it again it is delete it but my debugscript says that: tetoad.lua:2: bad argument @ 'isPedInVehicle' Thank you for help, i am a begginer function tetoad() if (isPedInVehicle(targetPlayer)) then if not(succes == nil) then setTimer(tetoveg, 5000, 1) else destroyElement(succes) end else outputChatBox("Rossz") end end function gomb() bindKey("p", "down", tetoad) end addEventHandler("onClientResourceStart", getRootElement(), gomb) function tetoveg() theVehicle = getPedOccupiedVehicle(targetPlayer) success = addVehicleUpgrade(theVehicle, 1131) end Link to comment
manawydan Posted December 2, 2014 Share Posted December 2, 2014 some errors(try change targetPlayer to localPlayer because you dont definity it) Link to comment
Ahmed Abo-elezz Posted December 2, 2014 Share Posted December 2, 2014 savana dont have allow to add roof so use this function attachElements and try ti use it (Condition) function addroof(thePlayer) if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then local veh = getElementModel ( source ) == 576 if veh then Link to comment
nerfioner Posted December 2, 2014 Author Share Posted December 2, 2014 i can't do it can you send me the full correct file i can not paste your version, i pasted it to somewhere and now tetoad.lua:2: bad argument @ 'getElementType' Link to comment
qaisjp Posted December 2, 2014 Share Posted December 2, 2014 Programming isn't just copy and paste. Please read Debugging. We will not fix your code for you unless you take the effort to understand the code you're modifying. tetoad.lua:2: bad argument @ 'isPedInVehicle' This means that in line 2, there is an error in the function isPedInVehicle. if (isPedInVehicle(targetPlayer)) then If you look carefully, there is no "targetPlayer" variable defined anywhere in your code, and this is confirmed because the debug output says that there is a bad argument. Since this is client side, you just need to rename all targetPlayer's to localPlayer. Link to comment
Ahmed Abo-elezz Posted December 2, 2014 Share Posted December 2, 2014 i can't do it can you send me the full correct file i can not paste your version, i pasted it to somewhere and now tetoad.lua:2: bad argument @ 'getElementType' i try to make it for you now Link to comment
undefined Posted December 3, 2014 Share Posted December 3, 2014 If the script on the client-side; Change targetPlayer to localPlayer or getLocalPlayer() If not; get first arguement(targetPlayer) on the function e.g: function tetoad(targetPlayer) -- Blablabla If you make this, i think it will work. 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