Small Addons.dll Update

Find news and updates about the Ashita project posted here.
Post Reply
User avatar
atom0s
Site Admin
Posts: 375
Joined: Sat May 14, 2016 5:13 pm

Small Addons.dll Update

Post by atom0s » Fri Feb 16, 2018 8:17 pm

Hello everyone,

shinzaku pointed out that the packet handlers were not reacting to an expected return scenario earlier today on our Discord, thus, they are now added.

incoming_packet and outgoing_packet events can return in the following manners now:

Valid Single Returns
  1. --[[
  2. Example 1 - Boolean Return
  3.  
  4. True or false if the packet should be blocked or not.
  5. ]]--
  6. ashita.register_event('incoming_packet', function (id, size, data, modified, blocked)
  7.     return false;
  8. end);
  9.  
  10. --[[
  11. Example 2 - Table Return
  12.  
  13. The packet data to use instead of the original packet. If the packet was already previously modified, the modified data should be used.
  14.  
  15. Using a table return value like this means the packet will not be blocked, just modified.
  16. ]]--
  17. ashita.register_event('incoming_packet', function (id, size, data, modified, blocked)
  18.     -- Non-recommended example..
  19.     local p = string.totable(data);
  20.     p[2] = 0;
  21.  
  22.     return p;
  23. end);
Valid Multiple Returns
  1. --[[
  2. Example 3 - Boolean and Table Return
  3.  
  4. The first return value is a boolean stating if the packet should be blocked or not.
  5. The second return value is a table containing the modified packet.
  6.  
  7. The second return value MUST be a valid table of packet data. You cannot return null or similar otherwise it will give you an error and ignore your return values!
  8. ]]--
  9. ashita.register_event('incoming_packet', function (id, size, data, modified, blocked)
  10.     -- Non-recommended example..
  11.     local p = string.totable(data);
  12.     p[2] = 0;
  13.  
  14.     return false, p;
  15. end);
Lead Ashita Developer

Want to donate to say thanks?
https://www.paypal.me/atom0s
Post Reply