Tails Posted August 5, 2012 Share Posted August 5, 2012 (edited) 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 August 5, 2012 by Guest Link to comment
codeluaeveryday Posted August 5, 2012 Share Posted August 5, 2012 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
Castillo Posted August 5, 2012 Share Posted August 5, 2012 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
Tails Posted August 5, 2012 Author Share Posted August 5, 2012 Thanks guys. Solidsnake14, in what gamemode did you test the script? I edited my first post and put in the lua script that I use as my gamemode. I tested it in that, the blips are working but the markers are not. Link to comment
Castillo Posted August 5, 2012 Share Posted August 5, 2012 I went to the marker and it worked, the game mode is not something that could cause it not to work. Link to comment
Tails Posted August 5, 2012 Author Share Posted August 5, 2012 Did you see an arrow by the door? Because I can't see anything. Link to comment
Castillo Posted August 5, 2012 Share Posted August 5, 2012 No door, I just seen the arrow floating in air. Link to comment
Tails Posted August 5, 2012 Author Share Posted August 5, 2012 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
Castillo Posted August 5, 2012 Share Posted August 5, 2012 The effect could be done via scripting, but I don't know how hard would it be. To "teleport" to an interior you must use: setElementInterior Link to comment
Tails Posted August 5, 2012 Author Share Posted August 5, 2012 Thanks, that was rather easy, however I cannot see markers inside an interior. How do I do that? Edit: I tried setting the marker using the setElementInterior command but that didn't really work. Link to comment
Castillo Posted August 5, 2012 Share Posted August 5, 2012 You must set the marker interior as well. Link to comment
Tails Posted August 5, 2012 Author Share Posted August 5, 2012 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
Castillo Posted August 5, 2012 Share Posted August 5, 2012 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
Tails Posted August 5, 2012 Author Share Posted August 5, 2012 Thank you very much Solidsnake14! Link to comment
Tails Posted August 5, 2012 Author Share Posted August 5, 2012 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
Castillo Posted August 5, 2012 Share Posted August 5, 2012 -- 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
Tails Posted August 5, 2012 Author Share Posted August 5, 2012 That didn't work, it broke the teleport ! haha Link to comment
Castillo Posted August 5, 2012 Share Posted August 5, 2012 Yeah, I'd a typo, copy the code again. Link to comment
Tails Posted August 5, 2012 Author Share Posted August 5, 2012 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
Castillo Posted August 5, 2012 Share Posted August 5, 2012 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
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