IIYAMA

Scripting Moderators
  • Content Count

    4,800
  • Joined

  • Last visited

  • Days Won

    51

IIYAMA last won the day on August 19

IIYAMA had the most liked content!

Community Reputation

776 MTA Ambassador

About IIYAMA

  • Rank
    Scripting Moderator & User Guide Contributor
  • Birthday 01/01/2016

Details

  • Gang
    [HB]
  • Location
    Netherlands
  • Occupation
    I have never been to the streets of SA... so who knows?
  • Interests
    Design, scripting, UX/UI

Recent Profile Visitors

8,081 profile views
  1. 1. Open your browser. 2. Right-mouse button > inspector 3. Go to the console tab. 4. Copy the JSON.parse method. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse 5. Place your json string as an argument. JSON.parse("the string") 6. Copy and past the code in to the console and run it. You have now loaded your JSON to it's origin. Or rather live version of it. Now you can inspect.
  2. Afaik I said in my pm's that you have to use the MTA function. https://wiki.multitheftauto.com/wiki/DxDrawCircle And now you are still asking for help for a shader which you do not understand at all? + keep bumping, which I have warned you already for. If you want people their attention, then atleast write a message with some useful content.
  3. Hovering is probably not possible. But you can get from each object it's texture names, based on the model id. https://wiki.multitheftauto.com/wiki/EngineGetModelTextureNames Or on screen: (+ filter option based on model id) https://wiki.multitheftauto.com/wiki/EngineGetVisibleTextureNames
  4. It is indeed a little bit strange. But on the other side, it does provide a way to optimise access for variables manually. It is just a pity that it can't optimise itself based on patterns of variable requests.
  5. IIYAMA

    Language layout

    Yes, I can understand that. But it is not ethical for MTA to implement such a privacy sensitive feature, so I doubt they will add something like that.
  6. IIYAMA

    Language layout

    That is more or less a privacy breach.
  7. IIYAMA

    Language layout

    local messages = { en = { ["welcome"] = "Hi" }, nl = { ["welcome"] = "hoi" } } function getMessageTextById(id, language) return messages[language] and messages[language][id] or messages["eng"][id] or "" end How about you create a global language system? @slapz0r iprint(getMessageTextById("welcome", "nl"))
  8. IIYAMA

    Help pls

    Login is not the same as registration. If you are still worried. Open your acl.xml file and search for sebas. If you can't find him there, he is no admin.
  9. I had the same results, so nothing has changed. It might even be possible that they are already localized in some unknown way. Just as the predefined source variable is localized when an event has been triggered.
  10. @slapz0r Do you want to mute them or mute the audio from other players as well? I haven't done this before, so I do not know the best practice, especially the capability of voice with your gamemode. But let me increase your options: See this event: onPlayerVoiceStart + example on that page. Here you have a list of export functions for the voice resource. See: https://wiki.multitheftauto.com/wiki/Resource:Voice#setPlayerVoiceMuted_2 And https://wiki.multitheftauto.com/wiki/Resource:Voice#setPlayerChannel
  11. The _G table keeps track of all global variables. Not just functions and not all functions, as some can be saved in local variables. https://www.Lua.org/pil/14.html Yes, they are `shared` or rather copied. I honestly only localize my own functions. The last time I checked, I didn't notice any optimization by localize MTA functions. Every file has it's own scope, so making use of that is not a bad thing. My main reason for localization: You can use it to distinguish functions used within the file, from functions that are called from other files. The only thing I do with some Lua functions is this: local mathRandom = math.random
  12. 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)

     

     

  13. MTA-Communication-Enchantment This is an enchantment that allows you to communicate between clientside and serverside a bit easier. If you know how to work with events, then you probably do not need this, but it has some nice features which allows you to sit back and write less code + achieve some nice results. Note: It is important to keep in mind that this is an enchantment. Which means it is just an layer on top of the basic functionalities of MTA. And most enchantments come with a cost, in this case that is bit of performance. I will keep the information of topic to the minimal, as I have written most of the information already on the repository. You can find the repository here. Examples Syntax Installation What can you do with it? Calling from clientside to serverside Client callServer("hello") Server function hello () outputChatBox("Hello client!") end Calling from serverside to clientside Server addCommandHandler("callclient", function (player) -- An addCommandHandler is needed, because the client hasn't loaded it's scripts yet. callClient(player, "hello") end, false, false) Client function hello () outputChatBox("Hello server!") end Ok, ok, that was boring. The next one this is a bit nicer! Hello are you there? Just Call-me-back... I miss(ed) you too Callback Client callServer( "callbackMe", "argument", function (argument) -- < This is the callback function outputChatBox(argument) end ) Server function callbackMe (argument) return argument .. " < I looked at it :)" end Callback + internal arguments Sometimes you have arguments that you simply can't send over. > functions Or arguments that shouldn't be send over. > LARGE quantities of database data Internal arguments can be used to pass information to a callback without exposing it to the other side(client/server). Client callServer( "callbackMe", -------------------------------- -- arguments that are send over "argument", -- -------------------------------- function (internalArgument, argument) -- < This is the callback function. outputChatBox(internalArgument) outputChatBox(argument) end, -------------------------------- -- arguments that are not send over "internalArgument" -- < internal argument -- -------------------------------- ) Server function callbackMe (argument) return argument .. " < I looked at it :D" end Ha! Serverside what is that? No need for complicated things! Communicate between clients without writing a single line of serverside. Magic! Note: There is serverside used behind the scenes, you just don't have to write it. Client function smile (player) outputChatBox((isElement(player) and getPlayerName(player) or "[unknown]") .. " has send you a: :)") local x, y, z = getElementPosition(localPlayer) setElementPosition(localPlayer, x, y, z + 100) end addRemoteClientAccessPoint(smile) -- < This function allows other clients to call this function. --------------------------------------- -- -- function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end -- Author: TAPL -- https://wiki.multitheftauto.com/wiki/GetPlayerFromPartialName -- -- --------------------------------------- addCommandHandler("smile", function (cmd, playerName) local player = getPlayerFromPartialName(playerName) if player then outputChatBox("Sending smile!") callRemoteClient(player, "smile", player) else outputChatBox("Can't find player!") end end) Turtle, I will wait for you to catch up. So don't worry, you are still cute. Await functions When a player has joined the server, he or she doesn't have download + loaded his scripts yet. This means that you can't deliver your love letter yet and all your work will be for nothing. But what if you don't have to worry about that? You can just wait now! Server addEventHandler("onPlayerJoin", root, function () callClientAwait(source, "testCallClientAwait") end) Client function testCallClientAwait () outputChatBox("Yes this works!") end Security Worried about security issues? Remote calls for C++/MTA functions have been blocked. There is a whitelist feature included, if enabled your code can only remote-call whitelisted functions. (this is disabled by default) Read the docs for that. Here and here
  14. I locked it for you as requested.
  15. IIYAMA

    onPickupHit

    local pickup[k] = createPickup( i[1], i[2], i[3], i[4], i[5], 0) You shouldn't use the local keyword, when you are not declaring a local variable.