Jump to content

createMarker doesn't work


Tails

Recommended Posts

So this is what I have so far, a script for blips and markers for my gamemode.

The blips are working fine, but I can't seem to get the markers working. Any ideas on how to fix this?

Perhaps it is an issue with the gamemode I'm running, because they're no elements assigned?

rootElement = getRootElement() 
local myMarker = createMarker(-1374.29, 1019.93, 10.8, 'arrow', 1.75, 255, 136, 255, 100) 
  
-- markers 
function MarkerHit( thePlayer, matchingDimension ) 
    local elementType = getElementType( thePlayer ) 
    outputChatBox("You hit the marker", getRootElement(), 255,0,0 ) 
    givePlayerMoney(thePlayer, 5000) 
  
end 
addEventHandler( "onMarkerHit", myMarker, MarkerHit ) 
  
-- blips 
function blips() 
  
createBlip(1713.02, 917.98, 10.80, 27) -- mechanic 
createBlip(1381.99, 1019.81, 10.82, 51) -- store 
  
end 
  
addEventHandler("onResourceStart", rootElement, blips) 

Server lua:

local spawnX, spawnY, spawnZ = 1713.02, 917.98, 10.80 
function joinHandler() 
    spawnPlayer(source, spawnX, spawnY, spawnZ) 
    fadeCamera(source, true) 
    setCameraTarget(source, source) 
    setPedSkin ( source, 50 ) 
    outputChatBox("Welcome to My Server", source) 
end 
addEventHandler("onPlayerJoin", getRootElement(), joinHandler) 
  
-- retrieve a table with all flag elements 
local flagElements = getElementsByType ( "tdm" ) 
-- loop through them 
for key, value in pairs(flagElements) do 
    -- get our info 
    local posX = getElementData ( value, "posX" ) 
    local posY = getElementData ( value, "posY" ) 
    local posZ = getElementData ( value, "posZ" ) 
end 

Edited by Guest
Link to comment

I made this work for vehicles and players. It shouldnt matter much anyway if your using race.

Marker = createMarker(-1374.29, 1019.93, 10.8, 'arrow', 1.75, 255, 136, 255, 100) 
  
-- markers 
function MarkerHit(hitElem, matchingDimension ) 
    if getElementType(hitElem) == "player" then 
        outputChatBox("You hit the marker", hitElem, 255,0,0 ) 
        givePlayerMoney(hitElem, 5000) 
    else getElemntType(hitElem) == "vehicle" then 
        outputChatBox("You hit the marker", getVehicleOccupant(hitElem), 255,0,0 ) 
        givePlayerMoney(getVehicleOccupant(hitElem), 5000) 
    end 
end 
addEventHandler( "onMarkerHit", Marker, MarkerHit ) 
  
-- blips 
function blips() 
  
createBlip(1713.02, 917.98, 10.80, 27) -- mechanic 
createBlip(1381.99, 1019.81, 10.82, 51) -- store 
  
end 
  
addEventHandler("onResourceStart", rootElement, blips) 

Link to comment

Tails: Your script works, I hit the marker and I get message + the money, although, you should not create blips on every resource start.

-- blips 
function blips ( ) 
    createBlip ( 1713.02, 917.98, 10.80, 27 ) -- mechanic 
    createBlip ( 1381.99, 1019.81, 10.82, 51 ) -- store 
    myMarker = createMarker ( -1374.29, 1019.93, 10.8, 'arrow', 1.75, 255, 136, 255, 100 ) 
    addEventHandler ( "onMarkerHit", myMarker, MarkerHit ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, blips ) 
  
-- markers 
function MarkerHit ( thePlayer, matchingDimension ) 
    local elementType = getElementType ( thePlayer ) 
    if ( elementType == "player" ) then 
        outputChatBox ( "You hit the marker", thePlayer, 255,0,0 ) 
        givePlayerMoney ( thePlayer, 5000 ) 
    end 
end 

Link to comment

Ahh! That was really stupid from me, I put a - in front of the x coordinate. I thought it just wouldn't appear! Thanks anyway guys!

Edit: Any way to make the arrow float up and down like the regular gta door arrows? Or a little tut on how to make it teleport you to an interior and back.

Thanks in advance

Link to comment

Ok I got that working

Is there a more convenient way to the evenhandlers, = marks etc. in my script?

