Jump to content

Bug or what?


`Dmz

Recommended Posts

Posted

Hi, MTA community. I have one problem with server side event onMarkerHit, it doesn't works, but when I write similar script client-side, it works, so is it bug or scripting mistake?

vokJuodas = createMarker(197.1796875, 168.767578125, 1002.0234375, "cylinder", 1.5, 1, 1, 1)
setElementInterior(vokJuodas,3) 	
addEventHandler("onMarkerHit", vokJuodas, function ()
triggerClientEvent("vokPuolimas", getRootElement())
end)

Posted

It's a bug to me. It's been around since DP1. You should addEventHandler to root element (resource's root element is better) and make sure that the marker hit is the marker you created.

Posted

Maybe you can show me how because I haven't any idea how to do it, I tried it to do it with event onPlayerMarkerHit, but it was the same thing like with onMarkerHit event.

Posted
myMarker = createMarker( ......... )
addEventHandler( "onMarkerHit", getResourceRootElement(),
function( )
if ( source == myMarker ) then
-- You hit your marker, do whatever you want here
end
end
)

Posted

I don't works this is my code look maybe i did something wrong here? :|

indJuodas = createMarker(216.9921875, 79.0078125, 1004.0390625, "cylinder", 1.5, 1, 1, 1)
setElementInterior(indJuodas,6)
addEventHandler( "onMarkerHit", getResourceRootElement(),
function( )
if ( source == indJuodas ) then
outputChatBox("Boo")
end
end
)

Posted

Try this:

function markerHit( )
if ( source == indJuodas ) then
outputChatBox("Boo")
end
end
 
addEventHandler( "onRecourseStart", getResourceRootElement(),
function( )
       indJuodas = createMarker(216.9921875, 79.0078125, 1004.0390625, "cylinder", 1.5, 1, 1, 1)
setElementInterior(indJuodas,6)
addEventHandler( "onMarkerHit", this, markerHit )
end
)

Posted
indJuodas = createMarker(216.9921875, 79.0078125, 1004.0390625, "cylinder", 1.5, 1, 1, 1)
setElementInterior(indJuodas,6)
function markerHit()
if ( source == indJuodas ) then
outputChatBox("Boo")
end
end
addEventHandler ("onMarkerHit", getRootElement(), markerHit)

this should work

Posted
indJuodas = createMarker(216.9921875, 79.0078125, 1004.0390625, "cylinder", 1.5, 1, 1, 1)
setElementInterior(indJuodas,6)
function markerHit()
if ( source == indJuodas ) then
outputChatBox("Boo")
end
end
addEventHandler ("onMarkerHit", getRootElement(), markerHit)

this should work

No it don't works to.

Posted
are u sure? cause i tryed it and does it what it says, "Boo" that says when i enter in the marker.

the script its server-side

Yes this is server-side, but it don't works I don't lie. Maybe something wrong with my all script :?: but what then if it is.

Posted
Try this:
function markerHit( )
if ( source == indJuodas ) then
outputChatBox("Boo")
end
end
 
addEventHandler( "onRecourseStart", getResourceRootElement(),
function( )
       indJuodas = createMarker(216.9921875, 79.0078125, 1004.0390625, "cylinder", 1.5, 1, 1, 1)
setElementInterior(indJuodas,6)
addEventHandler( "onMarkerHit", this, markerHit )
end
)

This should work, but the variable this is not defined!

The code with the variable this defined

this = getResourceRootElement(getThisResource())
 
function markerHit( )
if ( source == indJuodas ) then
outputChatBox("Boo")
end
end
 
addEventHandler( "onRecourseStart", getResourceRootElement(),
function( )
       indJuodas = createMarker(216.9921875, 79.0078125, 1004.0390625, "cylinder", 1.5, 1, 1, 1)
setElementInterior(indJuodas,6)
addEventHandler( "onMarkerHit", this, markerHit )
end
)

Posted
Try this:
function markerHit( )
if ( source == indJuodas ) then
outputChatBox("Boo")
end
end
 
addEventHandler( "onRecourseStart", getResourceRootElement(),
function( )
       indJuodas = createMarker(216.9921875, 79.0078125, 1004.0390625, "cylinder", 1.5, 1, 1, 1)
setElementInterior(indJuodas,6)
addEventHandler( "onMarkerHit", this, markerHit )
end
)

This should work, but the variable this is not defined!

The code with the variable this defined

this = getResourceRootElement(getThisResource())
 
function markerHit( )
if ( source == indJuodas ) then
outputChatBox("Boo")
end
end
 
addEventHandler( "onRecourseStart", getResourceRootElement(),
function( )
       indJuodas = createMarker(216.9921875, 79.0078125, 1004.0390625, "cylinder", 1.5, 1, 1, 1)
setElementInterior(indJuodas,6)
addEventHandler( "onMarkerHit", this, markerHit )
end
)

You have to read wiki more often.

https://wiki.multitheftauto.com/wiki/AddEventHandler

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