PhantomNL Posted September 21, 2013 Share Posted September 21, 2013 Hi, I've got this script, and it worked fine, until yesterday, it doesn't respawn the exploded vehicles anymore.. This is the script: function respawnExplodedVehicle() setTimer( respawnExplodedVehicle, 5000, 1, source ) end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle) And this is the script without any changes (it will give errors in the console when it's this, the problem is at line 2): function respawnVehicle() setTimer( respawnVehicle, 5000, 1, source ) end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle) This is the error if it's the second one: [gameplay]/vehiclerespawn/explode.lua:2 Bad 'element' pointer @ 'respawnVehicle'(1) So I don't know what to do now since my knowledge for .lua is not that good, however this might be a simple problem.. Thanks Link to comment
EstrategiaGTA Posted September 21, 2013 Share Posted September 21, 2013 Is the script server-side? Post your meta.xml, and also you named your function with a MTA function name: change it. Link to comment
TAPL Posted September 21, 2013 Share Posted September 21, 2013 This is the wiki example as you want it. function respawnExplodedVehicle() setTimer(respawnVehicle, 5000, 1, source) end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle) https://wiki.multitheftauto.com/wiki/RespawnVehicle Link to comment
PhantomNL Posted September 21, 2013 Author Share Posted September 21, 2013 This is the wiki example as you want it. function respawnExplodedVehicle() setTimer(respawnVehicle, 5000, 1, source) end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle) https://wiki.multitheftauto.com/wiki/RespawnVehicle Still the same error man, sorry: WARNING: [gameplay]/vehiclerespawn/explode.lua:2 Bad 'element' pointer @ 'respawnVehicle'(1) Link to comment
PhantomNL Posted September 21, 2013 Author Share Posted September 21, 2013 Is the script server-side? Post your meta.xml, and also you named your function with a MTA function name: change it. Yeah man it's server side, I don't know what you mean with "you also named your function with a MTA function name: change it." Link to comment
TAPL Posted September 21, 2013 Share Posted September 21, 2013 This is the wiki example as you want it. function respawnExplodedVehicle() setTimer(respawnVehicle, 5000, 1, source) end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle) https://wiki.multitheftauto.com/wiki/RespawnVehicle Still the same error man, sorry: WARNING: [gameplay]/vehiclerespawn/explode.lua:2 Bad 'element' pointer @ 'respawnVehicle'(1) Impossible, you must have something else destroyed the vehicle before it respawned. What happen to the vehicle after it exploded? Link to comment
PhantomNL Posted September 21, 2013 Author Share Posted September 21, 2013 The exploded vehicle (black leftovers) just disappear, no vehicle coming back at the place, what do you mean with "you must have something else destroyed the vehicle before it respawned?" I just start the resource, search for a car, shoot it down, let it explode, and wait.. I also tried to switch gamemodes, doesn't work. Link to comment
Moderators IIYAMA Posted September 21, 2013 Moderators Share Posted September 21, 2013 you put it serverside? Link to comment
PhantomNL Posted September 21, 2013 Author Share Posted September 21, 2013 you put it serverside? Yes. Link to comment
TAPL Posted September 21, 2013 Share Posted September 21, 2013 The exploded vehicle (black leftovers) just disappear, no vehicle coming back at the place, what do you mean with "you must have something else destroyed the vehicle before it respawned?"I just start the resource, search for a car, shoot it down, let it explode, and wait.. I also tried to switch gamemodes, doesn't work. Exactly, the exploded vehicles does not disappear by default, you have other script destroyed the vehicle and that why it did not respawn and show you the error. Link to comment
PhantomNL Posted September 22, 2013 Author Share Posted September 22, 2013 The exploded vehicle (black leftovers) just disappear, no vehicle coming back at the place, what do you mean with "you must have something else destroyed the vehicle before it respawned?"I just start the resource, search for a car, shoot it down, let it explode, and wait.. I also tried to switch gamemodes, doesn't work. Exactly, the exploded vehicles does not disappear by default, you have other script destroyed the vehicle and that why it did not respawn and show you the error. Then I think this script does that, it's a vehicle script so people can buy cars and spawn their cars whenever they want (server side lua of the script): carShopMarker = createMarker (2133.59,-1149.29, 23.3, "cylinder", 3, 255, 0, 0, 127) carShopMarker2 = createMarker (562, -1270, 16, "cylinder", 2, 255, 0, 0, 127) carShopMarker3 = createMarker (-1954,299,34,"cylinder",2,255,0,0,127) carShopMarker4 = createMarker (-1663,1208,6,"cylinder",2,255,0,0,127) carShopMarker5 = createMarker (1946,2068,10,"cylinder",2,255,0,0,127) createBlipAttachedTo(carShopMarker,55,2,0,255,0,0,0,200) createBlipAttachedTo(carShopMarker2,55,2,0,255,0,0,0,200) createBlipAttachedTo(carShopMarker3,55,2,0,255,0,0,0,200) createBlipAttachedTo(carShopMarker4,55,2,0,255,0,0,0,200) createBlipAttachedTo(carShopMarker5,55,2,0,255,0,0,0,200) addEvent ("viewGUI", true) function markerHit (hitPlayer, matchingDimension) if (source == carShopMarker) or (source == carShopMarker2) or (source == carShopMarker3) or (source == carShopMarker4) or (source == carShopMarker5) then triggerClientEvent ("viewGUI", hitPlayer) end end addEventHandler ("onMarkerHit", getRootElement(), markerHit) addEvent ("carShopCarBuy", true) addEventHandler ("carShopCarBuy", getRootElement(), function(id, cost, name) if (getPlayerMoney (source) >= tonumber(cost)) then outputChatBox ("Bought a " .. name, source, 255, 0, 0, false) outputChatBox ("ID: " .. id, source, 255, 0, 0, false) outputChatBox ("Cost: " .. cost, source, 255, 0, 0, false) takePlayerMoney (source, tonumber (cost)) setAccountData (getPlayerAccount (source), "funmodev2-car", tonumber(id)) setAccountData (getPlayerAccount (source), "funmodev2-paintjob", 3) setAccountData (getPlayerAccount (source), "funmodev2-carupg", 0) else outputChatBox ("You are too poor!", source, 255, 0, 0, false) end end) addEvent ("carSpawn", true) addEvent ("carDestroy", true) function carSpawn () if not (isGuestAccount (getPlayerAccount (source))) and not (isPedInVehicle(source)) then if (getElementData (source, "hisCar")) and (getElementData (source, "hisCar") ~= nil) and (getElementType(getElementData (source, "hisCar")) == "vehicle") then if (getElementData (source, "carSpawnTime") > 0) then outputChatBox("Please wait "..tostring(getElementData(source, "carSpawnTime")).." seconds before you respawn your car.", source) return end if (getPlayerMoney (source) < 1000) then outputChatBox("You need to have atleast $1000 to spawn your car", source) return end setElementVelocity (getElementData (source, "hisCar"), 0,0,0) local x,y,z = getElementPosition (source) setVehicleRotation (getElementData (source, "hisCar"), 0, 0, 0) setElementPosition (getElementData (source, "hisCar"), x+2,y,z +1) outputChatBox ("Car spawned.", source, 255, 0, 0) setElementData (source, "carSpawnTime", 600) takePlayerMoney(source, 1000) elseif not (getElementData (source, "hisCar")) then local accountData = getAccountData (getPlayerAccount (source), "funmodev2-car") if (accountData) then if (getElementData (source, "carSpawnTime") > 0) then outputChatBox("Please wait "..tostring(getElementData(source, "carSpawnTime")).." seconds before you respawn your car.", source) return end if (getPlayerMoney (source) < 1000) then outputChatBox("You need to have atleast $1000 to spawn your car", source) return end carID = getAccountData (getPlayerAccount (source), "funmodev2-car") x,y,z = getElementPosition (source) vehicle = createVehicle (carID, x +2, y, z +1) setElementID (vehicle, getAccountName (getPlayerAccount(source))) setElementData (source, "hisCar", vehicle) outputChatBox ("Car spawned.", source, 255, 0, 0) setElementData (source, "carSpawnTime", 600) takePlayerMoney(source, 1000) if (getAccountData (getPlayerAccount(source), "funmodev2-carupg")) then local upgrades = nil local upgrades = {} local upgrades = getAccountData (getPlayerAccount(source), "funmodev2-carupg") for i,v in ipairs (upgrades) do addVehicleUpgrade (vehicle, v) end end if (getAccountData (getPlayerAccount(source), "funmodev2-paintjob")) then local paintjob = getAccountData (getPlayerAccount(source), "funmodev2-paintjob") setVehiclePaintjob (vehicle, paintjob) end if (getAccountData (getPlayerAccount(source), "funmodev2-carcolor1")) and (getAccountData (getPlayerAccount(source), "funmodev2-carcolor2")) then local c1 = getAccountData (getPlayerAccount(source), "funmodev2-carcolor1") local c2 = getAccountData (getPlayerAccount(source), "funmodev2-carcolor2") setVehicleColor (vehicle, c1,c2,0,0) end else outputChatBox ("You haven't got a car.", source, 255, 0, 0) end else outputChatBox ("You're already in a car!", source, 255, 0, 0) end end end addEventHandler ("carSpawn", getRootElement(), carSpawn) function carDestroy () if not (isGuestAccount (getPlayerAccount (source))) then if (isPedInVehicle (source)) then if (getElementID(getPedOccupiedVehicle(source)) == getAccountName (getPlayerAccount(source))) then setElementHealth (getElementData (source, "hisCar"), 0) destroyElement (getPedOccupiedVehicle (source)) removeElementData (source, "hisCar") outputChatBox ("Car Destroyed.", source, 255, 0, 0) else outputChatBox ("This not your car!", source, 255, 0, 0) end elseif (not (isPedInVehicle (source))) and (getElementData (source, "hisCar")) and (getElementData (source, "hisCar") ~= nil) then car=getElementData(source, "hisCar") destroyElement(car) outputChatBox ("Car Destroyed.", source, 255, 0, 0) removeElementData (source, "hisCar") end end end addEventHandler ("carDestroy", getRootElement(), carDestroy) function engineSwitch () if (isPedInVehicle (source)) then local veh = getPedOccupiedVehicle (source) if (getVehicleEngineState (veh) == true) then setVehicleEngineState (veh, false) outputChatBox ("Vehicle shutted down.", source, 255, 0, 0) elseif (getVehicleEngineState (veh) == false) then setVehicleEngineState (veh, true) outputChatBox ("Vehicle started.", source, 255, 0, 0) end else outputChatBox ("You aren't in a vehicle!", source, 255, 0, 0) end end addEvent("engenieSwitch",true) addEventHandler("engenieSwitch",getRootElement(),engineSwitch) function lightsSwitch () if (isPedInVehicle (source)) then local veh = getPedOccupiedVehicle (source) if (getVehicleOverrideLights(veh) ~= 2) then setVehicleOverrideLights(veh, 2) outputChatBox ("Vehicle lights turned on.", source, 255, 0, 0) elseif (getVehicleOverrideLights(veh) ~= 1) then setVehicleOverrideLights(veh, 1) outputChatBox ("Vehicle lights turned off.", source, 255, 0, 0) end else outputChatBox ("You aren't in a vehicle!", source, 255, 0, 0) end end addEvent("lightsSwitch",true) addEventHandler("lightsSwitch",getRootElement(),lightsSwitch) function lockSwitch () if (isPedInVehicle (source)) then local veh = getPedOccupiedVehicle (source) if not (isVehicleLocked (veh)) then setVehicleLocked (veh, true) setVehicleDoorsUndamageable (veh, true) setVehicleDoorState (veh, 0, 0) setVehicleDoorState (veh, 1, 0) setVehicleDoorState (veh, 2, 0) setVehicleDoorState (veh, 3, 0) outputChatBox ("Vehicle locked.", source, 255, 0, 0) elseif (isVehicleLocked (veh)) then setVehicleLocked (veh, false) setVehicleDoorsUndamageable (veh, false) outputChatBox ("Vehicle unlocked.", source, 255, 0, 0) end else outputChatBox ("You aren't in a vehicle!", source, 255, 0, 0) end end addEvent("lockSwitch",true) addEventHandler("lockSwitch",getRootElement(),lockSwitch ) addEventHandler ("onVehicleStartEnter", getRootElement(), function(player, seat, jacked, door) if (isVehicleLocked (source) == true) then local mannetjeNaam = getAccountName (getPlayerAccount (player)) local autoNaam = getElementID (source) if (mannetjeNaam == autoNaam) then setVehicleLocked (source, false) outputChatBox ("Vehicle unlocked!", player, 255, 0, 0, false) end end end) addEventHandler ("onVehicleExplode", getRootElement(), function() local theOwner = getAccountName (getPlayerAccount(getPlayerFromName (getElementID (source)))) if (theOwner) then removeElementData (theOwner, "hisCar") end end) addEventHandler ("onPlayerQuit", getRootElement(), function(quitType, reason, responsibleElement) if (getElementData (source, "hisCar")) then blowVehicle (getElementData (source, "hisCar")) removeElementData (source, "hisCar") end end) addEventHandler( "onResourceStop", getResourceRootElement( getThisResource() ), function () for i,v in ipairs (getElementsByType ("player")) do if (getElementData (v, "hisCar")) then setElementHealth (getElementData (v, "hisCar"), 0) removeElementData (v, "hisCar") end end end ) function destroyOnExplode () setTimer (destroyElement, 2500, 1, source) end addEventHandler ("onVehicleExplode", getRootElement(), destroyOnExplode) Thanks ALOT for helping me out! I removed that script, and now it works! Although now I need to figure out how to have both resources to run together I will come back here if I need help, but I'm gonna try myself first Again, thanks alot! PhantomNL Link to comment
TAPL Posted September 22, 2013 Share Posted September 22, 2013 From line 211 to line 214 you need to add IF statement to make sure that the vehicle that were exploded does not have an ElementID (empty string or false). You're welcome. Link to comment
PhantomNL Posted September 23, 2013 Author Share Posted September 23, 2013 I do know what you mean, but I have no idea where to exactly place the 'if' statement.. function destroyOnExplode () setTimer (destroyElement, 2500, 1, source) end addEventHandler ("onVehicleExplode", getRootElement(), destroyOnExplode) Link to comment
TAPL Posted September 23, 2013 Share Posted September 23, 2013 If you understand what i've said you should know the if statement should be above the timer. Link to comment
PhantomNL Posted September 25, 2013 Author Share Posted September 25, 2013 If you understand what i've said you should know the if statement should be above the timer. function destroyOnExplode () if setTimer (destroyElement, 2500, 1, source) end addEventHandler ("onVehicleExplode", getRootElement(), destroyOnExplode) Like this? By the way, I meant that I understood the part of the 'if' statement. 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