Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/12/16 in all areas

  1. اكتفي بالتعليق اعلاه -- عموماً تُشكر على المجهود
    2 points
  2. 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
  3. Hi guys @fastman92 has recently engaged with us in order to get his limit adjuster implemented into MTA. Obviously, there are a number of complexities involved in implementing this, and we need to make some important design decisions to achieve this. So, why do you want to use a Limit Adjuster tool? Some things I'm hoping to learn: Are you trying to play MTA with a modified version of GTASA? Do you want the limit adjuster to play mods like GTA:Underground? Are you trying to use Limit Adjusters with MTA's own Lua engine* functions? (e.g. engineLoadDFF) Anything else? Any feedback would be incredibly beneficial to the team going forward. Cheers Dan
    1 point
  4. Ok here's the serverside with all in it. I never used the restricted argument in addCMDHandler, but it should work... still it's better to test. If testing of the first function result in a "fail", then use the second variant. function nameThatFunction( playerSource, cmd, ... ) local pX, pY, pZ = getElementPosition ( playerSource ) createExplosion ( pX+3, pY+3, pZ, 2 ) createExplosion ( pX-3, pY-3, pZ, 2 ) createExplosion ( pX+5, pY-2, pZ, 2 ) createExplosion ( pX-4, pY+4, pZ, 2 ) end addCommandHandler( "rob", nameThatFunction, true) --that true means the resource is restricted, so only if a player is in a group with the access to command.rob that command will be executed --since i NEVER used the restricted argument, here's the variant with the check inside the function function nameThatFunction( playerSource, cmd, ... ) if hasObjectPermissionTo(playerSource,"command.rob") then local pX, pY, pZ = getElementPosition ( playerSource ) createExplosion ( pX+3, pY+3, pZ, 2 ) createExplosion ( pX-3, pY-3, pZ, 2 ) createExplosion ( pX+5, pY-2, pZ, 2 ) createExplosion ( pX-4, pY+4, pZ, 2 ) end end addCommandHandler( "rob", nameThatFunction) EDIT: lol i noticed that the second variant is already posted, sorry for the duplicate.
    1 point
  5. Well hasObjectPermissionTo is a server-side only function, so you either make changes to it so you don't have to use that function or just do the explosion server side: function robbant(p,s) if hasObjectPermissionTo(p,"command.rob") then local pX, pY, pZ = getElementPosition ( p ) createExplosion ( pX+3, pY+3, pZ, 2 ) createExplosion ( pX-3, pY-3, pZ, 2 ) createExplosion ( pX+5, pY-2, pZ, 2 ) createExplosion ( pX-4, pY+4, pZ, 2 ) end end addCommandHandler("rob",robbant)
    1 point
  6. function boom ( ) local pX, pY, pZ = getElementPosition ( getLocalPlayer() ) createExplosion ( pX, pY, pZ, 2 ) end addCommandHandler( "rob", boom)
    1 point
  7. 1 point
  8. No no the problem is that i'm an idiot if getPlayerMoney >=25 then i'm comparing a function with a number... replace line 4 with if getPlayerMoney(player) >=25 then tell me if it's working after this edit PS: Warning: You should use the global variable client serverside instead of passing the localPlayer by parameter or source. Otherwise event faking (passing another player instead of the localPlayer) would be possible. More information at addEventHandler insert between line 1 and 2 this: player = client or player That way if the function is used as handler for the event, "client" will be the player that triggered the event and the variable "player" will have that player as value without security problems If the function is called from the commandhandler, "client" will be nil and so the "player" variable will have as value the player that typed the command "rentroller"
    1 point
  9. https://wiki.multitheftauto.com/wiki/ToggleControl
    1 point
  10. addEvent("onMapStarting") function nilMapData() if exports.mapmanager:getRunningGamemodeMap() == getElementData(resourceRoot, "keepnextmap") then setElementData(resourceRoot, "keepnextmap", nil) end end addEventHandler("onMapStarting", getRootElement(), nilMapData) This worked
    1 point
  11. You only nil the data if the winner map is the same as the one in keepnextmap Yes it will work, but the currentmap and the data should be EQUAL and not different. It's the basically same thing of what i was saying: - on poll end, pick the winner map, nil the data IF the winner map is the one in keepnextmap, start the map vs - on map start check if currentMap is the same as the keepnextmap, and if true nil the data. It's the third time i write this since i'm at school and the connection here sucks -.- sorry if i omitted something and let me know
    1 point
  12. There is a freecam resource included in MTA. Used in Map Editor.
    1 point
×
×
  • Create New...