hackermagus Posted November 21, 2019 Share Posted November 21, 2019 (edited) When I hit a marker I want to Display "GG" in the chat. I have got a resource which is a garage system that will have a marker. I write this code: Marker = createMarker(1702.7998046875, -1079.2001953125, 22.89999961853, "cylinder", 2, 0, 0, 255) local myMarker = createMarker(1702.7998046875, -1079.2001953125, 22.89999961853, 'cylinder', 2.0, 0, 0, 255, 150) function MarkerHit( Element, matchingDimension ) triggerClientEvent ( "onMarkerHit", getRootElement()) outputChatBox("GG") end addEventHandler( "onMarkerHit", Marker, MarkerHit ) And when I go to the marker I created, nothing happened. But when I go to the garage system marker, that works. And the marker position in this code is not the same as the garage system marker. Please help!! Edited November 21, 2019 by hackermagus Link to comment
ReZurrecti0n Posted November 21, 2019 Share Posted November 21, 2019 Line 2, after "cylinder" you put 2.0 instead of just 2 as the size, that might be your issue Link to comment
hackermagus Posted November 21, 2019 Author Share Posted November 21, 2019 15 minutes ago, ReZurrecti0n said: Line 2, after "cylinder" you put 2.0 instead of just 2 as the size, that might be your issue Not working.. Link to comment
ReZurrecti0n Posted November 21, 2019 Share Posted November 21, 2019 You should always try to pin point the problem by adding output messages everywhere. Or prints, but anyway, try putting a output right after the createmarker so you know that was successfully made, then another message right before TriggerClientEvent… Wait, I don't even think you need the TriggerClientEvent line, that would keep looping forever... Try commenting out that line and see if it works Link to comment
ReZurrecti0n Posted November 21, 2019 Share Posted November 21, 2019 (edited) Marker = createMarker(1702.7998046875, -1079.2001953125, 22.89999961853, "cylinder", 2, 0, 0, 255) -- Global variable for a marker (Probably should be local) local myMarker = createMarker(1702.7998046875, -1079.2001953125, 22.89999961853, 'cylinder', 2.0, 0, 0, 255, 150) -- Locl variable for a marker function MarkerHit( Element, matchingDimension )-- The function, notice the arugments as it will be useful (Element is whatever hits the marker, a player) -- triggerClientEvent ( "onMarkerHit", getRootElement())-- This will call MarkerHit, but we already triggered MarkerHit, so this is an infinite loop outputChatBox("GG",Element)-- This is our goal... By adding the Element argument, sends the message ONLY to the player that hit the marker end -- Ends the function, easy enough addEventHandler( "onMarkerHit", getRootElement(), MarkerHit )-- Defines that MTA-SA's onMarkerHit will be the function MarkerHit, had to change this too... It will take some time, but you must learn in general how coding/scripting is done, try to understand what every line is doing. Use the MTA-SA Wiki for Events, Functions and such. Lua is the language MTA SA uses, will need to learn how the language operates too. Remember, baby steps Edited November 21, 2019 by ReZurrecti0n Bugs? 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