Jump to content

Bug or what?


`Dmz

Recommended Posts

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)

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

Link to comment

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
)

Link to comment

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
)

Link to comment
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

Link to comment
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.

Link to comment
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.

Link to comment
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
)

Link to comment
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

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