Jump to content

[ SOLVED ] DestroyElement


MrDante

Recommended Posts

Sorry my bad english :oops:

Guys is this, I'm kind of horrible mess with tables as there are always mistakes: lol:

So wanted to make the player caught the vehicle, typing the command / trabalharaqui, and goes toward another marker after getting it the vehicle destroys, but if two players, if you get to the marker, will destroy your and the other player ..

I'm debating about that a long time, someone could help?

local marker = createMarker (2211, -2506, 12.8, "cylinder", 1, 255,0,0,255) 
local mark2 = createMarker (667, -615, 16, "cylinder", 4, 255,0,0,255) 
local blip = createBlip(667, -615, 17, 0) 
createBlip (2211, -2506, 12.8, 51) 
setElementVisibleTo(mark2, root, false) 
setElementVisibleTo(blip, root, false) 
  
  
  
  
veh = {} 
  
function entrarmarker(Jogador) 
   if(isElement(Jogador)) and (getElementType(Jogador) == "player") then 
     if (not isPedInVehicle(Jogador)) then 
         if veh[Jogador] and isElement(veh[Jogador]) then 
            destroyElement(veh[Jogador]) 
            veh[Jogador] = nil 
         end 
         veh[Jogador] = createVehicle ( 408, 2200, -2509, 12.5 + 10 ) 
      end 
   end 
end 
addEventHandler("onMarkerHit", marker, entrarmarker) 
  
function commandMarker(Jogador) 
   if isElementWithinMarker(Jogador, marker) then 
      setElementData(Jogador, "trab", true) 
      
      warpPedIntoVehicle(Jogador, veh[Jogador]) 
      setElementVisibleTo(mark2, Jogador, true) 
      setElementVisibleTo(blip, Jogador, true) 
   end 
end 
addCommandHandler("trabalharaqui", commandMarker) 
  
function des (Jogador) 
    if(isElement(Jogador)) and (getElementType(Jogador) == "player") then 
      if getElementData(Jogador, "trab") then 
         if veh[Jogador] and isElement(veh[Jogador]) then 
            destroyElement (veh[Jogador]) 
         end 
         destroyElement(marker) 
         setElementVisibleTo(mark2, Jogador, false) 
         outputChatBox ( "#ff0000PARAB?NS VOC? TERMINOU A ENTREGA DE LIXO E GANHOU 500$ !", source, 255,255,255, true) 
         givePlayerMoney ( Jogador, 500) 
         removeElementData(Jogador, "trab") 
         setTimer(function() restartResource(getThisResource()) end, 100, 1) 
      end 
   end 
end 
addEventHandler( "onMarkerHit", mark2, des) 

And I'd like someone to explain, why create something on the table with the player element, you can use another name? example:

  
veh = {} 
  
veh["veiculo"] = createVehicle...; 
  

Edited by Guest
Link to comment
  
  
  
--1 - make tabel 
veh = {} 
veh["veiculo"] = {}  
  
  
--2 - add pLAYER TO TABEL 
veh["veiculo"][Player] = createVehicle... 
  
  
--3- for destroyElement 
if veh["veiculo"][Player] and isElement( veh["veiculo"][Player] ) then 
    destroyElement(veh["veiculo"][Player]) 
    veh["veiculo"][Player] = nil 
end 
  
  

Link to comment
  
  
  
--1 - make tabel 
veh = {} 
veh["veiculo"] = {}  
  
  
--2 - add pLAYER TO TABEL 
veh["veiculo"][Player] = createVehicle... 
  
  
--3- for destroyElement 
if veh["veiculo"][Player] and isElement( veh["veiculo"][Player] ) then 
    destroyElement(veh["veiculo"][Player]) 
    veh["veiculo"][Player] = nil 
end 
  
  

