Stranger Posted April 25, 2014 Share Posted April 25, 2014 hello, i have a problem in this code: addEventHandler ("onClientGUIClick", root, function () if source == giv then row, co = guiGridListGetSelectedItem(pl) row2, co2 = guiGridListGetSelectedItem(ve) select = guiGridListGetItemText(pl, row, co) selectt = guiGridListGetItemText(ve, row2, co2) if select and select ~= "" and selectt ~= "" then local pla = getPlayerFromName(select) if pla then triggerServerEvent ("giveH", getVehicleModelFromName (selectt), pla) end end end end) server side: vehh = { } addEvent ("giveH", true) addEventHandler ("giveH", root, function (vehID, plr) if isElement (vehh[plr]) then destroyElement (vehh[plr]) vehh[plr] = nil end local x,y,z = getElementPosition (plr) vehh[plr] = createVehicle (vehID, x,y,z) warpPedIntoVehicle (plr, vehh[plr]) end) that when i click the button "give" the debug says: WARNING: test\server.lua:8: Bad argument @ 'createVehicle' [Expected number at argument 4, got nil] WARNING: test\server.lua:9: Bad argument @ 'warpPedIntoVehicle' so, help. Link to comment
Ab-47 Posted April 25, 2014 Share Posted April 25, 2014 Your code is really messy.. I think you should try again. Well heads up on this line: addEventHandler ("onClientGUIClick", root, function () root is a global variable, meaning whatever you click the function will be triggered even from another GUI. Bad Argument at line 9 is because the vehicle wasn't created, the vehicle wasn't created (Line 8 ) because, idk.. Just really tired to focus, it must be your table data, I think. Link to comment
Stranger Posted April 26, 2014 Author Share Posted April 26, 2014 I know that there is a problem in this code, so I came here to find a solution here, because I do not know where the error. Link to comment
-.Paradox.- Posted April 26, 2014 Share Posted April 26, 2014 Server addEvent("giveH",true) addEventHandler("giveH",root, function(plr, vehID) local player = getPlayerFromName(plr or "") local theCurrentVehicle = getPedOccupiedVehicle(player) if player and theCurrentVehicle then if vehID then destroyElement(theCurrentVehicle) local x,y,z = getElementPosition(player) local rx,ry,rz = getElementRotation(player) local vehicle = createVehicle(vehID,x,y,z,rx,ry,rz) warpPedIntoVehicle(player, vehicle) end end end) Link to comment
Stranger Posted April 27, 2014 Author Share Posted April 27, 2014 Thanks guys for the help, but i fixed, the problem was in the trigger. 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