TorNix~|nR Posted July 9, 2016 Posted July 9, 2016 (edited) hello everyone, I have an admin panel, I can spawn vehicles, but there is a problem spawn of vehicles I need when onPlayerWasted or onPlayerQuit the vehicle get destroyed, any help please? Edited July 9, 2016 by Guest ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003
TorNix~|nR Posted July 9, 2016 Author Posted July 9, 2016 (edited) --giveVehicle addEvent("AdminPanel.giveVehicle", true) function giveVehicle(plr, getText) outputChatBox("#FF0000" ..getPlayerName(source).."#00FF00 Te ha dado un Vehiculo #0B00FF("..getText..") ", plr, r, g, b, true) outputChatBox("#00FF00Has dado a #FF0000" ..getPlayerName(plr).."#00FF00 Un Vehiculo #0B00FF(" ..getText..") ", source, r, g, b, true) if (not isElement(plr)) then return end if (isPedInVehicle(plr)) then outputChatBox("#00FF00Ya en un vehiculo", source, 225, 0, 0) else local veh local x, y, z = getElementPosition(plr) local rx, ry, rz = getElementRotation(plr) if (getVehicleModelFromName(getText)) then veh = createVehicle(getVehicleModelFromName(getText), x, y, z + 3) else veh = createVehicle(getText, x, y, z + 3) end if (veh) then warpPedIntoVehicle(plr, veh) setElementRotation(veh, 0, 0, rz) end end end addEventHandler("AdminPanel.giveVehicle", root, giveVehicle) Edited July 9, 2016 by Guest ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003
Captain Cody Posted July 9, 2016 Posted July 9, 2016 --giveVehicle addEvent("AdminPanel.giveVehicle", true) function giveVehicle(plr, getText) outputChatBox("#FF0000" ..getPlayerName(source).."#00FF00 Te ha dado un Vehiculo #0B00FF("..getText..") ", plr, r, g, b, true) outputChatBox("#00FF00Has dado a #FF0000" ..getPlayerName(plr).."#00FF00 Un Vehiculo #0B00FF(" ..getText..") ", source, r, g, b, true) if (not isElement(plr)) then return end if (isPedInVehicle(plr)) then outputChatBox("#00FF00Ya en un vehiculo", source, 225, 0, 0) else local veh local x, y, z = getElementPosition(plr) local rx, ry, rz = getElementRotation(plr) if (getVehicleModelFromName(getText)) then veh = createVehicle(getVehicleModelFromName(getText), x, y, z + 3) setElementData(veh,"spawner",plr) else veh = createVehicle(getText, x, y, z + 3) setElementData(veh,"spawner",plr) end if (veh) then warpPedIntoVehicle(plr, veh) setElementRotation(veh, 0, 0, rz) end end end addEventHandler("AdminPanel.giveVehicle", root, giveVehicle) function removeVeh() for i,v in pairs(getElementsByType("vehicle",resourceRoot) do if getElementData(v,"spawner") == source then destroyElement(v) end end end addEventHandler ( "onPlayerWasted", getRootElement(), removeVeh ) addEventHandler ( "onPlayerQuit", getRootElement(), removeVeh )
TorNix~|nR Posted July 9, 2016 Author Posted July 9, 2016 you have a problem for i,v in pairs(getElementsByType("vehicle",resourceRoot) do changed to for i,v in pairs(getElementsByType("vehicle",resourceRoot)) do done, I fix it, worked fine, thanks ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003
Captain Cody Posted July 9, 2016 Posted July 9, 2016 Oh sorry, that's because notePad++ Corrects that to a single ), always forget to fix it.
TorNix~|nR Posted July 9, 2016 Author Posted July 9, 2016 , no problem, thanks so much CodyL ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003
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