DouglaS666 Posted June 9, 2018 Share Posted June 9, 2018 server.lua:73: Bad argument @ 'destroyElement' [Expected element at argument 1] function showPanel(thePlayer) accountname = getAccountName(getPlayerAccount(thePlayer)) if isObjectInACLGroup("user." .. accountname, aclGetGroup("Painel-R7")) then triggerClientEvent(thePlayer, "R7", getRootElement()) else end end function onResStart() for index, player in ipairs(getElementsByType("player")) do bindKey(player, "z", "down", showPanel) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onResStart) function onPlayerJoin() bindKey(source, "z", "down", showPanel) end addEventHandler("onPlayerJoin", getRootElement(), onPlayerJoin) function cleanAll(player) for index, player in ipairs(getElementsByType("player")) do unbindKey(player, "z", "down", showPanel) end end addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), cleanAll) veh = {} function criarxx() if veh[source] and isElement( veh[source] ) then destroyElement( veh[source] ) veh[source] = nil end local x,y,z = getElementPosition(source) veh[source] = createVehicle(579, x,y,z + 2) warpPedIntoVehicle (source,veh[source]) end addEvent("carror7",true) addEventHandler("carror7",root,criarxx) function arm () giveWeapon( source, 24, 9999, true ) giveWeapon( source, 8, 9999, true ) giveWeapon( source, 27, 9999, true ) giveWeapon( source, 31, 9999, true ) giveWeapon( source, 29, 50, true ) giveWeapon( source, 33, 9999, true ) end addEvent("armar7",true) addEventHandler ( "armar7", getRootElement(), arm ) function arm2 () giveWeapon( source, 4, 9999, true ) giveWeapon( source, 22, 9999, true ) giveWeapon( source, 26, 9999, true ) giveWeapon( source, 32, 9999, true ) giveWeapon( source, 31, 9999, true ) giveWeapon( source, 34, 9999, true ) giveWeapon( source, 46, 1, true ) end addEvent("armar72",true) addEventHandler ( "armar72", getRootElement(), arm2 ) function skin () setPedSkin ( source, 106 ) end addEvent("skinsr7",true) addEventHandler ( "skinsr7", getRootElement(), skin ) function skin2 () setPedSkin ( source, 58 ) end addEvent("skinsr72",true) addEventHandler ( "skinsr72", getRootElement(), skin2 ) function destrui () destroyElement ( veh[source] ) end addEvent ("destroir7", true) addEventHandler ("destroir7", getRootElement(), destrui) addEventHandler ("onPlayerLogout", root, destrui) addEventHandler ("onPlayerQuit", root, destrui) addEventHandler ("onPlayerWasted", root, destrui) function vidacoleter7 () setPedArmor ( source, 100 ) setElementHealth( source, 200 ) end addEvent("vidaecoleter7",true) addEventHandler ( "vidaecoleter7", getRootElement(), vidacoleter7 ) Link to comment
DNL291 Posted June 9, 2018 Share Posted June 9, 2018 function destrui () if veh[source] and isElement(veh[source]) then -- verifica se o elemento existe na tabela destroyElement ( veh[source] ) end end 2 Link to comment
Other Languages Moderators Lord Henry Posted June 9, 2018 Other Languages Moderators Share Posted June 9, 2018 13 hours ago, DNL291 said: function destrui () if veh[source] and isElement(veh[source]) then -- verifica se o elemento existe na tabela destroyElement ( veh[source] ) end end Recomenda-se anular a variável após destruir o elemento dela. Para desocupar o espaço na memória. function destrui () if veh[source] and isElement(veh[source]) then destroyElement ( veh[source] ) veh[source] = nil end end 1 Link to comment
DNL291 Posted June 9, 2018 Share Posted June 9, 2018 6 hours ago, Lord Henry said: Recomenda-se anular a variável após destruir o elemento dela. Para desocupar o espaço na memória. function destrui () if veh[source] and isElement(veh[source]) then destroyElement ( veh[source] ) veh[source] = nil end end Exatamente. Tinha esquecido de colocar no código. 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