Jump to content

triggered serverside event onPlayer(resource)Start, but event is not added serverside


Zuher Laith

Recommended Posts

Posted

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

Posted
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

Posted
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 ?

  • Moderators
Posted

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

  • Thanks 1
Posted
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 ?

  • Like 1
  • Moderators
Posted

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.

  • Like 1
Posted
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 !

  • Like 1
Posted (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 by Zuher Laith
  • Like 1
  • Moderators
Posted

yes, but if you do that, you must make sure that the receiver resource is always running while using the other resource.

  • Thanks 1

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