Leaderboard
Popular Content
Showing content with the highest reputation on 20/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
-
https://community.multitheftauto.com/index.php?p=resources&s=details&id=1970 Just edit the resource according to your needs.1 point
-
If you want to whitelist the values that is in the table use this code: local zifr = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"} function editCheck() local chars = table.concat(zifr, ""):gsub("[%(%)%.%%%+%-%*%?%[%^%$]", "%%%1") local editText = guiGetText(source) local replacedText = editText:gsub("[^"..chars.."]", "") if editText ~= replacedText then guiSetText(source, replacedText) playSoundFrontEnd(2) end end addEventHandler("onClientGUIChanged", editMoney, editCheck, false) If you want to simply whitelist all the numbers use this code: function editCheck() local editText = guiGetText(source) local replacedText = editText:gsub("[^0-9]", "") if editText ~= replacedText then guiSetText(source, replacedText) playSoundFrontEnd(2) end end addEventHandler("onClientGUIChanged", editMoney, editCheck, false) * Both codes are not tested1 point
-
* Not tested local blacklisted = {"A", "a"} local edit = guiCreateEdit(...) function editCheck() local chars = table.concat(blacklisted, ""):gsub("[%(%)%.%%%+%-%*%?%[%^%$]", "%%%1") local editText = guiGetText(source) local replacedText = editText:gsub("["..chars.."]", "") if editText ~= replacedText then guiSetText(source, replacedText) end end addEventHandler("onClientGUIChanged", edit, editCheck, false)1 point
-
Não estava no lugar correto. Tópico movido para a seção de Programação em Lua. Sobre sua dúvida, vc pode usar SetPlayerHudComponentVisible.1 point
-
1 point
-
1 point
-
1 point
-
Tópico movido para a seção de Programação em Lua. Veja as regras do fórum aqui:1 point
-
السلام عليكم ورحمة الله و بركاته طبعاً معظم الناس مش فكراني والباقي مش عارفني انا كازانوفا مصمم اوبجت dff,txd,col اي model تفكر فيه بصممه و صاحب سيرفر Gta Egypt Team الاصلي القديم كنت انا و عصفورة و تايجر و اعتزلت و رجعت لهدف معين يعني الموفجأة هي :- اي اوبجكت محتاجة لسيرفرك اكتبه في كومنت و هصممهولك و من غير اي مقابل طبعا في ناس هتقول نصاب و كذاب و الكلام دا بس الناس القديمة الهنا و اصحاب السيرفرات القديمة عرفني كويس1 point
-
Are you in search of a good hosting service provider? HostSailor is a global and trusted provider of VPS hosting, dedicated servers, domains, SSL certificates, and other hosting and technology services. They provide a wide selection of platforms to ensure that customers offer the right solution for their website needs. They offer affordable prices for good quality products and services.1 point
-
Olá, tente isto: local function Skin( ) if eventName == 'onPlayerSpawn' then local nData = getElementData( source, 'save-skin' ) if nData then setElementModel( source, nData ) end else setElementData( source, 'save-skin', getElementModel( source ) ) end end addEventHandler( 'onPlayerWasted', root, Skin ) addEventHandler( 'onPlayerSpawn', root, Skin )1 point
-
Sim. Usando as seguintes funções: getTickCount - Fazer verificação de tempo. É melhor do que usar setTimer, pois o tempo ainda pode ser contado entre as sessões independente se for demorado ou não. AclGroupAddObject - Adicionar o jogador na ACL VIP. AclGroupRemoveObject - Remover o jogador da ACL VIP. IsObjectInACLGroup - Verificar se o jogador está ou não na ACL VIP. SetAccountData - Colocar o tempo restante do VIP na conta do jogador para salvar entre as sessões. GetAccountData - Receber o tempo restante do VIP da conta do jogador para saber se o VIP já acabou ou não. AddCommandHandler - Colocar os comandos que você quer que o jogador use, por exemplo /viptime GuiCreateWindow - Criar o painel para você gerenciar os VIPs. As demais funções dos outros elementos GUI também estão nesta página. Eventos: onPlayerQuit, onPlayerLogin, onPlayerLogout. Espero ter ajudado. Boa sorte.1 point