Jump to content

4O4

Members
  • Posts

    25
  • Joined

  • Last visited

Posts posted by 4O4

  1. On 08/11/2020 at 13:09, Adolfram said:

    I'm afraid it is not. I've set up a docker environment for my dev/prod servers and the only way I can distinguish dev and prod is the ports.

     

    Actually I've made a simple native server module for exactly this purpose - to pass some configuration or secrets via env variables to the MTA server running in docker container. There is a "getSystemEnvVariable(string variableName)" function there (no "set" counterpart as I didn't need it, but could be implemented easily). Currently I haven't published any releases of .dll / .so but the code is available on Github and you can build it yourself easily: https://github.com/4O4/mta-ml-sysutils

    Generic building instruction is: run "utils/premake5 gmake && cd Build && make" on linux, and on windows run: "utils/premake5.exe vs2019" and then open Build/*.sln file in visual studio and launch build from there. After a successful build the dll / so will be in Bin/ folder.  If you need help with building or want me to publish binaries built by me on github releases, just let me know.

    This module also includes a second utility function "executeSystemCommand(string systemCommand, function commandFinishedCallback(exitCode, stdout, stderr))" for executing system commands asynchronously in a separate thread, although I ended up not using it very much so I don't know about its stability. Should work but no guarantees, I'm just informing you that it exists in the same module and that's why it is called "sysutils".

    • Like 2
  2. It must be Player, but not necessarily a variable named "player" (which was nil in your case, because you never told your script what it is). Both of your functions are executed by some events, and all events have a source (which is also a special variable available in scope of the function that gets executed by event). If you open the documentation page on wiki for onPlayerWasted you can see that in this case the source of event is some Player.

    Quote

    The source of this event is the player that died or got killed.

    There is plenty of information on wiki, so you just need to learn how to use it properly. Follow the links and read everything which is related to the functions or events you want to use. Start by clicking on "source" link and you will see all information about event system :) Then check some Lua tutorials to learn about variables, scopes, functions etc., there are links on main wiki page too (https://wiki.multitheftauto.com/wiki/Main_Page, General Lua Help section).

  3. Hi, please use Code button next time you are pasting Lua code

    if getPlayerTeam == Infected then

    This condition looks bad and it is probably never true. getPlayerTeam is a function so it should be called - check wiki for examples. Also, Infected should probably be quoted if it is team name literal.

    function removePlayerZombie()
    	if getElementData (player,'zombie',true)

    It is throwing warning, because you haven't defined "player" anywhere. It should probably be "source" in your case instead.

  4. Well I'm dealing with this problem on Trucking server and this can be really annoying. It hasn't been fully fixed for many years in MTA. SetElementSyncer doesn't work at all, I tried it many times without any success. I'm personally using interval function to reattach streamed in trailers every 3 secs. I've also enabled ghostmode on all trailers because they're sometimes flying and hitting clients around the road. This is the best solution I found and have been using it for about 9 months now without any problems. Of course there are some cons and I'd be happy to hear if anybody found better ways of scriptside syncing because I doubt it will ever be fixed in MTA itself as it's being delayed all the time in bugtracker :)

    One more advice - don't rely on clientside trailer events because they are sometimes triggered on detach caused by desync and sometimes not. Serverside trailer events are more relialble.

  5. You don't see it because it's created out of window box. X and Y coordinates are relative to parent, parent is shaderPanel so you don't need to add window's x and y coordinates anymore. Replace:

    local checkBox1 = guiCreateCheckBox ( x1+spaceX, y1+spaceY, cWidth, cHeight, "Water Shader", true, false, shaderPanel) 
    

    with:

    local checkBox1 = guiCreateCheckBox ( spaceX, spaceY, cWidth, cHeight, "Water Shader", true, false, shaderPanel) 
    

  6. outputChatBox doesn't seems to work with team element, therefore you will have to make the loop.

    Oops! You're right, my bad. I've been always using custom team elements and forgot that this doesn't work by default. I'll edit the code.

  7. You're defining local team variable in line 9 and it only exists in that scope. For more information check this http://lua-users.org/wiki/ScopeTutorial

    The for loop is unnecessary. My suggestion is to put lines 9-12 just after "local acc..." so all of your code that depends on "team" is in the same scope. Also the for loop needs to be repeated two more times.

      
      
    local function teamChat(message, messageType) 
        if messageType == 2 then 
            cancelEvent() 
            local acc = getPlayerAccount(source) 
            local team = getPlayerTeam ( source ) 
            if ( not team ) then 
                return 
            end 
            
            if not isGuestAccount(acc) then 
                if getAccountData(acc,"chatc") and getElementData(source, "Vip") == true then 
                    local color = getAccountData(acc,"chatc") 
                    for _, player in ipairs(getPlayersInTeam(team)) do 
                        outputChatBox("(TEAM): " .. getPlayerName(source) .. ": " .. color .. message, player, 255, 255, 255, true) 
                    end 
                else 
                    for _, player in ipairs(getPlayersInTeam(team)) do 
                        outputChatBox("(TEAM): " .. getPlayerName(source) .. ": #FFFFFF" .. message, player, 255, 255, 255, true) 
                    end 
                end 
            else 
                for _, player in ipairs(getPlayersInTeam(team)) do 
                    outputChatBox("(TEAM): " .. getPlayerName(source) .. ": #FFFFFF" .. message, player, 255, 255, 255, true ) 
                end 
            end 
            outputServerLog("CHAT: "..getPlayerName(source)..": "..message) 
        end 
    end 
    addEventHandler("onPlayerChat", root, teamChat) 
      
    

×
×
  • Create New...