Jump to content

marker problem. Please help.


bartje01

Recommended Posts

Well I want that if you walk into a marker that it says:

You are in the pilot marker.

I tried but failed.

I have this:

pilotmarker = createMarker ( 1712.4139404297,1616.1068115234,9.130989074707, "cylinder",1.0)

at

onResourceStart

and then I have this:

addEventHandler ("onMarkerHit",getRootElement(),
function(player)
if (source == pilotmarker) then
outputChatBox("Failed to create vehicle.",player)
end
end)

And well. I see the small blue marker. But when I walk into it. just nothing happends

Please help

Thanks inregards

Link to comment

bettter add event handler attached only for that one marker, your script will be easier and.. faster :)

pilotmarker = -- create marker here
 
addEventHandler("onMarkerHit", pilotmarker, function()
--actions
end)

btw: debugscript /3 and outputDebugString should be your best friends

Link to comment

Well it didn;t worked yet. Thanks for helping by the way.

Is it better when I show you everything about it?

function load ( name )
pilot = createPed ( 61,1712.6456298828,1617.2902832031,10.063969612122)
setPedRotation ( pilot, 169.0)
pilotmarker = createMarker ( 1712.4139404297,1616.1068115234,9.130989074707, "cylinder",1.0)
end
addEventHandler ( "onResourceStart", getRootElement(), load )
 
 
 
 
addEventHandler("onMarkerHit", pilotmarker, function()
outputChatBox("Welcome to My Server", thePlayer)
end)

Sorry for the




			
		
Link to comment

btw one thing:

your resource will be creating new ped and marker when ANY resource starts..

https://wiki.multitheftauto.com/wiki/OnResourceStart

Important: If you attach this event to the root element it will called when any resource starts, not just the resource your script is running inside. As such, most of the time you will want to check that the resource passed to this event matches your resource (compare with the value returned by getThisResource) before doing anything. Alternatively you can attach the event to getResourceRootElement(getThisResource()).

ill check this code now

Link to comment

okay, the problem is you have to put event handler after marker is created, using onResourceStart looks like adding new thread, so you cant be sure if your marker will be created before or after adding onMarkerHit event.. do something like:

function load_ (name) -- i suggest not to use "load" as function name
outputDebugString("load_")
pilot = createPed (61,1712.6456298828,1617.2902832031,10.063969612122)
setPedRotation ( pilot, 169.0)
pilotmarker = createMarker ( 1712.4139404297,1616.1068115234,9.130989074707, "cylinder",1.5) -- its very hard to hit 1.0 marker.. i did it just once
 
addEventHandler("onMarkerHit", pilotmarker, function()
outputDebugString("hit pilot marker")
outputChatBox("Welcome to My Server", thePlayer)
end)
 
end
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), load_)

will be ok..

btw:

https://wiki.multitheftauto.com/wiki/Debugging

all your errors can be easly spotted:

http://i33.tinypic.com/nvcgif.png

Link to comment
But what when I want a gui menu shows up when someone steps in the marker?

u can use this function,

triggerClientEvent (source,"YOUR_CUSTOM_EVENT",source)

then in client side:

function showGUI()
guiSetVisible(YOUR_GUI_ELEMENT,true)
showCursor(true)
end
addEvent("YOUR_CUSTOM_EVENT", true)
addEventHandler("YOUR_CUSTOM_EVENT", getRootElement(), showGUI)

Link to comment

Wiki is the first place that you should visit when you need help. Remember that. I've never asked a question on this forum on how to script... All you need to do is spend loads of time reading. Practice makes perfect.

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