Shuubaru Posted March 13, 2016 Share Posted March 13, 2016 (edited) Hi, I did a gui with a button to buy a full repair in-game, but i have a problem with this. When i press on the button i get this error on the debug: guibuyer_s.lua:2: Bad argument @ 'isPedInVehicle' [Expected ped at argument 1, got nil] and the vehicle do not fix. --clientside (not full code) function buyFRepair () triggerServerEvent ( "buyFRepair", getLocalPlayer()) end addEventHandler ( "onClientGUIClick", GUIEditor_Button[1], buyFRepair ) --serverside function buyFRepair(player) if isPedInVehicle(player) then local vehicle = getPedOccupiedVehicle(player) if onTakeMoney( player, infos.frepairPrice) then if vehicle then setElementHealth( vehicle,1000 ) outputChatBox("[FULL REPAIR] #FFFFFF"..getPlayerName(player).." #FFFFFFhas bought full repair. #B72A00-1600",root,_r,_g,_b,true) end else outputChatBox("[ERROR] #ffffffYou dont have enough cash!",player,255,0,0,true) end else outputConsole ( "You must be in a vehicle!",player,255,0,0,true) end end addEvent("buyFRepair",true) addEventHandler("buyFRepair",root,buyFRepair) what can I do to fix it? Sorry for my english. Edited March 13, 2016 by Guest Link to comment
KariiiM Posted March 13, 2016 Share Posted March 13, 2016 Try that, client side: function buyFRepair () triggerServerEvent ( "buyFRepair", getLocalPlayer(), getLocalPlayer()) end addEventHandler ( "onClientGUIClick", GUIEditor_Button[1], buyFRepair ) server side: function buyFRepair(player) if not player then return end if isPedInVehicle(player) then local vehicle = getPedOccupiedVehicle(player) if onTakeMoney( player, infos.frepairPrice) then if vehicle then setElementHealth( vehicle,1000 ) outputChatBox("[FULL REPAIR] #FFFFFF"..getPlayerName(player).." #FFFFFFhas bought full repair. #B72A00-1600",root,_r,_g,_b,true) end else outputChatBox("[ERROR] #ffffffYou dont have enough cash!",player,255,0,0,true) end else outputConsole ( "You must be in a vehicle!",player,255,0,0,true) end end addEvent("buyFRepair",true) addEventHandler("buyFRepair",root,buyFRepair) Link to comment
Shuubaru Posted March 13, 2016 Author Share Posted March 13, 2016 Try that,client side: function buyFRepair () triggerServerEvent ( "buyFRepair", getLocalPlayer(), getLocalPlayer()) end addEventHandler ( "onClientGUIClick", GUIEditor_Button[1], buyFRepair ) server side: function buyFRepair(player) if not player then return end if isPedInVehicle(player) then local vehicle = getPedOccupiedVehicle(player) if onTakeMoney( player, infos.frepairPrice) then if vehicle then setElementHealth( vehicle,1000 ) outputChatBox("[FULL REPAIR] #FFFFFF"..getPlayerName(player).." #FFFFFFhas bought full repair. #B72A00-1600",root,_r,_g,_b,true) end else outputChatBox("[ERROR] #ffffffYou dont have enough cash!",player,255,0,0,true) end else outputConsole ( "You must be in a vehicle!",player,255,0,0,true) end end addEvent("buyFRepair",true) addEventHandler("buyFRepair",root,buyFRepair) works, i love you <3 Link to comment
KariiiM Posted March 13, 2016 Share Posted March 13, 2016 works, i love you <3 Glad to help 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