Zuher Laith Posted November 4, 2017 Share Posted November 4, 2017 Hi I'm getting a error on debugscript each time I start the resource, Spoiler Error output: Quote [13:15:14] ERROR: Client (Zuher) triggered serverside event onPlayer(ResourceName)Start, but event is not added serverside Code: -- client side: function initGUI() triggerServerEvent( "vendInit", resourceRoot ); end addEventHandler( "onClientResourceStart", resourceRoot, initGUI ) -- server side function vendInit( ) -- code and stuff end addEvent( "vendInit", true ) addEventHandler( "vendInit", resourceRoot, vendInit ) could anyone explain to me the cause of this error ? Thanks for any help .. Link to comment
Storm-Hanma Posted November 4, 2017 Share Posted November 4, 2017 u need to add code in server side too ! Link to comment
Zuher Laith Posted November 4, 2017 Author Share Posted November 4, 2017 2 hours ago, Khadeer143 said: u need to add code in server side too ! explain what you mean ! Link to comment
quindo Posted November 4, 2017 Share Posted November 4, 2017 The event "onPlayer(ResourceName)Start" Isn't defined nor triggered anywhere in the snippet you posted. Link to comment
Zuher Laith Posted November 4, 2017 Author Share Posted November 4, 2017 26 minutes ago, quindo said: The event "onPlayer(ResourceName)Start" Isn't defined nor triggered anywhere in the snippet you posted. How is that possible?, I just used onClientResourceStart and passed the InitGUI function, nothing else Link to comment
quindo Posted November 4, 2017 Share Posted November 4, 2017 You are triggering vendInit event, which is added serverside, but the error seems to mention different event Link to comment
Zuher Laith Posted November 4, 2017 Author Share Posted November 4, 2017 27 minutes ago, quindo said: You are triggering vendInit event, which is added serverside, but the error seems to mention different event I don't think there is another event, the code I pasted is almost everything, so what's the matter ? Link to comment
Moderators IIYAMA Posted November 4, 2017 Moderators Share Posted November 4, 2017 A triggerServerEvent is used to communicate with the server. It is required that the event is added serverside before used. addEvent("onPlayer(ResourceName)Start", true) The addEvent function will make sure that the event is added. (serverside in your case) The first argument is the event name "onPlayer(ResourceName)Start". The second argument will enable events from a different side (client/server). If set to false you can't use triggerServerEvent/triggerClientEvent, only triggerEvent to activate it. For more information: https://wiki.multitheftauto.com/wiki/AddEvent 1 Link to comment
Zuher Laith Posted November 4, 2017 Author Share Posted November 4, 2017 14 minutes ago, IIYAMA said: A triggerServerEvent is used to communicate with the server. It is required that the event is added serverside before used. So basically each server file in my resource I triggerServerEvents from should include that line ? 1 Link to comment
Moderators IIYAMA Posted November 4, 2017 Moderators Share Posted November 4, 2017 nope, in at least one RESOURCE where you want to use it. It can be in any server file, but it doesn't have to be added multiple times, just one time. 1 Link to comment
Zuher Laith Posted November 4, 2017 Author Share Posted November 4, 2017 2 minutes ago, IIYAMA said: nope, in at least one RESOURCE where you want to use it. It can be in any server file, but it doesn't have to be added multiple times, just one time. Oh, so that's how it is ... Thank you so much for help ! 1 Link to comment
Moderators IIYAMA Posted November 4, 2017 Moderators Share Posted November 4, 2017 And I shouldn't forget to tell you that the resource must be running as well. Link to comment
Zuher Laith Posted November 4, 2017 Author Share Posted November 4, 2017 (edited) 3 minutes ago, IIYAMA said: And I shouldn't forget to tell you that the resource must be running as well. In case it happened in another resource I'll add it, Its ok right ? Edited November 4, 2017 by Zuher Laith 1 Link to comment
Moderators IIYAMA Posted November 4, 2017 Moderators Share Posted November 4, 2017 yes, but if you do that, you must make sure that the receiver resource is always running while using the other resource. 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