bartje01 Posted August 6, 2010 Share Posted August 6, 2010 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
Castillo Posted August 7, 2010 Share Posted August 7, 2010 First put your code into [lua][/lua] tags Link to comment
dzek (varez) Posted August 7, 2010 Share Posted August 7, 2010 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
bartje01 Posted August 7, 2010 Author Share Posted August 7, 2010 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
dzek (varez) Posted August 7, 2010 Share Posted August 7, 2010 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
dzek (varez) Posted August 7, 2010 Share Posted August 7, 2010 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
bartje01 Posted August 7, 2010 Author Share Posted August 7, 2010 Thaknyou :D:D It works fine now I will also use the other things you told me like debugging. Thanks in regards. Btw. is it hard to make this things client side? SO I can use it with GUI Link to comment
blas95 Posted August 7, 2010 Share Posted August 7, 2010 onResourceStart >> onClientResourceStart outputChatBox("Welcome to My Server", thePlayer) >> outputChatBox("Welcome to My Server") Link to comment
AeroXbird Posted August 7, 2010 Share Posted August 7, 2010 It impossible to make this clientside, except for the resourceStart function, but it would be useless to make that clientsided. Link to comment
bartje01 Posted August 7, 2010 Author Share Posted August 7, 2010 But what when I want a gui menu shows up when someone steps in the marker? Link to comment
Castillo Posted August 7, 2010 Share Posted August 7, 2010 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
50p Posted August 7, 2010 Share Posted August 7, 2010 I don't get it If you don't get it, you need to read wiki more. Link to comment
bartje01 Posted August 7, 2010 Author Share Posted August 7, 2010 I readed wiki days long -_-' Link to comment
50p Posted August 7, 2010 Share Posted August 7, 2010 I readed wiki days long -_-' Keep reading. Link to comment
50p Posted August 7, 2010 Share Posted August 7, 2010 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
bartje01 Posted August 7, 2010 Author Share Posted August 7, 2010 So with reading the wiki time after time I can be a pro scripter? Link to comment
dzek (varez) Posted August 7, 2010 Share Posted August 7, 2010 if you really want to learn - yes, with no problem, you just need some time 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