-- blips 
function blips ( ) 
    createBlip ( 1713.02, 917.98, 10.80, 27 ) -- mechanic 
    createBlip ( 1381.99, 1019.81, 10.82, 51 ) -- store 
    storeMarker = createMarker (1374.50, 1020, 12.5, 'arrow', 2.5, 255, 136, 0, 250 ) 
    mechMarker = createMarker (1713, 913, 12.0, 'arrow', 2.0, 255, 136, 0, 250 ) 
    mechMarkerBack = createMarker (2333.17, -1075.96, 1049.02, 'arrow', 2.0, 255, 136, 0, 250 ) 
    setElementInterior(mechMarkerBack, 6, 2333.17, -1075.96, 1049.02) 
    addEventHandler ( "onMarkerHit", storeMarker, MarkerHit ) 
    addEventHandler ( "onMarkerHit", mechMarker, MarkerTeleport ) 
    addEventHandler ( "onMarkerHit", mechMarkerBack, MarkerTeleportBack ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, blips ) 
  
-- markers 
-- storeMark 
function MarkerHit ( thePlayer, matchingDimension ) 
    local elementType = getElementType ( thePlayer ) 
    if ( elementType == "player" ) then 
        outputChatBox ( "You hit the marker", thePlayer, 255,0,0 ) 
        givePlayerMoney ( thePlayer, 5000 ) 
    end 
end 
-- mechMark 
function MarkerTeleport ( thePlayer, matchingDimension ) 
    local elementType = getElementType ( thePlayer ) 
    if ( elementType == "player" ) then 
        outputChatBox ( "You hit the marker", thePlayer, 255,0,0 ) 
        setElementInterior(thePlayer, 6, 2333.0330, -1073.9600, 1049.0230) 
    end 
end 
-- mechMark - LEAVE 
function MarkerTeleportBack ( thePlayer, matchingDimension ) 
    local elementType = getElementType ( thePlayer ) 
    if ( elementType == "player" ) then 
        outputChatBox ( "You hit the marker", thePlayer, 255,0,0 ) 
        setElementInterior(thePlayer, 0, 1713.02, 917.98, 10.80) 
    end 
end 

Link to comment

You can use this way:

-- blips 
function blips ( ) 
    createBlip ( 1713.02, 917.98, 10.80, 27 ) -- mechanic 
    createBlip ( 1381.99, 1019.81, 10.82, 51 ) -- store 
    storeMarker = createMarker ( 1374.50, 1020, 12.5, 'arrow', 2.5, 255, 136, 0, 250 ) 
    mechMarker = createMarker ( 1713, 913, 12.0, 'arrow', 2.0, 255, 136, 0, 250 ) 
    mechMarkerBack = createMarker ( 2333.17, -1075.96, 1049.02, 'arrow', 2.0, 255, 136, 0, 250 ) 
    setElementInterior ( mechMarkerBack, 6, 2333.17, -1075.96, 1049.02 ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, blips ) 
  
-- markers 
function MarkerHit ( thePlayer, matchingDimension ) 
    local elementType = getElementType ( thePlayer ) 
    if ( elementType == "player" ) then 
        if ( source == storeMarker ) then 
            outputChatBox ( "You hit the marker", thePlayer, 255,0,0 ) 
            givePlayerMoney ( thePlayer, 5000 ) 
        elseif ( source == mechMarker ) then 
            outputChatBox ( "You hit the marker", thePlayer, 255,0,0 ) 
            setElementInterior ( thePlayer, 6, 2333.0330, -1073.9600, 1049.0230 ) 
        elseif ( source == mechMarkerBack ) then 
            outputChatBox ( "You hit the marker", thePlayer, 255,0,0 ) 
            setElementInterior ( thePlayer, 0, 1713.02, 917.98, 10.80 ) 
        end 
    end 
end 
addEventHandler ( "onMarkerHit", root, MarkerHit ) 

Link to comment

How do I stop vehicles from triggering the setElementInterior ?

-- loool 
  
-- blips 
function blips ( ) 
    createBlip ( 1713.02, 917.98, 10.80, 27 ) -- mechanic 
    createBlip ( 1381.99, 1019.81, 10.82, 51 ) -- store 
    storeMarker = createMarker ( 1374.50, 1020, 12.5, 'arrow', 2.5, 72, 118, 255, 250 ) 
    mechMarker = createMarker ( 1713, 913, 12.0, 'arrow', 2.0, 72, 118, 255, 250 ) 
    mechMarkerBack = createMarker ( 2333.10, -1077.7, 1050.02, 'arrow', 2.0, 72, 118, 255, 250 ) 
    setElementInterior ( mechMarkerBack, 6) 
    gunInsideMech = createPickup (2342.25, -1063.91, 1049.02, 2, 22, 3000 ) -- Pistol inside mech house 
    setElementInterior ( gunInsideMech, 6) 
    armorInsideMech = createPickup (2340.25, -1063.91, 1049.02, 1, 100, 3000) -- Armor inside mech house 
    setElementInterior ( armorInsideMech, 6) 
