Leaderboard
Popular Content
Showing content with the highest reputation on 10/01/17 in Posts
-
I brought you bakaGaijin and Ash Now I bring Discord integration with MTA scripts. MTA already has this for IRC Shoutout to the people who made the Sockets module, you're awesome. Features: -Scripts can echo messages to any Discord text channel of their choosing. -Any Discord channel can be set up to echo all messages to an ingame script. (Including the name of the person who said it, and his role) -One MTA server can send/receive to multiple Discord guilds. Example use: To show how this is useful, I made a small program to echo all global chat to a "global" Discord channel, and all team chats to individual "team" Discord channels. These Discord channels ofc echo messages back when someone posts. As proof of concept for commands, if a Discord user types "!ban name" then his role is checked, and if it includes Founder, the chat outputs "name was banned!" This is the client side script I used for this example: local SECRET_KEY = "15-A-53CR3T-K3Y" --The script works even if your server IP changes. You are mapped to a unique key. local function onopen(self) self:send(SECRET_KEY) --Your MTA server logs in addEventHandler("onResourceStop", resourceRoot, function() self:close() --Break off from Discord end) addEventHandler("onPlayerChat", getRootElement(), function(message, type) --Example hook to capture player chats local name = getPlayerName(source) local channel = "global" --Send to global channel if global chat if type==2 then channel = getTeamName(getPlayerTeam(source)) end --Or team channel if teamchat --Format to send messages is ("discord", channelName, message) self:send("discord", channel, name..": "..message) end) end function onmessage(self, data) local channelName, name, role, message = data[3], data[4], data[5], data[6] local orginal_message = message --The message we got from discord message = "("..role..") "..name..": "..message --Make it pretty if channelName=="global" then --Output to global chat or team chat outputChatBox("(DISCORD) "..message) else local team = getTeamFromName(channelName) local members = getPlayersInTeam(team) or {} local r, g, b = getTeamColor(team) --Color the output for lulz for _, player in ipairs(members) do outputChatBox( "(DISCORD) (TEAM) "..message, player, r, g, b) end end local commandExample = string.match(orginal_message, "^!ban (.+)") --If message started with !ban... if role=="Founders" and commandExample then -- ...and the person who said it had the right Role outputChatBox(commandExample.." was banned!", getRootElement(), 255, 0, 0) end end local function onclose() outputChatBox("The Discord link was closed") end local discord = Discord.new(onopen, onmessage, onclose) That's 41 lines of code, now let's see it in effect. I would love to hear what you think about it.1 point
-
Have the MTA Team setup an official Discord server? I saw an unofficial one on a topic a few weeks back and joined it, but somebody speaks once every few days and it's full of weird bot scripts. Would be an idea to get one going, especially as it can link to IRC.1 point
-
1 point
-
1 point
-
1 point
-
local _S, server = {}, not (isElement(localPlayer) and getElementType(localPlayer) == "player") local side, pside = server and "Server" or "Client", server and "Client" or "Server" function sync(t, k, v) assert(type(k) == "string" and k:match "([%a_][%w_]*)()", "Invalid variable name") _G["trigger"..side.."Event"]("onSync"..side.."Value", resourceRoot, {k, type(v) == "function" and "function:"..string.dump(v) or v}) end setmetatable(_S, { __index = sync, __newindex = sync, __metatable = "" }) addEvent("onSync"..pside.."Value", true) addEventHandler("onSync"..pside.."Value", resourceRoot, function(t) assert(type(t) == "table", "Invalid data") assert(type(t[1]) == "string" and k:match "([%a_][%w_]*)()", "Invalid variable name") local isfunc = type(t[2]) == "string" and t[2]:sub(1, 9) == "function:" _G[t[1]] = isfunc and pcall(loadstring("return "..t[2]:sub(10)))() or t[2] end) -- how to usage local test = function() print("hello") end _S["my_func_name"] = test string.dump كان بينجح لو ام تي اي تدعم1 point
-
You should change your router password now, as soon your server is up your public IP is exposed to the world and anyone who paste that IP into a browser can connect to your network on port 80 which goes directly to your router (unless you have a web server at home).1 point
-
Those functions are baked into MTA and aren't contained within any resource. To disable it, you need to edit your acl.xml. Simply go to where it says '<acl name="Default">' and add the following underneath: <right name="command.login" access="false"></right> <right name="command.register" access="false"></right>1 point
-
You are missing the socket module for your MTA server. There is a check in place to prevent starting the resource without it, which you probably circumvented, because the resource stops immediately if it's not available.1 point
-
1 point
-
ههه استخدام شو ؟؟؟؟ هاد فقط يسوي عنوان اللوحة فقط + عشان اقدر اخفيه براحتي و احركو مع اللوحة ,, الكود الكامل لسا ما خلص عندي اكتر تعقيد من كدا بس لو طرحتو يروح التعب1 point
-
To add, MTA:SA has no official servers. They're all created by other MTA:SA users/players and they can easily add additional resources that allows them to do such things.1 point
-
So I'm finally releasing the MTA Highlight extension that powers our syntax highlighting on the forums and on the wiki. This enables the blue and orange links you see that link to the Wiki for MTA functions. The highlighter is built off of Google's prettify library, so is only compatible with software that uses Google Prettify to highlight their code. Installation Usage is really simple, and it sits very well with Google's own prettify library. Note, that you'll need a version of JQuery for the functions to work. In your HTML HEAD includes, add the following: <!-- Add JQuery --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <!-- Add Google Prettify library --> <script src="//cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script> <!-- Lua not added by default, add it--> <script src="//cdn.rawgit.com/google/code-prettify/master/src/lang-lua.js"></script> <!-- Get the latest function definitions from MTA Forums --> <script type='text/javascript' src='//forum.multitheftauto.com/uploads/javascript_syntax/luafuncs.js'></script> <script type='text/javascript' src='//forum.multitheftauto.com/uploads/javascript_syntax/mtafuncs.js'></script> <!-- Add MTA-prettify library --> <link rel="stylesheet" type="text/css" href="//cdn.rawgit.com/darkdreamingdan/MTA-prettify/master/mtahighlight.min.css"> <script type='text/javascript' src="//cdn.rawgit.com/darkdreamingdan/MTA-prettify/master/mtahighlight.min.js"></script> You'll then need some JavaScript to use Google's Prettify and apply MTA's markup: $(function () { // Perform Google Prettify PR.prettyPrint(); // Add MTA markup applyMTAMarkup(); }); Usage Usage is just like Google's own Prettify, but you'll need to add lang-lua as a class to your <pre/> snippets. For example: <pre class="prettyprint lang-lua"> function onWasted() if not( isGuestAccount (getPlayerAccount(source)) ) then local jailtime = getAccountData(getPlayerAccount(source), "Jailtime" ) or 0 local theWeapon = getPedWeapon (source) local weaponAmmo = getPedTotalAmmo (source) if tonumber(jailtime) == nil or 0 then outputChatBox ("1", root) fadeCamera (source, false) setTimer (setElementHealth, 1500, 1, source, 10) setTimer (setCameraTarget, 1250, 1, source, source) setTimer (fadeCamera, 2000, 1, source, true) setTimer (giveWeapon, 2000, 1, source, theWeapon, weaponAmmo, true) elseif tonumber(jailtime) > 0 then outputChatBox ("2", root) fadeCamera (source, false) setTimer (portjail, 1500, 1) setTimer (setElementHealth, 1500, 1, source, 10) setTimer (setCameraTarget, 1250, 1, source, source) setTimer (fadeCamera, 2000, 1, source, true) setTimer (giveWeapon, 2000, 1, source, theWeapon, weaponAmmo, true) end end end addEventHandler ("onPlayerWasted", getRootElement(), onWasted) </pre> Example An example JSFiddle is available here: https://jsfiddle.net/darkdreamingdan/0uvzbL1n/. Source code available here: https://github.com/darkdreamingdan/MTA-prettify . I'd really appreciate a GitHub star if you found this useful! Note: Usage may be different if installing on different CMS software. Typically, this is easily implemented by using your CMS/forum's Theme editor.1 point