is not resolved :(

Link to comment
  
local marker = createMarker (2211, -2506, 12.8, "cylinder", 1, 255,0,0,255) 
local mark2 = createMarker (667, -615, 16, "cylinder", 4, 255,0,0,255) 
local blip = createBlip(667, -615, 17, 0) 
createBlip (2211, -2506, 12.8, 51) 
setElementVisibleTo(mark2, root, false) 
setElementVisibleTo(blip, root, false) 
  
  
  
  
veh = {} 
  
function entrarmarker(Jogador) 
   if(isElement(Jogador)) and (getElementType(Jogador) == "player") then 
      if veh[Jogador] and isElement(veh[Jogador]) then 
         destroyElement(veh[Jogador]) 
         veh[Jogador] = nil 
      end 
     if (not isPedInVehicle(Jogador)) then 
         veh[Jogador] = createVehicle ( 408, 2200, -2509, 12.5 + 10 ) 
         outputChatBox ( "#ff0000use  /trabalharaqui", Jogador, 255,255,255, true) 
      end 
   end 
end 
addEventHandler("onMarkerHit", marker, entrarmarker) 
  
function commandMarker(Jogador) 
   if isElementWithinMarker(Jogador, marker) then 
      setElementData(Jogador, "trab", true) 
      warpPedIntoVehicle(Jogador, veh[Jogador]) 
      setElementVisibleTo(mark2, Jogador, true) 
      setElementVisibleTo(blip, Jogador, true) 
   end 
end 
addCommandHandler("trabalharaqui", commandMarker) 
  
function des (Jogador) 
    if(isElement(Jogador)) and (getElementType(Jogador) == "player") then 
      if getElementData(Jogador, "trab") then 
         if veh[Jogador] and isElement(veh[Jogador]) then 
            destroyElement (veh[Jogador]) 
            veh[Jogador] = nil 
         end 
         ---destroyElement(marker) 
         setElementVisibleTo(marker, Jogador, false)          
         setElementVisibleTo(mark2, Jogador, false) 
         outputChatBox ( "#ff0000PARAB?NS VOC? TERMINOU A ENTREGA DE LIXO E GANHOU 500$ !", Jogador, 255,255,255, true) 
         givePlayerMoney ( Jogador, 500) 
         removeElementData(Jogador, "trab") 
         setTimer(function() restartResource(getThisResource()) end, 100, 1) 
      end 
   end 
end 
addEventHandler( "onMarkerHit", mark2, des) 
  
  

Link to comment
  
local marker = createMarker (2211, -2506, 12.8, "cylinder", 1, 255,0,0,255) 
local mark2 = createMarker (667, -615, 16, "cylinder", 4, 255,0,0,255) 
local blip = createBlip(667, -615, 17, 0) 
createBlip (2211, -2506, 12.8, 51) 
setElementVisibleTo(mark2, root, false) 
setElementVisibleTo(blip, root, false) 
  
  
  
  
veh = {} 
  
function entrarmarker(Jogador) 
   if(isElement(Jogador)) and (getElementType(Jogador) == "player") then 
      if veh[Jogador] and isElement(veh[Jogador]) then 
         destroyElement(veh[Jogador]) 
         veh[Jogador] = nil 
      end 
     if (not isPedInVehicle(Jogador)) then 
         veh[Jogador] = createVehicle ( 408, 2200, -2509, 12.5 + 10 ) 
         outputChatBox ( "#ff0000use  /trabalharaqui", Jogador, 255,255,255, true) 
      end 
   end 
end 
addEventHandler("onMarkerHit", marker, entrarmarker) 
  
function commandMarker(Jogador) 
   if isElementWithinMarker(Jogador, marker) then 
      setElementData(Jogador, "trab", true) 
      warpPedIntoVehicle(Jogador, veh[Jogador]) 
      setElementVisibleTo(mark2, Jogador, true) 
      setElementVisibleTo(blip, Jogador, true) 
   end 
end 
addCommandHandler("trabalharaqui", commandMarker) 
  
function des (Jogador) 
    if(isElement(Jogador)) and (getElementType(Jogador) == "player") then 
      if getElementData(Jogador, "trab") then 
         if veh[Jogador] and isElement(veh[Jogador]) then 
            destroyElement (veh[Jogador]) 
            veh[Jogador] = nil 
         end 
         ---destroyElement(marker) 
         setElementVisibleTo(marker, Jogador, false)          
         setElementVisibleTo(mark2, Jogador, false) 
         outputChatBox ( "#ff0000PARAB?NS VOC? TERMINOU A ENTREGA DE LIXO E GANHOU 500$ !", Jogador, 255,255,255, true) 
         givePlayerMoney ( Jogador, 500) 
         removeElementData(Jogador, "trab") 
         setTimer(function() restartResource(getThisResource()) end, 100, 1) 
      end 
   end 
end 
addEventHandler( "onMarkerHit", mark2, des) 
  
  

Friend, you edited a part that does not matter in this topic.

Link to comment

Sorry, but I did n't understand what you want !

why you use

  destroyElement(marker) 
  
  
  

use this

      setElementVisibleTo(marker, Jogador, false)   

this code for restart resource

  
         setTimer(function() restartResource(getThisResource()) end, 100, 1) 
  

why?

Link to comment
When two players enter, and go to the mark2 as a result was to destroy the vehicle of those in marker, but when two players, destroy the two vehicles

understood?

so, you need destroy two vehicles.

when tow player hit mark2?

not, it destroys, but it was only to destroy those who enter the marker, not everyone who took the vehicle

but already decided, the script is not mine, I tested because my friend was in trouble ..

I realize when, who was destroying was restartResource :lol::lol::lol::lol::lol::lol::lol:

I am a very sluggish person :lol::lol::lol::lol::lol::lol::lol:

Link to comment
When two players enter, and go to the mark2 as a result was to destroy the vehicle of those in marker, but when two players, destroy the two vehicles

understood?

so, you need destroy two vehicles.

when tow player hit mark2?

not, it destroys, but it was only to destroy those who enter the marker, not everyone who took the vehicle

but already decided, the script is not mine, I tested because my friend was in trouble ..

I realize when, who was destroying was restartResource :lol::lol::lol::lol::lol::lol::lol:

I am a very sluggish person :lol::lol::lol::lol::lol::lol::lol:

yes, I said why use restart :lol:

Link to comment

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...