IIYAMA

Scripting Moderators
  • Content Count

    5,173
  • Joined

  • Last visited

  • Days Won

    82

Status Updates posted by IIYAMA

  1. It took a while before I had time for explaining an enchantment which I created a while back, but I finally wrote a topic for it. Just another enchantment topic/tutorial. This time it is about communication between serverside and clientside.

    The context of what will be enchanted
    These 2 sides will have communication with each other:
     

    serverside > code that runs in the server application.
    Program Files (x86)\MTA San Andreas X.X\server\MTA Server(.exe)

    clientside > code that runs on all clients/players > game application.
    Program Files (x86)\MTA San Andreas X.X\Multi Theft Auto.exe

    In most cases there is just 1 server.
    And there might be more clients / players connected to that 1 server.

     

     

    17.10.jpg

     

    If you already know how client/server trigger events work, then it is still worth looking at. It is an enchantment, which means it does things for you, so less code is needed to achieve something complex.

     

    There are some stupid jokes included, which are actually really bad... sorry. It is suppose reduce the cognitive load of the content by letting the reader first visualize the context before explaining it. (it is a method)

     

     

  2. For those who haven't seen it yet. There is since yesterday a tutorial available about scaling DX components on the tutorial section.

     

     

    This tutorial can also be user for other types of user interfaces, like the MTA GUI or DX libraries.

     

     

  3.  

        /\
       /  \
      /    \
     /      \
    /        \
    ----------

     

    For those who have already downloaded the tool I post. I found and removed a critical bug in it, which had to do with calling back the client. While testing (alone) I didn't notice that it was sending information back to all clients instead of the one that should receive it. My apologies about this.

     

    Change in the source code:

    https://gitlab.com/IIYAMA12/mta-communication-enchantment/commit/c425481b5e49da3ff4aab9b5552795e2f2563e98

     

    It is recommended to re-download the tool in that case.

    NOTE: I will not make feature announcements here, only critical bugs.

     

    Re-download

  4. MTA-Communication-Enchantment

    It is finally far enough in development to share this with you. I made an announcement a few days ago about solving some struggles, that people have with communicating between the server and the client. Today is the day that it isn't just rumour, but for you to use.

     

    Before I am going to write a topic for it, I prefer to solve any unknown issues first. That is where you guys might come in!

     

    Just an example:(1)

    Passing arguments like you used to@

    --CLIENT
    callServer("passingArguments", "arg1", "arg2", "arg3")
    -- SERVER
    function passingArguments (arg1, arg2, arg3)
    	outputChatBox(arg1 .. " " .. arg2 .. " " .. arg3, client)
    end

     

     

    Just an example:(2)

    Calling back!

    -- CLIENT
    callServer(
      	"calculation", 
    	50,
    	100,
    	function (value)
    		outputChatBox("Value: " .. value)			  
    	end
    )

     

    -- SERVER
    function calculation (value1, value2)
    
    	return value1 + value2
    end

     

     

    Just an example:(3)

    Calling before a client has loaded his scripts!

    --SERVER
    addEventHandler("onPlayerJoin", root, 
    function ()
    	
    	callClientAwait(source, "testCallClientAwait")
    	
    end)

     

    -- CLIENT
    function testCallClientAwait ()
    	outputChatBox("Yes this works!")
    end

     


     

    Quote

    List with examples you can explore:

    Examples

     

    List with the syntax of functions you can use:

    Syntax

     

    Set-up for your own resources:

    Set-up

     

     

     

    Thank you @Xwad and @JeViCo for early testing!

     

    Repository: (+ download)

    https://gitlab.com/IIYAMA12/mta-communication-enchantment

    [NOTE] The documentation on the repository is not 100% complete.

     

    Direct download link:
    [NOTE]
    On the repository there is syntax highlight

    https://gitlab.com/IIYAMA12/mta-communication-enchantment/-/archive/master/mta-communication-enchantment-master.zip

    1. Show previous comments  2 more
    2. JeViCo

      JeViCo

      a little example (didn't test it)

      -- CLIENT
      callServer(
        	"checkIfAdmin", localPlayer,
      	function (result)
      		outputChatBox("Does player have admin rights? - " .. tostring(result))			  
      	end
      )
      --SERVER
      function checkIfAdmin(player)
      	return isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( player ) ), aclGetGroup ( "Admin" ) )
      end

       

    3. IIYAMA

      IIYAMA

      @JeViCo

      Yea it works!

      Nice done

    4. koragg

      koragg

      You intrigued me with the possibility to call certain events after players are actually loaded (thus removing the annoying red errors that come way too often for nothing). I'll definitely use that in a few resources on my server, thanks for creating it! But it'll be a while before I do so, am kinda busy these days. You're awesome ;)

  5. Dear scripters,

     

    A few days ago I started building  on a new tool/enchantment for a mta functionality. The tool is an enchantment for the trigger[Client/Server]Event function. It will be available for everybody once it is finished.

    I decided to build this tool as challenge for these issues:

    - The current trigger*events can be complex for some people to use.

    - CallBack functionality is not directly available.

    - Sending trigger events before the client has been loaded happens too often. This message will not be received.

    - Can't pass over arguments to the callback function without losing them or making copies. So a functionality that allows you to send tables and functions from(from A to B):

    [A] serverside > (clientside) > B  serverside callback

    (Clientside is left out, while passing  functions/tables)

     

    [A] clientside > (serverside) >  B  clientside callback

    (Serverside is left out, while passing these functions/tables)

     

    A question to you guys:

    Is there any other issue related to the trigger*Event functions that you would like to see automatically/easier?

    1. IIYAMA

      IIYAMA

      Is there anybody who is interested in trying it out, before the beta version is set public?

      If there is, then I will prepare a sample. (documentation included) :fadein:

       

      It is bad practice to release something without letting the user testing it.... You should know better @IIYAMA... 🙃

  6. New free health regeneration resource. Simple concept, but it is worth a try! Enjoy 🍾
    Might be an interesting addition for shooters and race gamemodes.

     

     

  7. Added a tutorial:

     

  8. Using one addEventHandler on a group of elements?

     

    Answer:

    local group = createElement("groupMyCutePeds") -- Create a custom element and save it in to the variable <group>.
    
    
    -- Create 3 peds.
    local ped1 = createPed(120, 5540.6654, 1020.55122, 1240.545)
    local ped2 = createPed(120, 5541.6654, 1021.55122, 1240.545)
    local ped3 = createPed(120, 5542.6654, 1022.55122, 1240.545)
    
    -- Set the parent of the 3 peds.
    setElementParent(ped1, group)
    setElementParent(ped2, group)
    setElementParent(ped3, group)
    
    
    -- Add an addEventHandler and use the <group> as <attachedTo> element.
    addEventHandler("onPedWasted", group, -- "onPedWasted" = serverside. "onClientPedWasted" = clientside.
    function ()
        outputChatBox("One of my cute peds just died. ;'( No exceptions!")
    end)

    (untested muhahaha :D)