Jump to content

Destroyelement


Xwad

Recommended Posts

Posted

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 ) 
  

Posted

Since destroyVehicleOfModel function isnt mta function you should create it by yourself

#include <iostream>

int main() {

    std::cout << "C++ is amazing <3" << std::endl;

    return 0;

}

I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please

Posted

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 ) 
  

Posted

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.

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted

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 ) 
  
  

#include <iostream>

int main() {

    std::cout << "C++ is amazing <3" << std::endl;

    return 0;

}

I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please

Posted

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:/

Posted
  
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 
  

#include <iostream>

int main() {

    std::cout << "C++ is amazing <3" << std::endl;

    return 0;

}

I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please

Posted

You're welcome :D

#include <iostream>

int main() {

    std::cout << "C++ is amazing <3" << std::endl;

    return 0;

}

I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...