1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. GTA Network forum is now in archive mode.

Better/easier client event handling

Discussion in 'Snippets' started by Eraknelo, Apr 9, 2017.

  1. Eraknelo

    Eraknelo Active Member

    Messages:
    64
    Likes Received:
    61
    Joined:
    Dec 26, 2016
    Read more here: https://github.com/Rene-Sackers/gta-network-easy-event-hook

    Basically, removes the need for this type of code when handling client events on the server:

    Code:
    private void OnClientEventTrigger(Client sender, string eventName, params object[] arguments)
    {
       if (eventName != "MyEvent") return;
    
        var firstArgument = arguments[0] as NetHandle?;
        var secondArgument = arguments[1] as string;
    
        if (!firstArgument.HasValue) return;
        if (string.IsNullOrWhiteSpace(secondArgument)) return;
    
        // Do stuff with the net handle and string arguments.
    }
    
    And it's even fully unit tested! Would you look at that.
     
    rum likes this.
  2. MissMelissa

    MissMelissa New Member

    Messages:
    0
    Likes Received:
    0
    Joined:
    Dec 26, 2016
    Nice!! :=D
     
  3. meisterlampe00

    meisterlampe00 Member

    Messages:
    20
    Likes Received:
    0
    Joined:
    May 2, 2017
    Someone can make an Tutorial about this?
     
  4. Eraknelo

    Eraknelo Active Member

    Messages:
    64
    Likes Received:
    61
    Joined:
    Dec 26, 2016
    The GitHub page is basically a tutorial.
     

Share This Page