end 
addEventHandler ( "onResourceStart", resourceRoot, blips ) 
  
-- markers 
function MarkerHit ( thePlayer, matchingDimension ) 
    local elementType = getElementType ( thePlayer ) 
    if ( elementType == "player" ) then 
        if ( source == storeMarker ) then 
            outputChatBox ( "You hit the marker", thePlayer, 255,0,0 ) 
            givePlayerMoney ( thePlayer, 5000 ) 
        elseif ( source == mechMarker ) then 
            outputChatBox ( "You entered the safe house.", thePlayer, 255,0,0 ) 
            setElementInterior ( thePlayer, 6, 2333.0330, -1073.9600, 1049.0230 ) 
        elseif ( source == mechMarkerBack ) then 
            outputChatBox ( "You left the safe house.", thePlayer, 255,0,0 ) 
            setElementInterior ( thePlayer, 0, 1713.02, 917.98, 10.80 ) 
        end 
    end 
end 
addEventHandler ( "onMarkerHit", root, MarkerHit ) 

Link to comment
-- loool 
  
-- blips 
function blips ( ) 
    createBlip ( 1713.02, 917.98, 10.80, 27 ) -- mechanic 
    createBlip ( 1381.99, 1019.81, 10.82, 51 ) -- store 
    storeMarker = createMarker ( 1374.50, 1020, 12.5, 'arrow', 2.5, 72, 118, 255, 250 ) 
    mechMarker = createMarker ( 1713, 913, 12.0, 'arrow', 2.0, 72, 118, 255, 250 ) 
    mechMarkerBack = createMarker ( 2333.10, -1077.7, 1050.02, 'arrow', 2.0, 72, 118, 255, 250 ) 
    setElementInterior ( mechMarkerBack, 6) 
    gunInsideMech = createPickup (2342.25, -1063.91, 1049.02, 2, 22, 3000 ) -- Pistol inside mech house 
    setElementInterior ( gunInsideMech, 6) 
    armorInsideMech = createPickup (2340.25, -1063.91, 1049.02, 1, 100, 3000) -- Armor inside mech house 
    setElementInterior ( armorInsideMech, 6) 
end 
addEventHandler ( "onResourceStart", resourceRoot, blips ) 
  
-- markers 
function MarkerHit ( thePlayer, matchingDimension ) 
    local elementType = getElementType ( thePlayer ) 
    if ( elementType == "player" and not isPedInVehicle ( thePlayer ) ) then 
        if ( source == storeMarker ) then 
            outputChatBox ( "You hit the marker", thePlayer, 255,0,0 ) 
            givePlayerMoney ( thePlayer, 5000 ) 
        elseif ( source == mechMarker ) then 
            outputChatBox ( "You entered the safe house.", thePlayer, 255,0,0 ) 
            setElementInterior ( thePlayer, 6, 2333.0330, -1073.9600, 1049.0230 ) 
        elseif ( source == mechMarkerBack ) then 
            outputChatBox ( "You left the safe house.", thePlayer, 255,0,0 ) 
            setElementInterior ( thePlayer, 0, 1713.02, 917.98, 10.80 ) 
        end 
    end 
end 
addEventHandler ( "onMarkerHit", root, MarkerHit ) 

Try that.

Link to comment

Thank you. Do you know if there is a way to put markers in the map via the editor? And if so how do I access them so I can edit its properties?

I've tried putting in spawn points using the TDM definition but it doesn't let me spawn on them.

Gamemode lua:

local spawnX, spawnY, spawnZ = 1713.02, 917.98, 10.80 
function joinHandler() 
    spawnPlayer(source, spawnX, spawnY, spawnZ) 
    fadeCamera(source, true) 
    setCameraTarget(source, source) 
    setPedSkin ( source, 50 ) 
    outputChatBox("Welcome to My Server", source) 
end 
addEventHandler("onPlayerJoin", getRootElement(), joinHandler) 
  
-- retrieve a table with all flag elements 
local flagElements = getElementsByType ( "tdm" ) 
-- loop through them 
for key, value in pairs(flagElements) do 
    -- get our info 
    local posX = getElementData ( value, "posX" ) 
    local posY = getElementData ( value, "posY" ) 
    local posZ = getElementData ( value, "posZ" ) 
end 

Link to comment

I don't understand what are you trying to do, but,

local flagElements = getElementsByType ( "tdm" ) 
-- loop through them 
for key, value in ipairs(flagElements) do 
    -- get our info 
    local posX = getElementData ( value, "posX" ) 
    local posY = getElementData ( value, "posY" ) 
    local posZ = getElementData ( value, "posZ" ) 
end 

That should be fine to get all 'tdm'.

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