Jump to content

Marker on spawned car


Recommended Posts

Hi sorry to bumb but i dont get how to get a text showing in the chatbox if u enter the marker

i tried this below but i cant seem to get the marker!

  
    function kickit() 
outputChatBox("Working!") 
end 
    addEventHandler("onMarkerHit", markers[source],kickit) 
  

Link to comment

Try this

function kickit(hitElement, matchingDimension) 
    if matchingDimension and isElement(hitElement) and getElementType(hitElement) == "player" then  
        outputChatBox("Working!",hitElement) 
    end 
end  
addEventHandler("onMarkerHit", markers[source],kickit) -- it must be inside the function 

Link to comment

Ok i tried to add the eventhandler in here ;

  
  
function attchMarkerToAllVehicle () 
    for i, vehicle in pairs(getElementsByType("vehicle")) do 
        if not markers[vehicle] then 
        local marker = createMarker( 0,0,0,"arrow",0.5,224,255,255,170) 
        attachElements ( marker, vehicle, -1.5, 0, 1 ) 
            markers[vehicle] = marker 
            addEventHandler("onMarkerHit", markers[source],kickit) -- it must be inside the function 
        end 
    end 
end 
setTimer(attchMarkerToAllVehicle,1000,0) 
  

but it isnt doing something

Link to comment

My whole code u mean?

here it is

  
  
local markers = {} 
  
function attchMarkerToAllVehicle () 
    for i, vehicle in pairs(getElementsByType("vehicle")) do 
        if not markers[vehicle] then 
        local marker = createMarker( 0,0,0,"arrow",0.5,224,255,255,170) 
        attachElements ( marker, vehicle, -1.5, 0, 1 ) 
            markers[vehicle] = marker 
            addEventHandler("onMarkerHit", markers[vehicle],kickit) 
        end 
    end 
end 
setTimer(attchMarkerToAllVehicle,1000,0) 
  
function destroyMarker() 
    if getElementType(source) == "vehicle" then 
        if markers[source] and isElement(markers[source]) then 
            destroyElement (markers[source]) 
             
        end 
    end 
end 
addEventHandler("onElementDestroy", getRootElement(),destroyMarker) 
  
  
function onResourceStart ( ) 
    local players = getElementsByType ( "player" ) -- Store all the players in the server into a table 
    for key, player in ipairs ( players ) do       -- for all the players in the table 
        setPlayerNametagShowing ( player, false )  -- turn off their nametag 
    end 
end 
addEventHandler ( "onResourceStart", resourceRoot, onResourceStart ) 
  
function onPlayerJoin ( ) 
      -- Whoever joins the server should also have their nametags deactivated 
    setPlayerNametagShowing ( source, false ) 
end 
addEventHandler ( "onPlayerJoin", root, onPlayerJoin ) 
  
function kickit(hitElement, matchingDimension) 
  --  if matchingDimension and isElement(hitElement) and getElementType(hitElement) == "player" then 
        outputChatBox("Working!",hitElement) 
end         
         
  
  

Link to comment

man why you edit my code

copy and past

local markers = {} 
  
function attchMarkerToAllVehicle () 
    for i, vehicle in pairs(getElementsByType("vehicle")) do 
        if not markers[vehicle] then 
        local marker = createMarker( 0,0,0,"arrow",0.5,224,255,255,170) 
            attachElements ( marker, vehicle, -1.5, 0, 1 ) 
            markers[vehicle] = marker 
            addEventHandler("onMarkerHit", markers[vehicle],kickit) 
        end 
    end 
end 
setTimer(attchMarkerToAllVehicle,1000,0) 
  
function destroyMarker() 
    if getElementType(source) == "vehicle" then 
        if markers[source] and isElement(markers[source]) then 
            destroyElement (markers[source]) 
            removeEventHandler("onMarkerHit", markers[source],kickit) 
        end 
    end 
end 
addEventHandler("onElementDestroy", getRootElement(),destroyMarker) 
  
  
function onResourceStart ( ) 
    local players = getElementsByType ( "player" ) -- Store all the players in the server into a table 
    for key, player in ipairs ( players ) do       -- for all the players in the table 
        setPlayerNametagShowing ( player, false )  -- turn off their nametag 
    end 
end 
addEventHandler ( "onResourceStart", resourceRoot, onResourceStart ) 
  
function onPlayerJoin ( ) 
    setPlayerNametagShowing ( source, false ) 
end 
addEventHandler ( "onPlayerJoin", root, onPlayerJoin ) 
  
function kickit(hitElement, matchingDimension) 
  if matchingDimension and isElement(hitElement) and getElementType(hitElement) == "player" then 
    outputChatBox("Working!",hitElement) 
end  

Link to comment
still not working after copy paste , some of my other scripts poped in too , i only removed the if matchingDimension to check if it was working then but now i tried to copy EXACTLY what you said now but it still didnt work

debugscript ??

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