Jump to content

Avoid debug error message from triggers


Recommended Posts

Hello dear community, I have a little question about triggers

First of all, I won't use the function getEventHandlers() or the event onDebugMessage to cancell the event.

Is there someway to avoid the typical message thats says: Server/Client triggered clientside/serverside EventName but event is not added if the script is not running. Im under an experimental script and I want to avoid such messages without having the resource running.

Best regards.

Link to comment
  • Moderators

1. Solving the main issue. In case of sending from server to client.

• Do not send triggerClientEvent's over the root variable.(it is also root, when you do not fill in the receiver)

Instead use a table which contains all players that have loaded their resources. When the event onClientResourceStart has been triggered, this player is ready to go.

 

When I release a tool that I have been announced two days ago, there will be a 2e.

 

There is also a function in Lua called pcall. This will skip all error messages, but I don't think that will work as it is an async created error. (Not directly shown up when the trigger*Event function is called, but after it has first send to the other side)

function test1 (arg)
  print(arg)
end

pcall(test1, 13342144)


pcall(test2, 354356) -- there is no test2 function, but we can try to call it without any error message.

 

 

 

 

Edited by IIYAMA
  • Like 2
Link to comment
  • 2 months later...
  • Scripting Moderators
On 01/03/2019 at 08:53, IIYAMA said:

1. Solving the main issue. In case of sending from server to client.

• Do not send triggerClientEvent's over the root variable.(it is also root, when you do not fill in the receiver)

Instead use a table which contains all players that have loaded their resources. When the event onClientResourceStart has been triggered, this player is ready to go.

 

When I release a tool that I have been announced two days ago, there will be a 2e.

 

There is also a function in Lua called pcall. This will skip all error messages, but I don't think that will work as it is an async created error. (Not directly shown up when the trigger*Event function is called, but after it has first send to the other side)


function test1 (arg)
  print(arg)
end

pcall(test1, 13342144)


pcall(test2, 354356) -- there is no test2 function, but we can try to call it without any error message.

 

 

 

 

Should work?

-- default

--> add player to table, after his login on https://wiki.multitheftauto.com/wiki/OnPlayerLogin

-- in case of resource restart

--> loop: getElementsByType, check if they are logged in (isGuestAccount function), insert logged in players to table.

And so, if isn't root then this will be a little bit better for performance?

Link to comment
  • Moderators
3 minutes ago, majqq said:

Should work?


-- default

--> add player to table, after his login on https://wiki.multitheftauto.com/wiki/OnPlayerLogin

-- in case of resource restart

--> loop: getElementsByType, check if they are logged in (isGuestAccount function), insert logged in players to table.

 

yes, this is how it should be done.

 

4 minutes ago, majqq said:

And so, if isn't root then this will be a little bit better for performance?

for which function? triggerServer/ClientEvent, addEventHandler or getElementsByType?

  • Like 1
Link to comment
  • Scripting Moderators
21 minutes ago, IIYAMA said:

yes, this is how it should be done.

 

for which function? triggerServer/ClientEvent, addEventHandler or getElementsByType?

triggerServerEvent

Edited by majqq
Link to comment
  • Moderators
41 minutes ago, majqq said:

triggerServerEvent

 

 

I am not 100% sure why sending the root to the other side will create more CPU usage. It is not logic when you look at the element tree Element_tree.

Most addEventHandlers have by default propagation enabled. Which means that all element (children) in the server will be able to trigger those addEventHandlers, if the eventname is the same and the handler element is root. The situation with using a child should be able to trigger more events than when the root element is used.

 

What is the difference between sending root and resourceRoot from a performance perspective?

Can't answer that. Not even sure if it has any relations with the addEventHandler.?

 

  • Like 1
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...