Overkillz Posted January 24, 2019 Share Posted January 24, 2019 Hello dear community. Yesterday I've got an problem with the triggers that I really dont know why it is not working properly. When I try to do a trigger to the event: ontestRegisterE It doesn't execute the function: whateverFunctionName -- ##EVENTS PART function addingEvent() addEvent( "ontestRegisterE", true ) end addingEvent() function addingEventHandler() addEventHandler( "ontestRegisterE",getRootElement(), whateverFunctionName ) end -- ## FUNCTION PART function whateverFunctionName() outputChatBox("The Trigger Should work") end --## TRIGGER RECEIVED function triggerFromServer() outputDebugString("Trigger Received") addingEventHandler() end addEvent("onGetTriggerFromServer", true) addEventHandler("onGetTriggerFromServer", root, triggerFromServer) onGetTriggerFromServer is working correctly. I get the outputDebugString Message and it should start addingEventHandler() but when I try to do a trigger to ontestRegisterE it doesn't work. I don't want to do the following method function whateverFunctionName() outputChatBox("The Trigger Should work") end addEvent( "ontestRegisterE", true ) addEventHandler( "ontestRegisterE",getRootElement(), whateverFunctionName ) I hope you can help me, thanks. Regards. Link to comment
Moderators IIYAMA Posted January 24, 2019 Moderators Share Posted January 24, 2019 Hmm, is your timing correct? (When is the second event being called) Is the eventName correct? Your test events are not correctly camelcase named, which might be correct named on serverside. ontest > onTest And how do you trigger? 1 Link to comment
Overkillz Posted January 24, 2019 Author Share Posted January 24, 2019 2 hours ago, IIYAMA said: Hmm, is your timing correct? (When is the second event being called) Is the eventName correct? Your test events are not correctly camelcase named, which might be correct named on serverside. ontest > onTest And how do you trigger? Yes it is. This is how I run everything --## Lobby.lua function joinArena(arenaNo) if tonumber(arenaNo) == 1 then triggerServerEvent ( "onPlayerJoinArena", localPlayer, 1 ) end end bindKey("1","down",joinArena) --## Server.lua room[thisArena].joinArena = function (arenaNo) -- ## <-- room table and thisArena are defined if arenaNo ~= thisArena then return end triggerClientEvent(source, "onClientRoomJoin", source, thisArena) end addEvent("onServerRoomJoin",true) addEventHandler("onServerRoomJoin",getRootElement(),room[thisArena].joinArena) --## Client.lua function addingEvent() addEvent( "ontestRegisterE", true ) end addingEvent() function addingEventHandler() addEventHandler( "ontestRegisterE",getRootElement(), whateverFunctionName ) end function whateverFunctionName() outputChatBox("The Trigger Should work") end addEvent("onClientRoomJoin", true) addEventHandler("onClientRoomJoin", root, function(arenaNo) if arenaNo ~= thisArena then return end addingEventHandler() outputChatBox("Succesfully joined at the room ") end) -- ##TRIGGER FROM THE OTHER RESOURCE triggerClientEvent(source,"ontestRegisterE",source) And I said before. If I use the following method instead the previous one, the code works function whateverFunctionName() outputChatBox("The Trigger Should work") end addEvent( "ontestRegisterE", true ) addEventHandler( "ontestRegisterE",getRootElement(), whateverFunctionName ) I hope u can help me. Thanks. Regards. Link to comment
Dimos7 Posted January 24, 2019 Share Posted January 24, 2019 You can't use server side and client side to a file Link to comment
Overkillz Posted January 24, 2019 Author Share Posted January 24, 2019 9 minutes ago, Dimos7 said: You can't use server side and client side to a file ????? Am I using it ? Please, read the whole topic before answering. Link to comment
Dimos7 Posted January 24, 2019 Share Posted January 24, 2019 38 minutes ago, Overkillz said: ????? Am I using it ? Please, read the whole topic before answering. I read it Link to comment
Moderators IIYAMA Posted January 24, 2019 Moderators Share Posted January 24, 2019 1 hour ago, Overkillz said: triggerClientEvent(source,"ontestRegisterE",source) As it is now, the code triggers immediately while loading the resource and source is not defined. 1 Link to comment
Overkillz Posted January 24, 2019 Author Share Posted January 24, 2019 (edited) 9 minutes ago, IIYAMA said: As it is now, the code triggers immediately while loading the resource and source is not defined. It is function getMapSettings() triggerClientEvent(source,"ontestRegisterE",source) end addEvent("onRequestMapSettings",true) addEventHandler("onRequestMapSettings",root,getMapSettings) The script is triggered correctly when I use the following method but I won't use it due to I have other goals with it. function whateverFunctionName() outputChatBox("The Trigger Should work") end addEvent( "ontestRegisterE", true ) addEventHandler( "ontestRegisterE",getRootElement(), whateverFunctionName ) Edited January 24, 2019 by Overkillz Link to comment
Moderators IIYAMA Posted January 24, 2019 Moderators Share Posted January 24, 2019 iprint(source) Did you debug it? 1 Link to comment
Overkillz Posted January 24, 2019 Author Share Posted January 24, 2019 Problem fixed. For a weird reason one of the scripts wan't restarting and the changes weren't being applied. Anyways thanks for ur help. It was a f**** mistake by me. Around a f**** day looking for the error but now it is solved. Thanks and regards. 1 Link to comment
Moderators IIYAMA Posted January 24, 2019 Moderators Share Posted January 24, 2019 (edited) 2 hours ago, Overkillz said: Problem fixed. For a weird reason one of the scripts wan't restarting and the changes weren't being applied. Anyways thanks for ur help. It was a f**** mistake by me. Around a f**** day looking for the error but now it is solved. Thanks and regards. Sometimes by just adding a random debug line in your code, it can reveal not updated code. Edited January 24, 2019 by IIYAMA 1 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