Jump to content

IIYAMA

Moderators
  • Posts

    6,086
  • Joined

  • Last visited

  • Days Won

    215

Everything posted by IIYAMA

  1. IIYAMA

    destroyElement

    if timehour == 6 then if wind and isElement(wind) then destroyElement(wind) wind = nil outputChatBox ("Object destroyed") end elseif not wind or not isElement(wind) then wind = createObject(1337,2321.5, -1659.5,13.5) outputChatBox ("Object created") end @Zcraks
  2. If you use Globals, you will be overwriting the variables. for i = 1, 40 do local Gate3 = createObject ( 5020, -2660.8000488281, 1424.8000488281, 921.20001220703, 0, 0, 270 ) setElementDimension( Gate3, i ) local x,y,z = getElementPosition (Gate3) local Zona = createColCircle ( x,y, 3, 3 ) local function Portao7(thePlayer) for _, group in ipairs ({"Console"}) do if isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group )) then moveObject (Gate3, 3000, -2660.8000488281, 1424.8000488281, 923 ) end end end addEventHandler ( "onColShapeHit", Zona, Portao7 ) -- not> Portao5 local function Portao8(thePlayer) for _, group in ipairs ({"Console"}) do if isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group )) then moveObject (Gate3, 3000, -2660.8000488281, 1424.8000488281, 921.20001220703 ) end end end addEventHandler ( "onColShapeLeave", Zona, Portao8 ) -- not> Portao6 end
  3. As far as I know these settings are only used for sync element orientations. p.s you might also reduce data like this: function onClientPlayerDamage(attacker, weapon, bodypart, loss) local newHealth = getElementHealth(localPlayer) if newHealth > 0 then -- is not dead local oldHealth = newHealth + loss setElementHealth(localPlayer, oldHealth) -- reset else -- is dead cancelEvent() triggerLatentServerEvent("onPlayerDamage_", localPlayer, attacker, weapon, bodypart, loss) end end addEventHandler("onClientPlayerDamage", localPlayer, onClientPlayerDamage) p.s this might also be needed serverside. addEvent("onPlayerDamage", false) --remote disabled
  4. function onClientPlayerDamage(...) cancelEvent() triggerLatentServerEvent("onPlayerDamage_", localPlayer, ...) end addEventHandler("onClientPlayerDamage", getLocalPlayer(), onClientPlayerDamage) addEvent("onPlayerDamage_", true)-- fake event onPlayerDamage_ = security addEventHandler("onPlayerDamage_", root, function (...) triggerEvent("onPlayerDamage", client, ...) end) It can be faked, but you might need to figure out a way to reduction data. @majqq For example buffer up till 100 ms, before sending the message This will reduce a lot in case of fire/minigun/Spraycan/Fire Extinguisher damage: (NOTE: surprisingly the minigun also fires a bullet every frame) How much reduction do you want for that scenario? Do the maths! local sendingDelay = 100 -- ms local fps = 60 local timeSlice = 1000 / fps local dataReduction = sendingDelay / timeSlice print("~" .. (dataReduction - 1 ) .. " x times LESS per " .. sendingDelay .. "ms") https://www.lua.org/cgi-bin/demo
  5. because the MTA developers decided to consider cancelled events as 'it never happened`. onPayerDamage is a delayed/streamed version of onClientPlayerDamage
  6. fileRead https://wiki.multitheftauto.com/wiki/FileRead fileWrite https://wiki.multitheftauto.com/wiki/FileWrite Examples are already included on the WIKI. Enjoy!
  7. @MatheusCalixto The files are mostlikely protected. I recommend to delete and recreate them.
  8. Hmm indeed strange. And what if you re-parse it? function reParseNumber(number) return tonumber(tostring(number)) end
  9. He is talking about the solution for this situation: The server sending a triggerClientEvent. But unfortunately the client is still downloading/loading the scripts. So the message isn't delivered and will give you that error that you are having. onClientResourceStart can be used as indication that the client is loaded and ready to receive triggerClientEvent's. (For that specific resource atleast)
  10. @majqq Did you checked if those are actual numbers? (and not strings. In that case you wouldn't see the difference in the outputChatBox.) Also you do not need to use Vector3 in the second example, it can be filled in without. That will save you another function execution.
  11. Ah that is a petty I do not think there are much options left. Except if the player is `standing still` and `doing nothing`. local x, y, z = getElementPosition(localPlayer) setElementPosition(localPlayer, x, y, z, true) -- warp argument is by default `true` but just so you know that it is doing something ... Optional Arguments warp: teleports players, resetting any animations they were doing. Setting this to false preserves the current animation. https://wiki.multitheftauto.com/wiki/SetElementPosition
  12. You could try to cancel the damage + set the health manually. (Only if the remaining health is not 0) https://wiki.multitheftauto.com/wiki/OnClientPlayerDamage Not sure if it will work, but good luck.
  13. I am going to be honest here. It is possible, but not for a beginner. As it is something that has to be either faked or recreated, that is complex stuff.
  14. While creating elements: -- on top of the script local boneAttachContainer = createElement("boneAttachContainer", "boneAttachContainer") -- while making objects local object = createObject(...) setElementParent(object, boneAttachContainer) -- on top of the script local validBoneAttachModels = {[2763] = true, [1820] = true, [2708] = true, [15036] = true} -- while pressing key local boneAttachContainer = getElementByID("boneAttachContainer") if boneAttachContainer then local objects = getElementsByType("object", boneAttachContainer, true) for i = 1, #objects do local object = objects[i] local model = getElementModel(object) if validBoneAttachModels[model] then setElementAlpha(object, alpha) end end end You might want to consider using a dirty timer or find an event that will occur at that time.
  15.  

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

     

    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

  16. @Overkillz I made an announcement about your option 2 on my status updates. (Topic comes later, when I have more time)
  17. 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 ;)

  18. 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.
  19. 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... ?

  20. @Xwad function getRotationOffset (rot1, rot2) local rotationOffset = (rot1 - rot2 + 360) % 360; if (rotationOffset > 180) then rotationOffset = 360 - rotationOffset else rotationOffset = -rotationOffset end return rotationOffset end function getRotationDifference (rot1, rot2) local rotationDifference = (rot1 - rot2 + 360) % 360; if (rotationDifference > 180) then rotationDifference = 360 - rotationDifference end return rotationDifference end Test them out and see which one you think need. getRotationOffset positive and negative. getRotationDifference only positive.
  21. He said two things: This doesn't sounds like server that can't handle things any more. This sounds like a clientside issue to me. But if the serverside also plays a role in it, that really depends on the resources.
  22. There should be a checkbox with the label: "Include clients" (on the top part you just cut off) Not sure if they disabled or removed it. Another way to view this information can be accessed with the browser: http://127.0.0.1:22005/resourcebrowser/ There you can do the same thing.
  23. Afaik from 0 to 1000. Because according to wiki 1000 enable dual weapons. https://wiki.multitheftauto.com/wiki/Weapon_skill_levels If you really want to know it for sure, then the obvious solution for a programmer is to debug it, isn't it? setPedStat(localPlayer, 21, 1000) iprint("super cow value:", getPedStat(localPlayer, 21))
  24. local selectedResourceName = "" -- < fill in -- This function will be restarting a selected resource. local function restartSelectedResource (selectedResource) local resourceState = getResourceState(selectedResource) if resourceState == "running" then restartResource(selectedResource) elseif resourceState == "loaded" then startResource(selectedResource) end end addEventHandler("onResourceStart", resourceRoot, function () local selectedResource = getResourceFromName(selectedResourceName) if selectedResource then setTimer(restartSelectedResource, 600000, 0, selectedResource) else outputChatBox("Can't find the selected resource.") cancelEvent(true, "Can't find the selected resource.") end end) https://wiki.multitheftauto.com/wiki/SetTimer https://wiki.multitheftauto.com/wiki/OnResourceStart https://wiki.multitheftauto.com/wiki/GetResourceFromName https://wiki.multitheftauto.com/wiki/StartResource https://wiki.multitheftauto.com/wiki/RestartResource https://wiki.multitheftauto.com/wiki/GetResourceState https://wiki.multitheftauto.com/wiki/CancelEvent Make sure the resource has access to these functions <right name="function.startResource" access="true" /> <right name="function.restartResource" access="true" /> startResource restartResource Those functions are blocked by default because they are used for administration purposes. Step 1 The rights can be requested by the resource if you add these lines in to your meta.xml: <aclrequest> <right name="function.startResource" access="true" /> <right name="function.restartResource" access="true" /> </aclrequest> Step 2 Commands left to do: (fill in the <resourceName> of the resource that contains this script) /refreshall /aclrequest allow <resourceName> all
  25. Use the ipb on yourself instead of your server. The server can indeed have influence on the client his FPS, but clientside has far more direct influence on the FPS.
×
×
  • Create New...