Search the Community
Showing results for tags 'destroyelement'.
-
Im working on a script wich create flames on the Thrusters of a vehicle (Mammoth Thruster of GTA Online), works well if you are the only that has a Thruster, but if someone also has a Thruster and gets out the vehicle, your Thruster will keep the attached elements and will not destroy the flames if you get out of the vehicle: Here is a video of what is happening: https://www.youtube.com/watch?v=Q3z9fdnBG0w and serverside and clientside scripts that are involved Serverside: (Functions for creating the flames) function LightOn(vehicle, x, y, z) if thePlayer ~= localPlayer then return end light = createMarker ( x , y , z, "corona", 0.5, 255, 160, 0, 170 ) attachElements(light, vehicle, 0, -0.3, -0.8) end addEvent("lighton", true) addEventHandler("lighton", getRootElement(), LightOn) function LightOff() if thePlayer ~= localPlayer then return end if light then destroyElement(light) end end addEvent("lightoff", true) addEventHandler("lightoff", getRootElement(), LightOff) function ThrustersOn(vehicle, x, y, z) if thePlayer ~= localPlayer then return end superhitbox = createObject (3471, x , y , z) setElementAlpha(superhitbox, 0) firethrustl = createObject (2031, x , y , z) firethrustr = createObject (2031, x , y , z) attachElements(superhitbox, vehicle, 0, -10, -1) attachElements(firethrustl, vehicle, 0.47, -0.4, -0.2) attachElements(firethrustr, vehicle, -0.47, -0.4, -0.2) setElementCollisionsEnabled(firethrustl, false) setElementCollisionsEnabled(firethrustr, false) end addEvent("thrusterson", true) addEventHandler("thrusterson", getRootElement(), ThrustersOn) function ThrustersOff() if thePlayer ~= localPlayer then return end if not firethrustl then return end destroyElement(firethrustl) destroyElement(firethrustr) end addEvent("thrustersoff", true) addEventHandler("thrustersoff", getRootElement(), ThrustersOff) Clientside: (Functions that triggers serverside events when you are in the Thruster) Thruster = 465 function SitOnThruster(thePlayer) if thePlayer ~= localPlayer then return end local vehicle = getPedOccupiedVehicle(localPlayer) if ( vehicle and getElementModel (vehicle) == Thruster ) then bindKey("vehicle_fire", "down", shootProjectile) triggerServerEvent ( "onthruster", resourceRoot) local x, y, z = getElementPosition(vehicle) local h, m = getTime() triggerServerEvent("thrusterson", getRootElement(), vehicle, x, y, z) if h > 20 then triggerServerEvent("lighton", getRootElement(), vehicle, x, y, z) else return end end end addEventHandler ( "onClientVehicleEnter", root, SitOnThruster ) function Notsit(thePlayer) if thePlayer ~= localPlayer then return end if Thruster then triggerServerEvent("thrustersoff", getRootElement(), vehicle, x, y, z) triggerServerEvent("lightoff", getRootElement(), vehicle, x, y, z) else return end end addEventHandler ( "onClientVehicleExit", root, Notsit ) function killed() if Thruster then if (isPedInVehicle(localPlayer) and Cars[getElementModel(getPedOccupiedVehicle(localPlayer))]) then if getPedOccupiedVehicleSeat ( localPlayer ) == 1 then return end triggerServerEvent("thrustersoff", getRootElement(), vehicle, x, y, z) triggerServerEvent("lightoff", getRootElement(), vehicle, x, y, z) else return end end end addEventHandler ( "onClientPlayerWasted", localPlayer, killed ) function shootProjectile() if not disparado then local vehicle = getPedOccupiedVehicle(localPlayer) if ( vehicle and getElementModel (vehicle) == Thruster ) then if isVehicleOnGround(vehicle) == false then local x, y, z = getElementPosition(vehicle) projectile = createProjectile(vehicle, 15, x, y+4, z-10) disparado = true setTimer ( function() disparado = false end, 1500, 1 ) else local x, y, z = getElementPosition(vehicle) createProjectile(vehicle, 15, x, y, z-3) disparado = true setTimer ( function() disparado = false end, 1500, 1 ) end end end end I'm very confused, i'm trying to make the script only create element for each player.
- 2 replies
-
- destroyelement
- problem
-
(and 6 more)
Tagged with:
-
Hello ! I recently made a weapon that shoots explosives. I thought about adding an object in the form of decoration using the bone attach resource. Everything go well until I realized that , when the player dies, the object stayed stuck and was not destroyed. Here you have the code function activArmas( player ) if (getElementData (player, "Armactivada") == false) then setElementData (player, "Armactivada", true) outputChatBox( "Activaste el arma", player, 100, 0, 0 ) else setElementData (player, "Armactivada", false) outputChatBox( "Desactivaste el arma", player, 100, 0, 0 ) end end addCommandHandler("activar", activArmas) local frascote = {} function setObjectInWeapon( previousWeaponID, currentWeaponID ) if (getElementData (source, "Armactivada") == true) then if ( currentWeaponID == 31 ) then exports.bone_attach:attachElementToBone(frascote[source],source,12,-0.09,0,-0.03,0,2,40) elseif ( previousWeaponID == 31 ) then exports.bone_attach:detachElementFromBone( frascote[source] ) destroyElement( frascote[source] ) end end end addEventHandler("onPlayerWeaponSwitch", root, setObjectInWeapon) function wast() if (getElementData (source, "Armactivada") == true) then destroyElement( frascote[source] ) --Here i have my problem. end end addEventHandler("onPlayerWasted", root, wast) Sorry for repost the topic but the spanish community is not than active . Thanks a lot !
-
¡ Hola ! hace poco hice un arma que dispara explosivos. Pensé en agregarle un objeto en forma de decoración usando el resource bone attach. Todo fue bien hasta que me di cuenta que, cuando el jugador moría, el objeto se quedaba pegado y no se destruía. Acá tienen el código function activArmas( player ) if (getElementData (player, "Armactivada") == false) then setElementData (player, "Armactivada", true) outputChatBox( "Activaste el arma", player, 100, 0, 0 ) else setElementData (player, "Armactivada", false) outputChatBox( "Desactivaste el arma", player, 100, 0, 0 ) end end addCommandHandler("activar", activArmas) local frascote = {} function setObjectInWeapon( previousWeaponID, currentWeaponID ) if (getElementData (source, "Armactivada") == true) then if ( currentWeaponID == 31 ) then exports.bone_attach:attachElementToBone(frascote[source],source,12,-0.09,0,-0.03,0,2,40) elseif ( previousWeaponID == 31 ) then exports.bone_attach:detachElementFromBone( frascote[source] ) destroyElement( frascote[source] ) end end end addEventHandler("onPlayerWeaponSwitch", root, setObjectInWeapon) function wast() if (getElementData (source, "Armactivada") == true) then destroyElement( frascote[source] ) --Acá es donde tengo mi duda. end end addEventHandler("onPlayerWasted", root, wast) Muchas gracias
-
I have the ambition to write all the missions from GTA SA on the MTA server for two people, but I can not write scripts very well yet. What I was able to write is that after entering the server, a bike appears with marker [where the first mission in SA]. Now I wanted after entering the bike, the marker disappeared. Here are my scraps that absolutely do not work. Could someone give me a helpfull hand? meta.xml <meta> <info author="Barti" title="missions" version="0.1"/> <script src="missions.lua" type="server"/> <cop>true</cop> </meta> missions.lua local x1, y1, z1, rx1, ry1, rz1 = 2243.2, -1263.2, 23.5, 0, 0, 270 -- I set the coordinates of the vehicle's spawn addEventHandler ( "onPlayerJoin", getRootElement(),function() local Bike = createVehicle ( 481, 0, 0, 0 ) -- set the type of vehicle setVehicleColor( Bike, 88,142,110 ) -- set the color spawnVehicle( Bike, x1, y1, z1, rx1, ry1, rz1) local spawnVeh = spawnVehicle ( Bike, x1, y1, z1, rx1, ry1, rz1 ) -- spawns the vehicle local xb1, yb1, zb1 = getElementPosition ( Bike ) -- taking the vehicle's coordinates local theMarker = createMarker ( xb1, yb1, zb1, "arrow", 0.4, 255, 255, 0, 170 ) -- create a marker over the vehicle attachElements ( theMarker, Bike, 0, 0, 1.5 ) -- that is attached to it local driver = getVehicleOccupant (source) -- wanted to read if someone is sitting on the bike if driver then -- and if he is sitting destroyElement(element theMarker) -- destroy the marker end end)
-
Olá, tenho este script que funciona perfeitamente em server local, sem bugs nem erros e sem lag. Porém, se eu uso ele em servidor na host, com vários jogadores online. Ele causa um lag absurdo que chega até a causar Network Trouble toda vez que ele faz a limpeza do mapa. O problema é que ele gera erros nada a ver e não consigo descobrir o motivo: Linha: 29 Bad argument @ 'destroyElement' [Expected element at argument 1] Linha: 10 Bad argument @ 'getVehicleOccupant' [Expected vehicle at argument 1] Linha: 11 Bad argument @ 'getVehicleOccupant' [Expected vehicle at argument 1] Linha: 12 Bad argument @ 'getVehicleOccupant' [Expected vehicle at argument 1] Linha: 13 Bad argument @ 'getVehicleOccupant' [Expected vehicle at argument 1] Linha: 14 Bad argument @ 'getVehicleOccupant' [Expected vehicle at argument 1] Linha: 15 Bad argument @ 'getVehicleOccupant' [Expected vehicle at argument 1] Linha: 16 Bad argument @ 'getVehicleOccupant' [Expected vehicle at argument 1] Linha: 17 Bad argument @ 'getVehicleOccupant' [Expected vehicle at argument 1] Linha: 18 Bad argument @ 'getVehicleOccupant' [Expected vehicle at argument 1] Obs: Se eu coloco um verificador antes disso, ele não faz nada e não deleta nenhum veículo. O que pode estar ocorrendo?
-
Hello there, I've been having some trouble with the DestroyElement function. (destroyHydraGun function, line 42-51) The rest of the script works fine. An uzi is created when a player enters a Hydra, but it doesn't seem to destroy the uzi when a player exits the vehicle. What am I doing wrong? function hydraFunctions() -- ignore this function local vehicle = getPedOccupiedVehicle(localPlayer) if(vehicle)then if getElementModel(vehicle) == 520 then outputChatBox ("Hydra guns installed") toggleControl ( "accelerate", true ) toggleControl ( "brake_reverse", true ) toggleControl ( "vehicle_secondary_fire", false ) toggleControl ( "vehicle_fire", false ) setControlState ( "special_control_up", true) toggleControl ( "special_control_down", false) local x, y, z = getElementPosition(vehicle) local weapon = createWeapon("uzi", x, y, z) attachElements ( weapon, vehicle, 0, 4, 1, 0, 0, 90) end end end addEventHandler ( "onClientPlayerVehicleEnter", getLocalPlayer(), hydraFunctions ) function hydraFiring() -- ignore this function local vehicle = getPedOccupiedVehicle(localPlayer) if(vehicle)then if getElementModel(vehicle) == 520 then setWeaponClipAmmo(weapon, 500) setWeaponFiringRate(weapon, 90) setWeaponState(weapon, "firing") outputChatBox ("guns activated") end end end function hydraStopping() -- ignore this function local vehicle = getPedOccupiedVehicle(localPlayer) if(vehicle)then if getElementModel(vehicle) == 520 then setWeaponState(weapon, "ready") outputChatBox ("guns deactivated") end end end function destroyHydraGun -- This function doesn't work local vehicle = getPedOccupiedVehicle(localPlayer) if(vehicle)then if getElementModel(vehicle) == 520 then local attached = getElementAttachedTo (vehicle) if ( attached ) then destroyElement ( weapon ) end end addEventHandler("onClientPlayerVehicleExit", getLocalPlayer(), destroyHydraGun ) bindKey("mouse1", "down", hydraFiring) bindKey("mouse1", "up", hydraStopping) bindKey("lctrl", "down", hydraFiring) bindKey("lctrl", "up", hydraStopping)