Jump to content

add/removeEventHandler


#Paper

Recommended Posts

Just the text doesn't changes to "Random" when new map starts:

function onMapStart() 
g_dxGUI.nextmapdisplay:text("Next Map: Random") 
removeEventHandler("onGamemodeMapStart", getRootElement(), onMapStart) 
end 
  
addEvent("onNextMapSet", true) 
function setNextMapText(theText) 
g_dxGUI.nextmapdisplay:text("Next Map: "..theText) 
addEventHandler("onGamemodeMapStart", getRootElement(), onMapStart) 
end 
addEventHandler("onNextMapSet", getRootElement(), setNextMapText) 

Link to comment

Mhh, no sry, same problem

Another Problem:

The function is like not triggered, nothing happens:

addEvent("onPlayerPickUpRacePickup", true) 
function disableGhostmode() 
if info == "Destruction derby" then 
if pickupType == "vehiclechange" then  
if vehicleModel == 425 then  
outputChatBox("* Hunter Reached! Ghostmode will be diasbled in 10 seconds!", getRootElement(), 35, 107, 142) 
setTimer(gmoff, 100000, 1) 
end 
end 
end 
end 
addEventHandler("onPlayerPickUpRacePickup",getRootElement(),disableGhostmode) 

Link to comment

first one: not enough info. like where is your event triggered, is theText defined, what's the debug output?

second: read my previous post. you forgot all of the event handler arguments:

function disableGhostmode() 

Link to comment

ye, i inserted these parameters, but nothing.

the event for pickup is triggere from recevoting_server.lua when someone sets nextmap, i inserted that trigger

triggerClientEvent("onNextMapSet", getRootElement(), getMapName(map)) 

Link to comment

first: i'm not sure if onGamemodeMapStart event is available clientside.

second:

addEvent("onPlayerPickUpRacePickup", true) 
function disableGhostmode(_, pickupType, vehicleModel) 
  if pickupType == "vehiclechange" and vehicleModel == "425" then 
    outputChatBox("* Hunter Reached! Ghostmode will be diasbled in 10 seconds!", getRootElement(), 35, 107, 142) 
    setTimer(gmoff, 100000, 1) 
  end 
end 
addEventHandler("onPlayerPickUpRacePickup",getRootElement(),disableGhostmode) 

also 100000ms is not 10 seconds, it's 100 seconds.

Link to comment
also 100000ms is not 10 seconds, it's 100 seconds.

Oh, my bad... :D ty

first: i'm not sure if onGamemodeMapStart event is available clientside.

Maybe onClientGamemodeMapStart? In the resource catalougue @ Mapmanager it isn't wroten if it's just for SS... :S

Link to comment
  • Discord Moderators

getMapName returns the current server map in a string, not whatever map parsed. I'm not sure if you know this already, but it doesn't seem like it on this piece you posted:

triggerClientEvent("onNextMapSet", getRootElement(), getMapName(map)) 

It won't break anything, but I'm not sure if it produces the output you want (if setMapName is called after that trigger it most likely wont)

Maybe onClientGamemodeMapStart? In the resource catalougue @ Mapmanager it isn't wroten if it's just for SS... :S

There isn't any clientside for the mapmanager by default, so you'll have to script one to get "onClientGamemodeMapStart"

An easy solution would be to place code similar to this in mapmanager_main.lua:

addEventHandler ('onGamemodeMapStart', root, 
    function (res) 
        local txt = getResourceName (res) 
        if txt then 
            triggerClientEvent ('onClientGamemodeMapStart', root, txt) 
        end 
    end 
) 

and create a clientside file where you do the text stuff.

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