Xwad Posted August 2, 2015 Share Posted August 2, 2015 Hi i made a script but its not working:/ The script is that if i enter the rustler(476) then the script will destroy the element(the rustler) in 5 sec and create a vehicle and warp me in that vehicle. debugscript: ERROR: shop/server.lua:54: attempt to call global 'destroyVehiclesOfModel' (a nil value) server.lua function timerKill (modelID) local USAteam = getTeamFromName("USA") if(getPlayerTeam ( localPlayer ) == USAteam) then local vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicles) do if (getElementModel(v) == modelID) then destroyElement(v) local x,y,z = getElementPosition(source) local vehicle = createVehicle(601,-2117.46, -2340.69, 100 + 3) warpPedIntoVehicle(source,vehicle) end end end end destroyVehiclesOfModel(476) setTimer ( timerKill, 5000, 1 ) Link to comment
darhal Posted August 2, 2015 Share Posted August 2, 2015 Since destroyVehicleOfModel function isnt mta function you should create it by yourself Link to comment
Xwad Posted August 2, 2015 Author Share Posted August 2, 2015 sry i dont understand that. What do you mean with create it by yourself? Maybe need i use destroyElement? Link to comment
Xwad Posted August 2, 2015 Author Share Posted August 2, 2015 i fixed the Destroyelemnt problem but now i have anbother problem.. After the vehicle is destroyed it must create and warp me i a vehicle but its not working:/ function vehicleExplode () if (getElementModel(source) == 476) then setTimer( destroyElement, 4000, 1, source) local x,y,z = getElementPosition(source) local vehicle = createVehicle(513,-2117.46, -2340.69, 100 + 3) warpPedIntoVehicle(source,vehicle) end end addEventHandler ( "onVehicleEnter", getRootElement(), vehicleExplode ) Link to comment
GTX Posted August 2, 2015 Share Posted August 2, 2015 Can you stop bumping the topic after 30 minutes? And a triple post? EDIT YOUR LAST POST. Why did you use onVehicleEnter? Delete it. Read wiki: warpPedIntoVehicle Attention: If you used setElementPosition to spawn the ped/player, this function will not work and returns false. Link to comment
Xwad Posted August 4, 2015 Author Share Posted August 4, 2015 why need i delete the event? Link to comment
darhal Posted August 4, 2015 Share Posted August 4, 2015 How you expect this to work you use the function warpPlayerIntoVehicle for warpping vehicle (source) to vehicle (that you create) TRY THIS : function vehicleExplode (plr) if (getElementModel(source) == 476) then setTimer( destroyElement, 4000, 1, source) local vehicle = createVehicle(513,-2117.46, -2340.69, 100 + 3) warpPedIntoVehicle(plr,vehicle) end end addEventHandler ( "onVehicleEnter", getRootElement(), vehicleExplode ) Link to comment
Xwad Posted August 4, 2015 Author Share Posted August 4, 2015 The problem is now that the script gives me the 513 vehicle immediately:/ I want to set the timer to the creatvehicle too not only for the destroyelemnt:/ Link to comment
darhal Posted August 4, 2015 Share Posted August 4, 2015 function vehicleExplode (plr) if (getElementModel(source) == 476) then setTimer( replaceVehicle, 4000, 1, source, plr) end end addEventHandler ( "onVehicleEnter", getRootElement(), vehicleExplode ) function replaceVehicle(veh, plr) destroyElement(veh) local vehicle = createVehicle(513,-2117.46, -2340.69, 100 + 3) warpPedIntoVehicle(plr,vehicle) end Link to comment
Xwad Posted August 4, 2015 Author Share Posted August 4, 2015 MY god i made the same script but when i made it then i didnt work now it works thanks!! 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