Leaderboard
Popular Content
Showing content with the highest reputation on 18/08/19 in all areas
-
MTA-Communication-Enhancement This is an enhancement 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 enhancement. Which means it is just an layer on top of the basic functionalities of MTA. And most enhancements 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 here2 points
-
1 point
-
بالنسبة لاول محاولة ، انت مسوي myTable = { [1] = {"Hello", "1154"} } يعني لما تجي تكتب myTable[1] النتيجة الي راح تجيك هي {"Hello", "1154"} يعني ذي جدول في حد ذاتها ! فـ الحل ايش؟ انك تسوي زي كذا myTable[1][1] = "Hello" myTable[1][2] = "1154" وصلت الفكرة؟1 point
-
Use setAccountData -- save player's nickname to his account Use the function above on login, on nick name change and on quit so it stays up to date. Then you may just call it by getAccountData to get the player's name from his account name.1 point
-
You can not do that, elementData is temporary, what you can that about is using setAccountData (when the player leaves save elementData) and getAccountData (get the data saved by the account) Try this: -- load elementData function load(_, account) local name = getAccountData(account, "name") or "N/A" setElementData(source, "name", name) end addEventHandler("onPlayerLogin", getRootElement(), load) -- save elementData function save() local name = getElementData(source, "name") or "N/A" setAccountData(getPlayerAccount(source), "name", name) end addEventHandler("onPlayerQuit", getRootElement(), save) -- find elementAccount function find (source, cmd, playerAccount) if cmd and playerAccount then if getAccount(playerAccount) then local gName = getAccountData(getAccount(playerAccount), "name") outputChatBox("Name of "..playerAccount.." is #FFFFFF"..""..gName, source, 152, 95, 161, true) end end end addCommandHandler("find", find) EDIT: I do not tested!1 point
-
entendo mas fazer oque né foi o jeito de funcionar kkk, muito obrigado pela ajuda sou grato . OBS: agora bora retribuir com thanks!!! kk1 point
-
local marker = getElementsByType("marker") numaratoare = 0 for k, markere in ipairs(marker) do numaratoare = numaratoare + 1 outputChatBox(numaratoare) end poftim aici , iti scrie in chat numarul de markere. ca sa functioneze pe editor faci si tu o resursa si introduci functia de mai sus intr-un client.1 point
-
É uma variável interna do MTA que retorna o cliente que chamou o lado server. É útil também para verificação de segurança visto que o elemento cliente pode ser burlado em modificações do jogo, daí client sempre vai retornar o cliente válido.1 point
-
Tente: function sairTunar() local veh = getPedOccupiedVehicle(client) if (veh) then setElementInterior(client, 0) setElementInterior(veh, 0) setElementDimension(client, 0) setElementDimension(veh, 0) setElementPosition(veh, 1041.4, -1039, 32) end end addEvent("sairbackspacetunar", true) addEventHandler("sairbackspacetunar", root, sairTunar)1 point
-
E o evento não tá recebendo o player no parâmetro. Mostre o trecho que chama o evento.1 point
-
Com uma depuração básica você pode descobrir o erro, faça um print no valor lvls, e no getElementData1 point
-
ابي اسوي يكتب ع السيارة عشان تقدر تعدلها من اللعبه افضل من تروح تسوي صور والخرابيط ذيه لو عندك طريقة قول .1 point
-
Também não entendi oq vc quer fazer. Você quer fazer a navegação do seu menu DX pelas setas do teclado em vez de clicar, é isso?1 point