Advertisement
Guest User

Server Side

a guest
Apr 15th, 2012
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 79.63 KB | None | 0 0
  1. mysql = exports.mysql
  2.  
  3. function trunklateText(thePlayer, text, factor)
  4.     if getElementData(thePlayer,"alcohollevel") and getElementData(thePlayer,"alcohollevel") > 0 then
  5.         local level = math.ceil( getElementData(thePlayer,"alcohollevel") * #text / ( factor or 5.5 ) )
  6.         for i = 1, level do
  7.             x = math.random( 1, #text )
  8.             -- dont replace spaces
  9.             if text.sub( x, x ) == ' ' then
  10.                 i = i - 1
  11.             else
  12.                 local a, b = text:sub( 1, x - 1 ) or "", text:sub( x + 1 ) or ""
  13.                 local c = ""
  14.                 if math.random( 1, 6 ) == 1 then
  15.                     c = string.char(math.random(65,90))
  16.                 else
  17.                     c = string.char(math.random(97,122))
  18.                 end
  19.                 text = a .. c .. b
  20.             end
  21.         end
  22.     end
  23.     return text
  24. end
  25.  
  26. function getElementDistance( a, b )
  27.     if not isElement(a) or not isElement(b) or getElementDimension(a) ~= getElementDimension(b) then
  28.         return math.huge
  29.     else
  30.         local x, y, z = getElementPosition( a )
  31.         return getDistanceBetweenPoints3D( x, y, z, getElementPosition( b ) )
  32.     end
  33. end
  34.  
  35. local gpn = getPlayerName
  36. function getPlayerName(p)
  37.     local name = gpn(p) or getElementData(p, "ped:name")
  38.     return string.gsub(name, "_", " ")
  39. end
  40.  
  41. -- /ad
  42. function advertMessage(thePlayer, commandName, showNumber, ...)
  43.     local canIAD = getElementData(thePlayer, "sanAdvert") or 0
  44.     --[[if (canIAD == 0) then
  45.         outputChatBox("(( Command removed. Visit SAN to place an advertisement. ))", thePlayer)
  46.     else]]
  47.         local logged = tonumber(getElementData(thePlayer, "loggedin"))
  48.          
  49.         if (logged==1) then
  50.             if not (...) or not (showNumber) then
  51.                 outputChatBox("SYNTAX: /" .. commandName .. " [Show Phone Number 0/1] [Message]", thePlayer, 255, 194, 14)
  52.             elseif getElementData(thePlayer, "adminjailed") then
  53.                 outputChatBox("You cannot advertise in jail.", thePlayer, 255, 0, 0)
  54.             elseif getElementData(thePlayer, "alcohollevel") and getElementData(thePlayer, "alcohollevel") ~= 0 then
  55.                 outputChatBox("You are too drunk to advertise!", thePlayer, 255, 0, 0)
  56.             else
  57.                 if (exports.global:hasItem(thePlayer, 2)) then
  58.                     if (getElementData(thePlayer, "ads") or 0) >= 2 then
  59.                         outputChatBox("You can only place 2 ads every 5 minutes.", thePlayer, 255, 0, 0)
  60.                         return
  61.                     end
  62.                     message = table.concat({...}, " ")
  63.                     if showNumber ~= "0" and showNumber ~= "1" then
  64.                         message = showNumber .. " " .. message
  65.                         showNumber = 0
  66.                     end
  67.                     if message:sub(-1) ~= "." then
  68.                         message = message .. "."
  69.                     end
  70.                    
  71.                     local cost = math.ceil(string.len(message)/6)
  72.                     if exports.global:takeMoney(thePlayer, cost) then
  73.                         local name = getPlayerName(thePlayer)
  74.                         local phoneNumber = getElementData(thePlayer, "cellnumber")
  75.                        
  76.                         exports.logs:logMessage("AD: " .. message .. ". ((" .. name .. "))", 2)
  77.                         for key, value in ipairs(exports.pool:getPoolElementsByType("player")) do
  78.                             if (getElementData(value, "loggedin")==1 and not getElementData(value, "disableAds")) then
  79.                                 outputChatBox("   Advertisement: " .. message .. " #66ffff((" .. name .. "))", value, 10, 255, 200, true)
  80.                                
  81.                                 if (tonumber(showNumber)==1) then
  82.                                     outputChatBox("   Phone: #" .. phoneNumber .. ".", value, 10, 255, 200)
  83.                                 end
  84.                             end
  85.                         end
  86.                         outputChatBox("Thank you for placing your advert. Total Cost: $" .. cost .. ".", thePlayer)
  87.                         exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "ads", ( getElementData(thePlayer, "ads") or 0 ) + 1, false)
  88.                         exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "sanAdvert", 0)
  89.                         setTimer(
  90.                             function(p)
  91.                                 if isElement(p) then
  92.                                     local c =  getElementData(p, "ads") or 0
  93.                                     if c > 1 then
  94.                                         exports['anticheat-system']:changeProtectedElementDataEx(p, "ads", c-1, false)
  95.                                     else
  96.                                         exports['anticheat-system']:changeProtectedElementDataEx(p, "ads")
  97.                                     end
  98.                                 end
  99.                             end, 300000, 1, thePlayer
  100.                         )
  101.                     else
  102.                         outputChatBox("You cannot afford to place such an advert, try making it smaller.", thePlayer)
  103.                     end
  104.                 else
  105.                     outputChatBox("You do not have a cellphone to call the advertisement agency.", thePlayer, 255, 0, 0)
  106.                 end
  107.             end
  108.         --end
  109.     end
  110. end
  111. addCommandHandler("ad", advertMessage, false, false)
  112.  
  113. -- Main chat: Local IC, Me Actions & Faction IC Radio
  114. function localIC(source, message, language)
  115.     if exports['freecam-tv']:isPlayerFreecamEnabled(source) then return end
  116.    
  117.     local x, y, z = getElementPosition(source)
  118.     local playerName = getPlayerName(source)
  119.    
  120.     message = string.gsub(message, "#%x%x%x%x%x%x", "") -- Remove colour codes
  121.     local languagename = call(getResourceFromName("language-system"), "getLanguageName", language)
  122.     message = trunklateText( source, message )
  123.    
  124.     local playerVehicle = getPedOccupiedVehicle(source)
  125.     if playerVehicle then
  126.         if (exports['vehicle-system']:isVehicleWindowUp(playerVehicle)) then
  127.             exports.logs:logMessage("[IC: In Car] " .. playerName .. ": " .. message, 1)
  128.             outputChatBox( "#EEEEEE [In Character] " .. playerName .. " ((In Car)) says: " .. message, source, 133, 44, getElementData(source, "chatbubbles") == 2 and 89 or 88, true)     
  129.         else
  130.             exports.logs:logMessage("[IC: Local Chat] " .. playerName .. ": " .. message, 1)
  131.             outputChatBox( "#EEEEEE [In Character] " .. playerName .. " says: " .. message, source, 133, 44, getElementData(source, "chatbubbles") == 2 and 89 or 88, true)
  132.         end
  133.     else
  134.         exports.logs:logMessage("[IC: Local Chat] " .. playerName .. ": " .. message, 1)
  135.         outputChatBox( "#EEEEEE [In Character] " .. playerName .. " says: " .. message, source, 133, 44, getElementData(source, "chatbubbles") == 2 and 89 or 88, true)
  136.     end
  137.  
  138.     local dimension = getElementDimension(source)
  139.     local interior = getElementInterior(source)
  140.     local shownto = 1
  141.    
  142.     -- Chat Commands tooltip
  143.     if(getResourceFromName("tooltips-system"))then
  144.         triggerClientEvent(source,"tooltips:showHelp", source,17)
  145.     end
  146.    
  147.     for key, nearbyPlayer in ipairs(getElementsByType( "player" )) do
  148.         local dist = getElementDistance( source, nearbyPlayer )
  149.        
  150.         if dist < 20 then
  151.             local nearbyPlayerDimension = getElementDimension(nearbyPlayer)
  152.             local nearbyPlayerInterior = getElementInterior(nearbyPlayer)
  153.  
  154.             if (nearbyPlayerDimension==dimension) and (nearbyPlayerInterior==interior) then
  155.                 local logged = tonumber(getElementData(nearbyPlayer, "loggedin"))
  156.                 if not (isPedDead(nearbyPlayer)) and (logged==1) and (nearbyPlayer~=source) then
  157.                     local message2 = call(getResourceFromName("language-system"), "applyLanguage", source, nearbyPlayer, message, language)
  158.                     message2 = trunklateText( nearbyPlayer, message2 )
  159.                    
  160.                     local pveh = getPedOccupiedVehicle(source)
  161.                     local nbpveh = getPedOccupiedVehicle(nearbyPlayer)
  162.                     if pveh then
  163.                         if (exports['vehicle-system']:isVehicleWindowUp(pveh)) then
  164.                             for i = 0, getVehicleMaxPassengers(pveh) do
  165.                                 local lp = getVehicleOccupant(pveh, i)
  166.                                
  167.                                 if (lp) and (lp~=source) then
  168.                                     outputChatBox("#EEEEEE [In Character] " .. playerName .. " ((In Car)) says: " .. message2, lp, 133, 44, getElementData(lp, "chatbubbles") > 0 and 89 or 88, true)
  169.                                 end
  170.                             end
  171.                             if (getElementData(nearbyPlayer, "adminduty") == 1) and (getPedOccupiedVehicle(nearbyPlayer) ~= pveh) then
  172.                                 outputChatBox("#EEEEEE [In Character] " .. playerName .. " ((In Car)) says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  173.                             end
  174.                             return
  175.                         end
  176.                     end
  177.                     if nbpveh then
  178.                         if (exports['vehicle-system']:isVehicleWindowUp(nbpveh)) then
  179.                             if dist < 3 then
  180.                                 outputChatBox( "#EEEEEE [In Character] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  181.                             elseif dist < 6 then
  182.                                 outputChatBox( "#DDDDDD [In Character] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  183.                             elseif dist < 9 then
  184.                                 outputChatBox( "#CCCCCC [In Character] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  185.                             elseif dist < 12 then
  186.                                 outputChatBox( "#BBBBBB [In Character] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  187.                             else
  188.                                 outputChatBox( "#AAAAAA [In Character] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  189.                             end
  190.                         else
  191.                             if dist < 4 then
  192.                                 outputChatBox( "#EEEEEE [In Character] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  193.                             elseif dist < 8 then
  194.                                 outputChatBox( "#DDDDDD [In Character] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  195.                             elseif dist < 12 then
  196.                                 outputChatBox( "#CCCCCC [In Character] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  197.                             elseif dist < 16 then
  198.                                 outputChatBox( "#BBBBBB [In Character] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  199.                             else
  200.                                 outputChatBox( "#AAAAAA [In Character] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  201.                             end
  202.                         end
  203.                     elseif not nbpveh then
  204.                         if dist < 4 then
  205.                             outputChatBox( "#EEEEEE [In Character] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  206.                         elseif dist < 8 then
  207.                             outputChatBox( "#DDDDDD [In Character] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  208.                         elseif dist < 12 then
  209.                             outputChatBox( "#CCCCCC [In Character] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  210.                         elseif dist < 16 then
  211.                             outputChatBox( "#BBBBBB [In Character] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  212.                         else
  213.                             outputChatBox( "#AAAAAA [In Character] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  214.                         end
  215.                     end
  216.                    
  217.                     shownto = shownto + 1
  218.                 end
  219.             end
  220.         end
  221.     end
  222.    
  223.     exports['freecam-tv']:add(shownto, playerName .. " says: " .. message, source)
  224. end
  225.  
  226. for i = 1, 3 do
  227.     addCommandHandler( tostring( i ),
  228.         function( thePlayer, commandName, ... )
  229.             local lang = tonumber( getElementData( thePlayer, "languages.lang" .. i ) )
  230.             if lang ~= 0 then
  231.                 localIC( thePlayer, table.concat({...}, " "), lang )
  232.             end
  233.         end
  234.     )
  235. end
  236.  
  237. function meEmote(source, cmd, ...)
  238.     local logged = getElementData(source, "loggedin")
  239.     if not(isPedDead(source) and (logged == 1)) then
  240.         local message = table.concat({...}, " ")
  241.         if not (...) then
  242.             outputChatBox("SYNTAX: /me [Action]", source, 255, 194, 14)
  243.         else
  244.             exports.global:sendLocalMeAction(source, message)
  245.             exports.logs:logMessage("[IC OOC: ME ACTION] *" .. getPlayerName(source) .. " " .. message, 7)
  246.         end
  247.     end
  248. end
  249. addCommandHandler("ME", meEmote, false, true)
  250. addCommandHandler("Me", meEmote, false, true)
  251.  
  252. function radio(source, radioID, message)
  253.     radioID = tonumber(radioID) or 1
  254.     local hasRadio, itemKey, itemValue, itemID = exports.global:hasItem(source, 6)
  255.     if hasRadio then
  256.         local theChannel = itemValue
  257.         if radioID ~= 1 then
  258.             local count = 0
  259.             local items = exports['item-system']:getItems(source)
  260.             for k, v in ipairs(items) do
  261.                 if v[1] == 6 then
  262.                     count = count + 1
  263.                     if count == radioID then
  264.                         theChannel = v[2]
  265.                         break
  266.                     end
  267.                 end
  268.             end
  269.         end
  270.        
  271.         if theChannel == 1 then
  272.             outputChatBox("Please Tune your radio (( /tuneradio # ))", source, 255, 194, 14)
  273.         elseif theChannel > 1 then
  274.             triggerClientEvent (source, "playRadioSound", getRootElement())
  275.             local username = getPlayerName(source)
  276.             local languageslot = getElementData(source, "languages.current")
  277.             local language = getElementData(source, "languages.lang" .. languageslot)
  278.             local languagename = call(getResourceFromName("language-system"), "getLanguageName", language)
  279.            
  280.             local factionID = getElementData(source,"faction")
  281.             if not (factionID == -1) then
  282.                 local theTeam = getPlayerTeam(source)
  283.                 local factionrank = tonumber(getElementData(source,"factionrank"))
  284.                 local ranks = getElementData(theTeam,"ranks")
  285.                 factionRankTitle = ranks[factionrank] .. " - "
  286.             else
  287.                 factionRankTitle = ""
  288.             end
  289.            
  290.             message = trunklateText( source, message )
  291.             outputChatBox("[In Character] [RADIO #" .. theChannel .. "] " .. factionRankTitle .. username .. " says: " .. message, source, 0, 102, 255)
  292.            
  293.             for key, value in ipairs(getElementsByType( "player" )) do
  294.                 local logged = getElementData(source, "loggedin")
  295.                
  296.                 if (isElement(value)) and (logged==1) and (value~=source) then
  297.                     if (exports.global:hasItem(value, 6, theChannel)) then
  298.                         triggerClientEvent (value, "playRadioSound", getRootElement())
  299.  
  300.                         local message2 = call(getResourceFromName("language-system"), "applyLanguage", source, value, message, language)
  301.                         outputChatBox("[In Character] [RADIO #" .. theChannel .. "] " .. factionRankTitle .. username .. " says: " .. trunklateText( value, message2 ), value, 0, 102, 255)
  302.                        
  303.                        
  304.                         if (exports.global:hasItem(value, 88) == false) then
  305.                             -- Show it to people near who can hear his radio
  306.                             for k, v in ipairs(exports.global:getNearbyElements(value, "player",7)) do
  307.                             local logged2 = getElementData(v, "loggedin")
  308.                                 if (logged2==1) then
  309.                                     if (exports.global:hasItem(v, 6, targetChannel) == false) then
  310.                                         local message2 = call(getResourceFromName("language-system"), "applyLanguage", source, v, message, language)
  311.                                         outputChatBox("[In Character] " .. getPlayerName(value) .. "'s Radio: " .. trunklateText( v, message2 ), v, 255, 255, 255)
  312.                                     end
  313.                                 end
  314.                             end
  315.                         end
  316.                     end
  317.                 end
  318.             end
  319.            
  320.             --Show the radio to nearby listening in people near the speaker
  321.             for key, value in ipairs(getElementsByType("player")) do
  322.                 if getElementDistance(source, value) < 10 then
  323.                     if (value~=source) then
  324.                         local message2 = call(getResourceFromName("language-system"), "applyLanguage", source, value, message, language)
  325.                         outputChatBox("[In Character] " .. getPlayerName(source) .. " [RADIO] says: " .. message2, value, 255, 255, 255)
  326.                     end
  327.                 end
  328.             end
  329.         else
  330.             outputChatBox("Your radio is off. ((/toggleradio))", source, 255, 0, 0)
  331.         end
  332.     else
  333.         outputChatBox("You do not have a radio.", source, 255, 0, 0)
  334.     end
  335. end
  336.  
  337. function chatMain(message, messageType)
  338.     if exports['freecam-tv']:isPlayerFreecamEnabled(source) then cancelEvent() return end
  339.    
  340.     local logged = getElementData(source, "loggedin")
  341.    
  342.     if not (isPedDead(source)) and (logged==1) and not (messageType==2) then -- Player cannot chat while dead or not logged in, unless its OOC
  343.         local dimension = getElementDimension(source)
  344.         local interior = getElementInterior(source)
  345.         -- Local IC
  346.         if (messageType==0) then
  347.             local languageslot = getElementData(source, "languages.current")
  348.             local language = getElementData(source, "languages.lang" .. languageslot)
  349.             localIC(source, message, language)
  350.         elseif (messageType==1) then -- Local /me action
  351.             meEmote(source, "me", message)
  352.         end
  353.     elseif (messageType==2) and (logged==1) then -- Radio
  354.         radio(source, 1, message)
  355.     end
  356. end
  357. addEventHandler("onPlayerChat", getRootElement(), chatMain)
  358.  
  359. function chatMain()
  360.    
  361.     if not getElementData(source, "loggedin") then     
  362.              outputChatBox("You need to be logged in to chat!",source,255,255,0)
  363.     end
  364.        
  365. end
  366. addEventHandler("onPlayerChat", getRootElement(), chatMain)
  367.  
  368. function msgRadio(thePlayer, commandName, ...)
  369.     if (...) then
  370.         local message = table.concat({...}, " ")
  371.         radio(thePlayer, 1, message)
  372.     else
  373.         outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  374.     end
  375. end
  376. addCommandHandler("r", msgRadio, false, false)
  377. addCommandHandler("radio", msgRadio, false, false)
  378.  
  379. for i = 1, 20 do
  380.     addCommandHandler( "r" .. tostring( i ),
  381.         function( thePlayer, commandName, ... )
  382.             if i <= exports['item-system']:countItems(thePlayer, 6) then
  383.                 radio( thePlayer, i, table.concat({...}, " ") )
  384.             end
  385.         end
  386.     )
  387. end
  388.  
  389. function govAnnouncement(thePlayer, commandName, ...)
  390.     local theTeam = getPlayerTeam(thePlayer)
  391.    
  392.     if (theTeam) then
  393.         local teamID = tonumber(getElementData(theTeam, "id"))
  394.    
  395.         if (teamID==1 or teamID==2 --[[or teamID==3]] or teamID==35) then
  396.             local message = table.concat({...}, " ")
  397.             local factionRank = tonumber(getElementData(thePlayer,"factionrank"))
  398.            
  399.             if (factionRank<8) then
  400.                 outputChatBox("You do not have permission to use this command.", thePlayer, 255, 0, 0)
  401.             elseif #message == 0 then
  402.                 outputChatBox("SYNTAX: " .. commandName .. " [message]", thePlayer, 255, 194, 14)
  403.             else
  404.                 local ranks = getElementData(theTeam,"ranks")
  405.                 local factionRankTitle = ranks[factionRank]
  406.                
  407.                 exports.logs:logMessage("[IC: Government Message] " .. factionRankTitle .. " " .. getPlayerName(thePlayer) .. ": " .. message, 6)
  408.                
  409.                 for key, value in ipairs(exports.pool:getPoolElementsByType("player")) do
  410.                     local logged = getElementData(value, "loggedin")
  411.                    
  412.                     if (logged==1) then
  413.                         outputChatBox(">> Government Announcement from " .. factionRankTitle .. " " .. getPlayerName(thePlayer), value, 0, 183, 239)
  414.                         outputChatBox(message, value, 0, 183, 239)
  415.                     end
  416.                 end
  417.             end
  418.         end
  419.     end
  420. end
  421. addCommandHandler("gov", govAnnouncement)
  422.  
  423. function playerToggleDonatorChat(thePlayer, commandName)
  424.     local logged = getElementData(thePlayer, "loggedin")
  425.    
  426.     if (logged==1) then
  427.         local enabled = getElementData(thePlayer, "donatorchat")
  428.        
  429.         if (enabled==1) then
  430.             outputChatBox("You have now hidden Donator Chat.", thePlayer, 255, 194, 14)
  431.             exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "donatorchat", 0, false)
  432.         else
  433.             outputChatBox("You have now enabled Donator Chat.", thePlayer, 255, 194, 14)
  434.             exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "donatorchat", 1, false)
  435.         end
  436.         mysql:query_free("UPDATE accounts SET donatorchat=" .. mysql:escape_string(getElementData(thePlayer, "donatorchat")) .. " WHERE id = " .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")))
  437.     end
  438. end
  439. addCommandHandler("toggledonatorchat", playerToggleDonatorChat, false, false)
  440. addCommandHandler("toggledon", playerToggleDonatorChat, false, false)
  441. addCommandHandler("toggledchat", playerToggleDonatorChat, false, false)
  442.  
  443. function donatorchat(thePlayer, commandName, ...)
  444.     if ( exports.global:isPlayerBronzeDonator(thePlayer) or exports.global:isPlayerAdmin(thePlayer) ) then
  445.         if not (...) then
  446.             outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  447.         else
  448.             local message = table.concat({...}, " ")
  449.             local title = ""
  450.             local hidden = getElementData(thePlayer, "hiddenadmin") or 0
  451.  
  452.             if ( exports.global:isPlayerAdmin(thePlayer) ) then
  453.                 if (hidden == 1) or (exports.global:getPlayerAdminTitle(thePlayer) == "Player") then
  454.                     if not (exports.global:isPlayerBronzeDonator(thePlayer)) then
  455.                         title = "Bronze Donator"
  456.                     else
  457.                         title = exports.global:getPlayerDonatorTitle(thePlayer)
  458.                     end
  459.                 else
  460.                     title = exports.global:getPlayerAdminTitle(thePlayer)
  461.                 end
  462.             elseif ( exports.global:isPlayerBronzeDonator(thePlayer) ) then
  463.                 title = exports.global:getPlayerDonatorTitle(thePlayer)
  464.             end
  465.                
  466.             for key, value in ipairs(getElementsByType("player")) do
  467.                 if ( exports.global:isPlayerBronzeDonator(value) or exports.global:isPlayerAdmin(value) ) then
  468.                     if ( getElementData(value, "donatorchat") == 1 ) then
  469.                         outputChatBox("[Donator] " .. title .. " " .. getPlayerName(thePlayer) .. ": " .. message, value, 160, 164, 104)
  470.                     end
  471.                 end
  472.             end
  473.         end
  474.     end
  475. end
  476. addCommandHandler("donator", donatorchat, false, false)
  477. addCommandHandler("don", donatorchat, false, false)
  478. addCommandHandler("dchat", donatorchat, false, false)
  479.  
  480. --[[function donatorchat(thePlayer, commandName, ...)
  481.             helper = getElementData(theplayer,"helper")
  482.     if helper > 0 getElementData(theplayer,"helper") > 0 or exports.global:isPlayerAdmin(thePlayer) ) then
  483.         if not (...) then
  484.             outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  485.         else
  486.             local message = table.concat({...}, " ")
  487.             local title = ""
  488.             local hidden = getElementData(thePlayer, "hiddenadmin") or 0
  489.  
  490.             if ( exports.global:isPlayerAdmin(thePlayer) ) then
  491.                 if (hidden == 1) or (exports.global:getPlayerAdminTitle(thePlayer) == "Player") then
  492.                
  493.                         title = "Helper"
  494.                
  495.                    
  496.                 else
  497.                     title = exports.global:getPlayerAdminTitle(thePlayer)
  498.                 end
  499.            
  500.             end
  501.                
  502.             for key, value in ipairs(getElementsByType("player")) do
  503.                 if getElementData(value,"helper") > 0  or exports.global:isPlayerAdmin(value) ) then
  504.                    
  505.                         outputChatBox("[GM Chat] " .. title .. " " .. getPlayerName(thePlayer) .. ": " .. message, value, 255, 204, 255)
  506.                    
  507.                 end
  508.             end
  509.         end
  510.     end
  511. end
  512. addCommandHandler("gm", donatorchat, false, false)]]
  513.  
  514.  
  515. function departmentradio(thePlayer, commandName, ...)
  516.     local theTeam = getPlayerTeam(thePlayer)
  517.    
  518.     if (theTeam) then
  519.         local teamID = tonumber(getElementData(theTeam, "id"))
  520.  
  521.         if (teamID==1 or teamID==2 or teamID==3 or teamID == 30 or teamID == 71 or teamID == 36) then
  522.             if (...) then
  523.                 local message = trunklateText( thePlayer, table.concat({...}, " ") )
  524.                 local PDFaction = getPlayersInTeam(getTeamFromName("Los Santos Police Department"))
  525.                 local ESFaction = getPlayersInTeam(getTeamFromName("Los Santos Emergency Services"))
  526.                 local TowFaction = getPlayersInTeam(getTeamFromName("Los Santos Towing and Recovery"))
  527.                 local GovFaction = getPlayersInTeam(getTeamFromName("Government of Los Santos"))
  528.                 local SACFFaction = getPlayersInTeam(getTeamFromName("San Andreas Correctional Facility"))
  529.                 local CorFaction = getPlayersInTeam(getTeamFromName("First Court of San Andreas"))
  530.                 local playerName = getPlayerName(thePlayer)
  531.                
  532.                 exports.logs:logMessage("[IC: Department Radio] " .. playerName .. ": " .. message, 6)
  533.                
  534.                 for key, value in ipairs(PDFaction) do
  535.                     outputChatBox("[DEPARTMENT RADIO] " .. playerName .. " says: " .. message, value, 0, 102, 255)
  536.                 end
  537.                
  538.                 for key, value in ipairs(ESFaction) do
  539.                     outputChatBox("[DEPARTMENT RADIO] " .. playerName .. " says: " .. message, value, 0, 102, 255)
  540.                 end
  541.                
  542.                 for key, value in ipairs(TowFaction) do
  543.                     outputChatBox("[DEPARTMENT RADIO] " .. playerName .. " says: " .. message, value, 0, 102, 255)
  544.                 end
  545.                
  546.                 for key, value in ipairs(GovFaction) do
  547.                     outputChatBox("[DEPARTMENT RADIO] " .. playerName .. " says: " .. message, value, 0, 102, 255)
  548.                 end
  549.                
  550.                 for key, value in ipairs(SACFFaction) do
  551.                     outputChatBox("[DEPARTMENT RADIO] " .. playerName .. " says: " .. message, value, 0, 102, 255)
  552.                 end
  553.                
  554.                 for key, value in ipairs(CorFaction) do
  555.                     outputChatBox("[DEPARTMENT RADIO] " .. playerName .. " says: " .. message, value, 0, 102, 255)
  556.                 end
  557.             else
  558.                 outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  559.             end
  560.         end
  561.     end
  562. end
  563. addCommandHandler("d", departmentradio, false, false)
  564. addCommandHandler("department", departmentradio, false, false)
  565.  
  566. function blockChatMessage()
  567.     cancelEvent()
  568. end
  569.  
  570. addEventHandler("onPlayerChat", getRootElement(), blockChatMessage)
  571. -- End of Main Chat
  572.  
  573. function globalOOC(thePlayer, commandName, ...)
  574.     local logged = tonumber(getElementData(thePlayer, "loggedin"))
  575.    
  576.     if (logged==1) then
  577.         if not (...) then
  578.             outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  579.         else
  580.             local oocEnabled = exports.global:getOOCState()
  581.             message = table.concat({...}, " ")
  582.             local muted = getElementData(thePlayer, "muted")
  583.             if (oocEnabled==0) and not (exports.global:isPlayerAdmin(thePlayer)) then
  584.                 outputChatBox("OOC Chat is currently disabled.", thePlayer, 255, 0, 0)
  585.             elseif (muted==1) then
  586.                 outputChatBox("You are currenty muted from the OOC Chat.", thePlayer, 255, 0, 0)
  587.             else
  588.                 local players = exports.pool:getPoolElementsByType("player")
  589.                 local playerName = getPlayerName(thePlayer)
  590.                 local playerID = getElementData(thePlayer, "playerid")
  591.                    
  592.                 exports.logs:logMessage("[OOC: Global Chat] " .. playerName .. ": " .. message, 1)
  593.                 for k, arrayPlayer in ipairs(players) do
  594.                     local logged = tonumber(getElementData(arrayPlayer, "loggedin"))
  595.                     local targetOOCEnabled = getElementData(arrayPlayer, "globalooc")
  596.                     local adminlevel = exports.global:getPlayerAdminLevel(thePlayer)
  597.                     title = exports.global:getPlayerAdminTitle(thePlayer)
  598.                     if adminlevel >= 4 then
  599.                          color = "#CC0000"
  600.                     else
  601.                          color = "#00ff00"
  602.                     end
  603.                    
  604.                     if adminlevel == 0 or getElementData(thePlayer,"hiddenadmin") == 1 then
  605.                         title = false
  606.                     end
  607.                     if  exports.global:getPlayerDonatorLevel(thePlayer) > 0 and exports.global:getPlayerAdminLevel(thePlayer) == 0 then
  608.                         color = "#CC9933"
  609.                         title = "Donator"
  610.                     end
  611.                     if (logged==1) and (targetOOCEnabled==1) then
  612.  
  613.                     if  title and color then
  614.                         outputChatBox("(( [GOOC] (" .. playerID .. ") ["..color.."" ..title.. "#ffe4c4] " .. playerName .. ": " .. message.." ))",arrayPlayer, 255,228,196,true)
  615.                     else
  616.                         outputChatBox("(( [GOOC] (" .. playerID .. ") " .. playerName .. ": " .. message.." ))", arrayPlayer, 255,228,196,true)
  617.                     end
  618.                     end
  619.                 end
  620.             end
  621.         end
  622.     end
  623. end
  624. addCommandHandler("o", globalOOC, false, false)
  625. addCommandHandler("GlobalOOC", globalOOC)
  626.  
  627. function playerToggleOOC(thePlayer, commandName)
  628.     local logged = getElementData(thePlayer, "loggedin")
  629.    
  630.     if (logged==1) then
  631.         local playerOOCEnabled = getElementData(thePlayer, "globalooc")
  632.        
  633.         if (playerOOCEnabled==1) then
  634.             outputChatBox("You have now hidden Global OOC Chat.", thePlayer, 255, 194, 14)
  635.             exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "globalooc", 0, false)
  636.         else
  637.             outputChatBox("You have now enabled Global OOC Chat.", thePlayer, 255, 194, 14)
  638.             exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "globalooc", 1, false)
  639.         end
  640.         mysql:query_free("UPDATE accounts SET globalooc=" .. mysql:escape_string(getElementData(thePlayer, "globalooc")) .. " WHERE id = " .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")))
  641.     end
  642. end
  643. addCommandHandler("toggleooc", playerToggleOOC, false, false)
  644.  
  645.  
  646. local advertisementMessages = { "samp", "SA-MP", "vedic", "grimz","paradox","server", "sincityrp", "ls-rp", "sincity", "twd", "virtua", "vg", "valhalla", "www.", ".com", ".net", ".co.uk", ".org", "Bryan", "Danny", "everlast", "neverlast", "www.everlastgaming.com"}
  647.  
  648. function isFriendOf(thePlayer, targetPlayer)
  649.     local friends = getElementData(targetPlayer, "friends")
  650.     if friends then
  651.         local targetID = tonumber( getElementData( thePlayer, "gameaccountid" ) )
  652.         if friends[ targetID ] then
  653.             return true
  654.         end
  655.     end
  656.     return false
  657. end
  658.  
  659. function pmPlayer(thePlayer, commandName, who, ...)
  660.     if not (who) or not (...) then
  661.         outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick] [Message]", thePlayer, 255, 194, 14)
  662.     else
  663.         message = table.concat({...}, " ")
  664.        
  665.         local loggedIn = getElementData(thePlayer, "loggedin")
  666.         if (loggedIn==0) then
  667.             return
  668.         end
  669.        
  670.         local targetPlayer, targetPlayerName
  671.         if (isElement(who)) then
  672.             if (getElementType(who)=="player") then
  673.                 targetPlayer = who
  674.                 targetPlayerName = getPlayerName(who)
  675.                 message = string.gsub(message, string.gsub(targetPlayerName, " ", "_", 1) .. " ", "", 1)
  676.             end
  677.         else
  678.             targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, who)
  679.         end
  680.        
  681.         if (targetPlayer) then
  682.             local logged = getElementData(targetPlayer, "loggedin")
  683.             local pmblocked = getElementData(targetPlayer, "pmblocked")
  684.  
  685.             if not (pmblocked) then
  686.                 pmblocked = 0
  687.                 exports['anticheat-system']:changeProtectedElementDataEx(targetPlayer, "pmblocked", 0, false)
  688.             end
  689.            
  690.             if (logged==1) and not getElementData(targetPlayer, "disablePMs") and (pmblocked==0 or exports.global:isPlayerAdmin(thePlayer) or exports.global:isPlayerScripter(thePlayer) or getElementData(thePlayer, "reportadmin") == targetPlayer or isFriendOf(thePlayer, targetPlayer)) then
  691.                 local playerName = getPlayerName(thePlayer):gsub("_", " ")
  692.                
  693.                 if not exports.global:isPlayerScripter(thePlayer) and not exports.global:isPlayerScripter(targetPlayer) then
  694.                     -- Check for advertisements
  695.                     for k,v in ipairs(advertisementMessages) do
  696.                         local found = string.find(string.lower(message), "%s" .. tostring(v))
  697.                         local found2 = string.find(string.lower(message), tostring(v) .. "%s")
  698.                         if (found) or (found2) or (string.lower(message)==tostring(v)) then
  699.                             exports.global:sendMessageToAdmins("AdmWrn: " .. tostring(playerName) .. " sent a possible advertisement PM to " .. tostring(targetPlayerName) .. ".")
  700.                             exports.global:sendMessageToAdmins("AdmWrn: Message: " .. tostring(message))
  701.                             break
  702.                         end
  703.                     end
  704.                 end
  705.                
  706.                 -- Send the message
  707.                 local playerid = getElementData(thePlayer, "playerid")
  708.                 local targetid = getElementData(targetPlayer, "playerid")
  709.                 outputChatBox("Msg From (" .. playerid .. ") " .. playerName .. ": " .. message, targetPlayer, 173,255,47)
  710.                 outputChatBox("Msg Sent to (" .. targetid .. ") " .. targetPlayerName .. ": " .. message, thePlayer, 173,255,47)
  711.                
  712.                 exports.logs:logMessage("[PM From " ..playerName .. " TO " .. targetPlayerName .. "]" .. message, 8)
  713.                 outputDebugString("[PM From " ..playerName .. " TO " .. targetPlayerName .. "]" .. message)
  714.                
  715.                 if not exports.global:isPlayerScripter(thePlayer) and not exports.global:isPlayerScripter(targetPlayer) then
  716.                     -- big ears
  717.                     local received = {}
  718.                     received[thePlayer] = true
  719.                     received[targetPlayer] = true
  720.                     for key, value in pairs( getElementsByType( "player" ) ) do
  721.                         if isElement( value ) and not received[value] then
  722.                             local listening = getElementData( value, "bigears" )
  723.                             if listening == thePlayer or listening == targetPlayer then
  724.                                 received[value] = true
  725.                                 outputChatBox("(" .. playerid .. ") " .. playerName .. " -> (" .. targetid .. ") " .. targetPlayerName .. ": " .. message, value, 255, 255, 0)
  726.                             end
  727.                         end
  728.                     end
  729.                 end
  730.             elseif (logged==0) then
  731.                 outputChatBox("Player is not logged in yet.", thePlayer, 255, 255, 0)
  732.             elseif (pmblocked==1) then
  733.                 outputChatBox("Player is ignoring whispers!", thePlayer, 255, 255, 0)
  734.             end
  735.         end
  736.     end
  737. end
  738. addCommandHandler("pm", pmPlayer, false, false)
  739.  
  740. function localOOC(thePlayer, commandName, ...)
  741.     if exports['freecam-tv']:isPlayerFreecamEnabled(thePlayer) then return end
  742.    
  743.     local logged = getElementData(thePlayer, "loggedin")
  744.     local dimension = getElementDimension(thePlayer)
  745.     local interior = getElementInterior(thePlayer)
  746.        
  747.     if (logged==1) and not (isPedDead(thePlayer)) then
  748.         local muted = getElementData(thePlayer, "muted")
  749.         if not (...) then
  750.             outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  751.         elseif (muted==1) then
  752.             outputChatBox("You are currenty muted from the OOC Chat.", thePlayer, 255, 0, 0)
  753.         else
  754.             exports.global:sendLocalText(thePlayer, "[LOOC] "..getPlayerName(thePlayer) .. ": (( " .. table.concat({...}, " ") .. " ))",127,255,212)
  755.             exports.logs:logMessage("[OOC: Local Chat] " .. getPlayerName(thePlayer) .. ": " .. table.concat({...}, " "), 1)
  756.         end
  757.     end
  758. end
  759. addCommandHandler("b", localOOC, false, false)
  760. addCommandHandler("LocalOOC", localOOC)
  761.  
  762. function districtIC(thePlayer, commandName, ...)
  763.     if exports['freecam-tv']:isPlayerFreecamEnabled(thePlayer) then return end
  764.    
  765.     local logged = getElementData(thePlayer, "loggedin")
  766.     local dimension = getElementDimension(thePlayer)
  767.     local interior = getElementInterior(thePlayer)
  768.    
  769.     if (logged==1) and not (isPedDead(thePlayer)) then
  770.         if not (...) then
  771.             outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  772.         else
  773.             local playerName = getPlayerName(thePlayer)
  774.             local message = table.concat({...}, " ")
  775.             local zonename = exports.global:getElementZoneName(thePlayer)
  776.            
  777.             for key, value in ipairs(exports.pool:getPoolElementsByType("player")) do
  778.                 local playerzone = exports.global:getElementZoneName(value)
  779.                 local playerdimension = getElementDimension(value)
  780.                 local playerinterior = getElementInterior(value)
  781.                
  782.                 if (zonename==playerzone) and (dimension==playerdimension) and (interior==playerinterior) then
  783.                     local logged = getElementData(value, "loggedin")
  784.                     if (logged==1) then
  785.                         outputChatBox("District IC: " .. message .. " ((".. playerName .."))", value, 255, 255, 255)
  786.                     end
  787.                 end
  788.             end
  789.         end
  790.     end
  791. end
  792. addCommandHandler("district", districtIC, false, false)
  793.  
  794. function localDo(thePlayer, commandName, ...)
  795.     if exports['freecam-tv']:isPlayerFreecamEnabled(thePlayer) then return end
  796.    
  797.     local logged = getElementData(thePlayer, "loggedin")
  798.     local dimension = getElementDimension(thePlayer)
  799.     local interior = getElementInterior(thePlayer)
  800.        
  801.     if not (isPedDead(thePlayer)) and (logged==1) then
  802.         if not (...) then
  803.             outputChatBox("SYNTAX: /" .. commandName .. " [Action/Event]", thePlayer, 255, 194, 14)
  804.         else
  805.             local message = table.concat({...}, " ")
  806.             exports.logs:logMessage("[IC: Local Do] * " .. message .. " *      ((" .. getPlayerName(thePlayer) .. "))", 19)
  807.             exports.global:sendLocalDoAction(thePlayer, message)
  808.         end
  809.     end
  810. end
  811. addCommandHandler("do", localDo, false, false)
  812.  
  813.  
  814. function localShout(thePlayer, commandName, ...)
  815.     if exports['freecam-tv']:isPlayerFreecamEnabled(thePlayer) then return end
  816.    
  817.     local logged = getElementData(thePlayer, "loggedin")
  818.     local dimension = getElementDimension(thePlayer)
  819.     local interior = getElementInterior(thePlayer)
  820.        
  821.     if not (isPedDead(thePlayer)) and (logged==1) then
  822.         if not (...) then
  823.             outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  824.         else
  825.             local playerName = getPlayerName(thePlayer)
  826.            
  827.             local languageslot = getElementData(thePlayer, "languages.current")
  828.             local language = getElementData(thePlayer, "languages.lang" .. languageslot)
  829.             local languagename = call(getResourceFromName("language-system"), "getLanguageName", language)
  830.            
  831.             local message = trunklateText(thePlayer, table.concat({...}, " "))
  832.             outputChatBox("[In Character] " .. playerName .. " shouts: " .. message .. "!!", thePlayer, 255, 255, 255)
  833.             exports.logs:logMessage("[IC: Local Shout] " .. playerName .. ": " .. message, 1)
  834.             for index, nearbyPlayer in ipairs(getElementsByType("player")) do
  835.                 if getElementDistance( thePlayer, nearbyPlayer ) < 40 then
  836.                     local nearbyPlayerDimension = getElementDimension(nearbyPlayer)
  837.                     local nearbyPlayerInterior = getElementInterior(nearbyPlayer)
  838.                    
  839.                     if (nearbyPlayerDimension==dimension) and (nearbyPlayerInterior==interior) and (nearbyPlayer~=thePlayer) then
  840.                         local logged = getElementData(nearbyPlayer, "loggedin")
  841.                        
  842.                         if (logged==1) and not (isPedDead(nearbyPlayer)) then
  843.                             --local mode = tonumber(getElementData(nearbyPlayer, "chatbubbles"))
  844.                             local message2 = call(getResourceFromName("language-system"), "applyLanguage", thePlayer, nearbyPlayer, message, language)
  845.                             message2 = trunklateText(nearbyPlayer, message2)
  846.                             --if mode > 0 then
  847.                             --  triggerClientEvent(nearbyPlayer, "onMessageIncome", thePlayer, message2, mode)
  848.                             --end
  849.                             outputChatBox("[In Character] " .. playerName .. " shouts: " .. message2 .. "!!", nearbyPlayer, 255, 255, 255)
  850.                         end
  851.                     end
  852.                 end
  853.             end
  854.         end
  855.     end
  856. end
  857. addCommandHandler("s", localShout, false, false)
  858.  
  859. function megaphoneShout(thePlayer, commandName, ...)
  860.     if exports['freecam-tv']:isPlayerFreecamEnabled(thePlayer) then return end
  861.    
  862.     local logged = getElementData(thePlayer, "loggedin")
  863.     local dimension = getElementDimension(thePlayer)
  864.     local interior = getElementInterior(thePlayer)
  865.        
  866.     if not (isPedDead(thePlayer)) and (logged==1) then
  867.         local faction = getPlayerTeam(thePlayer)
  868.         local factiontype = getElementData(faction, "type")
  869.        
  870.         if (factiontype==2) or (factiontype==3) or (factiontype==4) then
  871.             if not (...) then
  872.                 outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  873.             else
  874.                 local playerName = getPlayerName(thePlayer)
  875.                 local message = trunklateText(thePlayer, table.concat({...}, " "))
  876.                
  877.                 local languageslot = getElementData(thePlayer, "languages.current")
  878.                 local language = getElementData(thePlayer, "languages.lang" .. languageslot)
  879.                 local langname = call(getResourceFromName("language-system"), "getLanguageName", language)
  880.                
  881.                 for index, nearbyPlayer in ipairs(getElementsByType("player")) do
  882.                     if getElementDistance( thePlayer, nearbyPlayer ) < 40 then
  883.                         local nearbyPlayerDimension = getElementDimension(nearbyPlayer)
  884.                         local nearbyPlayerInterior = getElementInterior(nearbyPlayer)
  885.                        
  886.                         if (nearbyPlayerDimension==dimension) and (nearbyPlayerInterior==interior) then
  887.                             local logged = getElementData(nearbyPlayer, "loggedin")
  888.                        
  889.                             if (logged==1) and not (isPedDead(nearbyPlayer)) then
  890.                                 local message2 = message
  891.                                 if nearbyPlayer ~= thePlayer then
  892.                                     message2 = call(getResourceFromName("language-system"), "applyLanguage", thePlayer, nearbyPlayer, message, language)
  893.                                 end
  894.                                 outputChatBox(" [" .. langname .. "] ((" .. playerName .. ")) Megaphone <O: " .. trunklateText(nearbyPlayer, message2), nearbyPlayer, 255, 255, 0)
  895.                             end
  896.                         end
  897.                     end
  898.                 end
  899.             end
  900.         else
  901.             outputChatBox("Believe it or not, it's hard to shout through a megaphone you do not have.", thePlayer, 255, 0 , 0)
  902.         end
  903.     end
  904. end
  905. addCommandHandler("m", megaphoneShout, false, false)
  906.  
  907. local togState = { }
  908. function toggleFaction(thePlayer, commandName, State)
  909.     local pF = getElementData(thePlayer, "faction")
  910.     local fL = getElementData(thePlayer, "factionleader")
  911.     local theTeam = getPlayerTeam(thePlayer)
  912.  
  913.     if fL == 1 then
  914.         if togState[pF] == false or not togState[pF] then
  915.             togState[pF] = true
  916.             outputChatBox("Faction chat is now disabled.", thePlayer)
  917.             for index, arrayPlayer in ipairs( getElementsByType( "player" ) ) do
  918.                 if isElement( arrayPlayer ) then
  919.                     if getPlayerTeam( arrayPlayer ) == theTeam and getElementData(thePlayer, "loggedin") == 1 then
  920.                         outputChatBox("OOC Faction Chat Disabled", arrayPlayer, 255, 0, 0)
  921.                     end
  922.                 end
  923.             end
  924.         else
  925.             togState[pF] = false
  926.             outputChatBox("Faction chat is now enabled.", thePlayer)
  927.             for index, arrayPlayer in ipairs( getElementsByType( "player" ) ) do
  928.                 if isElement( arrayPlayer ) then
  929.                     if getPlayerTeam( arrayPlayer ) == theTeam and getElementData(thePlayer, "loggedin") == 1 then
  930.                         outputChatBox("OOC Faction Chat Enabled", arrayPlayer, 0, 255, 0)
  931.                     end
  932.                 end
  933.             end
  934.         end
  935.     end
  936. end
  937. addCommandHandler("togglef", toggleFaction)
  938. addCommandHandler("togf", toggleFaction)
  939.  
  940. function factionOOC(thePlayer, commandName, ...)
  941.     local logged = getElementData(thePlayer, "loggedin")
  942.  
  943.     if (logged==1) then
  944.         if not (...) then
  945.             outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  946.         else
  947.             local theTeam = getPlayerTeam(thePlayer)
  948.             local theTeamName = getTeamName(theTeam)
  949.             local playerName = getPlayerName(thePlayer)
  950.             local playerFaction = getElementData(thePlayer, "faction")
  951.            
  952.             if not(theTeam) or (theTeamName=="Citizen") then
  953.                 outputChatBox("You are not in a faction.", thePlayer)
  954.             else
  955.                 local message = table.concat({...}, " ")
  956.                
  957.                 if (togState[playerFaction]) == true then
  958.                     return
  959.                 end
  960.                 exports.logs:logMessage("[OOC: " .. theTeamName .. "] " .. playerName .. ": " .. message, 6)
  961.            
  962.                 for index, arrayPlayer in ipairs( getElementsByType( "player" ) ) do
  963.                     if isElement( arrayPlayer ) then
  964.                         if getElementData( arrayPlayer, "bigearsfaction" ) == theTeam then
  965.                             outputChatBox("((" .. theTeamName .. ")) " .. playerName .. ": " .. message, arrayPlayer, 3, 157, 157)
  966.                         elseif getPlayerTeam( arrayPlayer ) == theTeam and getElementData(thePlayer, "loggedin") == 1 then
  967.                             outputChatBox("((OOC Faction Chat)) " .. playerName .. ": " .. message, arrayPlayer, 3, 237, 237)
  968.                         end
  969.                     end
  970.                 end
  971.             end
  972.         end
  973.     end
  974. end
  975. addCommandHandler("f", factionOOC, false, false)
  976.  
  977. function setRadioChannel(thePlayer, commandName, slot, channel)
  978.     slot = tonumber( slot )
  979.     channel = tonumber( channel )
  980.    
  981.     if not channel then
  982.         channel = slot
  983.         slot = 1
  984.     end
  985.    
  986.     if not (channel) then
  987.         outputChatBox("SYNTAX: /" .. commandName .. " [Radio Slot] [Channel Number]", thePlayer, 255, 194, 14)
  988.     else
  989.         if (exports.global:hasItem(thePlayer, 6)) then
  990.             local count = 0
  991.             local items = exports['item-system']:getItems(thePlayer)
  992.             for k, v in ipairs( items ) do
  993.                 if v[1] == 6 then
  994.                     count = count + 1
  995.                     if count == slot then
  996.                         if v[2] > 0 then
  997.                             if channel > 0 and channel < 1000000000 then
  998.                                 if exports['item-system']:updateItemValue(thePlayer, k, channel) then
  999.                                     outputChatBox("You retuned your radio to channel #" .. channel .. ".", thePlayer)
  1000.                                     exports.global:sendLocalMeAction(thePlayer, "retunes their radio.")
  1001.                                 end
  1002.                             else
  1003.                                 outputChatBox("You can't tune your radio to that frequency!", thePlayer, 255, 0, 0)
  1004.                             end
  1005.                         else
  1006.                             outputChatBox("Your radio is off. ((/toggleradio))", thePlayer, 255, 0, 0)
  1007.                         end
  1008.                         return
  1009.                     end
  1010.                 end
  1011.             end
  1012.             outputChatBox("You do not have that many radios.", thePlayer, 255, 0, 0)
  1013.         else
  1014.             outputChatBox("You do not have a radio!", thePlayer, 255, 0, 0)
  1015.         end
  1016.     end
  1017. end
  1018. addCommandHandler("tuneradio", setRadioChannel, false, false)
  1019.  
  1020. function toggleRadio(thePlayer, commandName, slot)
  1021.     if (exports.global:hasItem(thePlayer, 6)) then
  1022.         local slot = tonumber( slot )
  1023.         local items = exports['item-system']:getItems(thePlayer)
  1024.         local titemValue = false
  1025.         local count = 0
  1026.         for k, v in ipairs( items ) do
  1027.             if v[1] == 6 then
  1028.                 if slot then
  1029.                     count = count + 1
  1030.                     if count == slot then
  1031.                         titemValue = v[2]
  1032.                         break
  1033.                     end
  1034.                 else
  1035.                     titemValue = v[2]
  1036.                     break
  1037.                 end
  1038.             end
  1039.         end
  1040.        
  1041.         -- gender switch for /me
  1042.         local genderm = getElementData(thePlayer, "gender") == 1 and "her" or "his"
  1043.        
  1044.         if titemValue < 0 then
  1045.             outputChatBox("You turned your radio on.", thePlayer, 255, 194, 14)
  1046.             exports.global:sendLocalMeAction(thePlayer, "turns " .. genderm .. " radio on.")
  1047.         else
  1048.             outputChatBox("You turned your radio off.", thePlayer, 255, 194, 14)
  1049.             exports.global:sendLocalMeAction(thePlayer, "turns " .. genderm .. " radio off.")
  1050.         end
  1051.         --exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "radiochannel", channel, false)
  1052.        
  1053.         local count = 0
  1054.         for k, v in ipairs( items ) do
  1055.             if v[1] == 6 then
  1056.                 if slot then
  1057.                     count = count + 1
  1058.                     if count == slot then
  1059.                         exports['item-system']:updateItemValue(thePlayer, k, ( titemValue < 0 and 1 or -1 ) * math.abs( v[2] or 1))
  1060.                         break
  1061.                     end
  1062.                 else
  1063.                     exports['item-system']:updateItemValue(thePlayer, k, ( titemValue < 0 and 1 or -1 ) * math.abs( v[2] or 1))
  1064.                 end
  1065.             end
  1066.         end
  1067.     else
  1068.         outputChatBox("You do not have a radio!", thePlayer, 255, 0, 0)
  1069.     end
  1070. end
  1071. addCommandHandler("toggleradio", toggleRadio, false, false)
  1072.  
  1073. -- Admin chat
  1074. function adminChat(thePlayer, commandName, ...)
  1075.     local logged = getElementData(thePlayer, "loggedin")
  1076.    
  1077.     if(logged==1) and (exports.global:isPlayerAdmin(thePlayer))  then
  1078.         if not (...) then
  1079.             outputChatBox("SYNTAX: /a [Message]", thePlayer, 255, 194, 14)
  1080.         else
  1081.             local message = table.concat({...}, " ")
  1082.             local players = exports.pool:getPoolElementsByType("player")
  1083.             local username = getPlayerName(thePlayer)
  1084.             local adminTitle = exports.global:getPlayerAdminTitle(thePlayer)
  1085.             exports.logs:logMessage("[Admin Chat] " .. username .. ": " .. message, 3)
  1086.             for k, arrayPlayer in ipairs(players) do
  1087.                 local logged = getElementData(arrayPlayer, "loggedin")
  1088.                
  1089.                 if(exports.global:isPlayerAdmin(arrayPlayer)) and (logged==1) then
  1090.                     outputChatBox(adminTitle .. " " .. username .. ": " .. message, arrayPlayer, 51, 255, 102)
  1091.                 end
  1092.             end
  1093.            
  1094.         end
  1095.     end
  1096. end
  1097.  
  1098. addCommandHandler("a", adminChat, false, false)
  1099.  
  1100.  
  1101. -- Scripter Chat
  1102. function scripterChat(thePlayer, commandName, ...)
  1103.     local logged = getElementData(thePlayer, "loggedin")
  1104.    
  1105.     if(logged==1) and (exports.global:isPlayerScripter(thePlayer))  then
  1106.         if not (...) then
  1107.             outputChatBox("SYNTAX: /s [Message]", thePlayer, 255, 194, 14)
  1108.         else
  1109.             local message = table.concat({...}, " ")
  1110.             local players = exports.pool:getPoolElementsByType("player")
  1111.             local username = getPlayerName(thePlayer)
  1112.            
  1113.             for k, arrayPlayer in ipairs(players) do
  1114.                 local logged = getElementData(arrayPlayer, "loggedin")
  1115.                
  1116.                 if(exports.global:isPlayerScripter(arrayPlayer)) and (logged==1) then
  1117.                     outputChatBox("~" .. username .. "~ " .. message, arrayPlayer, 255, 255, 128)
  1118.                 end
  1119.             end
  1120.         end
  1121.     end
  1122. end
  1123. addCommandHandler("ss", scripterChat, false, false)
  1124. addCommandHandler("sc", scripterChat, false, false)
  1125.  
  1126. -- Admin announcement
  1127. function adminAnnouncement(thePlayer, commandName, ...)
  1128.     local logged = getElementData(thePlayer, "loggedin")
  1129.    
  1130.     if(logged==1) and (exports.global:isPlayerAdmin(thePlayer))  then
  1131.         if not (...) then
  1132.             outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  1133.         else
  1134.             local message = table.concat({...}, " ")
  1135.             local players = exports.pool:getPoolElementsByType("player")
  1136.             local username = getPlayerName(thePlayer)
  1137.  
  1138.             for k, arrayPlayer in ipairs(players) do
  1139.                 local logged = getElementData(arrayPlayer, "loggedin")
  1140.                
  1141.                 if (logged) then
  1142.                     if exports.global:isPlayerAdmin(arrayPlayer) then
  1143.                         outputChatBox( "Admin Announcement by " .. getPlayerName(thePlayer) .. ":", arrayPlayer, 255, 194, 14)
  1144.                     end
  1145.                     outputChatBox("   *** " .. message .. " ***", arrayPlayer, 255, 194, 14)
  1146.                 end
  1147.             end
  1148.         end
  1149.     end
  1150. end
  1151. addCommandHandler("ann", adminAnnouncement, false, false)
  1152.  
  1153. function adminAnnouncement(thePlayer, commandName, ...)
  1154.     local logged = getElementData(thePlayer, "loggedin")
  1155.    
  1156.     if(logged==1) and (exports.global:isPlayerAdmin(thePlayer))  then
  1157.         if not (...) then
  1158.             outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  1159.         else
  1160.             local message = table.concat({...}, " ")
  1161.             local players = exports.pool:getPoolElementsByType("player")
  1162.             local username = getPlayerName(thePlayer)
  1163.  
  1164.             for k, arrayPlayer in ipairs(players) do
  1165.                 local logged = getElementData(arrayPlayer, "loggedin")
  1166.                
  1167.                 if (logged) then
  1168.                     if exports.global:isPlayerAdmin(arrayPlayer) then
  1169.                         outputChatBox( "Admin Announcement by " .. getPlayerName(thePlayer) .. ":", arrayPlayer, 255, 194, 14)
  1170.                     end
  1171.                     triggerClientEvent(arrayPlayer,"aoutput",arrayPlayer,"Announcement",message,2)
  1172.                     --outputChatBox("   *** " .. message .. " ***", arrayPlayer, 255, 194, 14)
  1173.                 end
  1174.             end
  1175.         end
  1176.     end
  1177. end
  1178. addCommandHandler("bnn", adminAnnouncement, false, false)
  1179.  
  1180. function leadAdminChat(thePlayer, commandName, ...)
  1181.     local logged = getElementData(thePlayer, "loggedin")
  1182.    
  1183.     if(logged==1) and (exports.global:isPlayerLeadAdmin(thePlayer)) then
  1184.         if not (...) then
  1185.             outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  1186.         else
  1187.             local message = table.concat({...}, " ")
  1188.             local players = exports.pool:getPoolElementsByType("player")
  1189.             local username = getPlayerName(thePlayer)
  1190.             local adminTitle = exports.global:getPlayerAdminTitle(thePlayer)
  1191.  
  1192.             for k, arrayPlayer in ipairs(players) do
  1193.                 local logged = getElementData(arrayPlayer, "loggedin")
  1194.                
  1195.                 if (exports.global:isPlayerLeadAdmin(arrayPlayer)) and (logged==1) then
  1196.                     outputChatBox("*4+* " ..adminTitle .. " " .. username .. ": " .. message, arrayPlayer, 204, 102, 255)
  1197.                 end
  1198.             end
  1199.         end
  1200.     end
  1201. end
  1202.  
  1203. addCommandHandler("l", leadAdminChat, false, false)
  1204.  
  1205. function headAdminChat(thePlayer, commandName, ...)
  1206.     local logged = getElementData(thePlayer, "loggedin")
  1207.    
  1208.     if(logged==1) and (exports.global:isPlayerHeadAdmin(thePlayer)) then
  1209.         if not (...) then
  1210.             outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  1211.         else
  1212.             local message = table.concat({...}, " ")
  1213.             local players = exports.pool:getPoolElementsByType("player")
  1214.             local username = getPlayerName(thePlayer)
  1215.             local adminTitle = exports.global:getPlayerAdminTitle(thePlayer)
  1216.  
  1217.             for k, arrayPlayer in ipairs(players) do
  1218.                 local logged = getElementData(arrayPlayer, "loggedin")
  1219.                
  1220.                 if(exports.global:isPlayerHeadAdmin(arrayPlayer)) and (logged==1) then
  1221.                     outputChatBox("*5+* " ..adminTitle .. " " .. username .. ": " .. message, arrayPlayer, 255, 204, 51)
  1222.                 end
  1223.             end
  1224.         end
  1225.     end
  1226. end
  1227.  
  1228. addCommandHandler("h", headAdminChat, false, false)
  1229.  
  1230. -- Misc
  1231. local function sortTable( a, b )
  1232.     if b[2] < a[2] then
  1233.         return true
  1234.     end
  1235.    
  1236.     if b[2] == a[2] and b[4] > a[4] then
  1237.         return true
  1238.     end
  1239.    
  1240.     return false
  1241. end
  1242.  
  1243. function showAdmins(thePlayer, commandName)
  1244.     local logged = getElementData(thePlayer, "loggedin")
  1245.    
  1246.     if(logged==1) then
  1247.         local players = exports.global:getAdmins()
  1248.         local counter = 0
  1249.        
  1250.         admins = {}
  1251.         outputChatBox("#33CC99------------------------ #FFFFFFAdministrators#33CC99 ------------------------", thePlayer,255,255,255,true)
  1252.  
  1253.         for k, arrayPlayer in ipairs(players) do
  1254.             local hiddenAdmin = getElementData(arrayPlayer, "hiddenadmin")
  1255.             local logged = getElementData(arrayPlayer, "loggedin")
  1256.            
  1257.             if logged == 1 then
  1258.                 if hiddenAdmin == 0 or exports.global:isPlayerAdmin(thePlayer) or exports.global:isPlayerScripter(thePlayer) then
  1259.                     admins[ #admins + 1 ] = { arrayPlayer, getElementData( arrayPlayer, "adminlevel" ), getElementData( arrayPlayer, "adminduty" ), getPlayerName( arrayPlayer ) }
  1260.                 end
  1261.             end
  1262.         end
  1263.        
  1264.         table.sort( admins, sortTable )
  1265.        
  1266.         for k, v in ipairs(admins) do
  1267.             arrayPlayer = v[1]
  1268.             local adminTitle = exports.global:getPlayerAdminTitle(arrayPlayer)
  1269.            
  1270.             if exports.global:isPlayerAdmin(thePlayer) or exports.global:isPlayerScripter(thePlayer) then
  1271.                 v[4] = v[4] .. " (" .. tostring(getElementData(arrayPlayer, "gameaccountusername")) .. ")"
  1272.             end
  1273.            
  1274.             if(v[3]==1)then
  1275.                 outputChatBox("    " .. tostring(adminTitle) .. " " .. v[4].." - #66CC00On Duty", thePlayer, 255, 255, 255,true)
  1276.             else
  1277.                 outputChatBox("    " .. tostring(adminTitle) .. " " .. v[4].." - #FF0033Off Duty", thePlayer,255,255,255,true)
  1278.             end
  1279.         end
  1280.        
  1281.         if #admins == 0 then
  1282.             outputChatBox("     No Admins Online.", thePlayer,204,204,204)
  1283.         end
  1284.         outputChatBox("#33CC99------------------------ #FFFFFFGameMasters#33CC99 ------------------------", thePlayer,255,255,255,true)
  1285.         local count = 0
  1286.         for k,v in ipairs( getElementsByType ( "player" )) do
  1287.             helper = tonumber(getElementData(v,"helper"))
  1288.             if helper == 1 then
  1289.                     rank = "Trial"
  1290.             elseif helper ==2 then
  1291.                     rank = "Regular"
  1292.             elseif helper ==3 then
  1293.                     rank = "Lead"  
  1294.             elseif helper ==3 then
  1295.                     rank = "Head"  
  1296.             elseif helper ==3 then
  1297.                     rank = ""  
  1298.             end
  1299.             if helper > 0 then
  1300.                     outputChatBox("   " ..rank.." GameMaster "..getPlayerName(v),thePlayer,255,255,255)
  1301.                     count = count + 1
  1302.             end
  1303.         end
  1304.         if count == 0 then
  1305.            
  1306.             outputChatBox("   No GameMasters online",thePlayer,204,204,204)
  1307.         end
  1308.        
  1309.     end
  1310. end
  1311. addCommandHandler("admins", showAdmins, false, false)
  1312.  
  1313. function playerChangeChatbubbleMode(thePlayer, commandName, mode)
  1314.     local logged = getElementData(thePlayer, "loggedin")
  1315.    
  1316.     if logged == 1 then
  1317.         mode = tonumber(mode)
  1318.         if not mode or mode < 0 or mode > 2 then
  1319.             outputChatBox("SYNTAX: /" .. commandName .. " [Mode]", thePlayer, 255, 194, 14)
  1320.             outputChatBox("0 = hide all  1 = hide own  2 = show all", thePlayer, 255, 194, 14)
  1321.         else
  1322.             if (mode == 0) then
  1323.                 outputChatBox("All chatbubbles are now hidden.", thePlayer, 255, 194, 14)
  1324.             elseif (mode == 1) then
  1325.                 outputChatBox("Only your own chatbubbles are hidden others are visible.", thePlayer, 255, 194, 14)
  1326.             elseif (mode == 2) then
  1327.                 outputChatBox("All chatbubbles are now visible.", thePlayer, 255, 194, 14)
  1328.             end
  1329.             exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "chatbubbles", mode, false)
  1330.             mysql:query_free("UPDATE accounts SET chatbubbles=" .. mysql:escape_string(mode) .. " WHERE id = " .. mysql:escape_string(getElementData( thePlayer, "gameaccountid" )) )
  1331.         end
  1332.     end
  1333. end
  1334. addCommandHandler("changecbmode", playerChangeChatbubbleMode, false, false)
  1335.  
  1336. function toggleOOC(thePlayer, commandName)
  1337.     local logged = getElementData(thePlayer, "loggedin")
  1338.  
  1339.     if(logged==1) and (exports.global:isPlayerAdmin(thePlayer)) then
  1340.         local players = exports.pool:getPoolElementsByType("player")
  1341.         local oocEnabled = exports.global:getOOCState()
  1342.         if (commandName == "togooc") then
  1343.             if (oocEnabled==0) then
  1344.                 exports.global:setOOCState(1)
  1345.  
  1346.                 for k, arrayPlayer in ipairs(players) do
  1347.                     local logged = getElementData(arrayPlayer, "loggedin")
  1348.                    
  1349.                     if  (logged==1) then
  1350.                         --outputChatBox("OOC Chat Enabled by Admin.", arrayPlayer, 0, 255, 0)
  1351.                         triggerClientEvent(arrayPlayer,"aoutput",arrayPlayer,"Warning","Global OOC Chat Enabled by Admin.Press 'U' to talk",2)
  1352.                     end
  1353.                 end
  1354.             elseif (oocEnabled==1) then
  1355.                 if getPlayerCount()<=15 and not (exports.global:isPlayerLeadAdmin(thePlayer)) then
  1356.                     outputChatBox("There must be more than 15 players to disable this chat.",thePlayer,255,2,2)
  1357.                     return
  1358.                 end
  1359.                 exports.global:setOOCState(0)
  1360.  
  1361.                 for k, arrayPlayer in ipairs(players) do
  1362.                     local logged = getElementData(arrayPlayer, "loggedin")
  1363.                    
  1364.                     if  (logged==1) then
  1365.                         --outputChatBox("OOC Chat Disabled by Admin.", arrayPlayer, 255, 0, 0)
  1366.                         triggerClientEvent(arrayPlayer,"aoutput",arrayPlayer,"Warning","Global OOC Chat Disabled by Admin.",3)
  1367.                     end
  1368.                 end
  1369.             end
  1370.         elseif (commandName == "stogooc") then
  1371.             if (oocEnabled==0) then
  1372.                 exports.global:setOOCState(1)
  1373.                
  1374.                 for k, arrayPlayer in ipairs(players) do
  1375.                     local logged = getElementData(arrayPlayer, "loggedin")
  1376.                     local admin = getElementData(arrayPlayer, "adminlevel")
  1377.                    
  1378.                     if  (logged==1) and (tonumber(admin)>0)then
  1379.                         outputChatBox("OOC Chat Enabled Silently by Admin " .. getPlayerName(thePlayer) .. ".", arrayPlayer, 0, 255, 0)
  1380.                     end
  1381.                 end
  1382.             elseif (oocEnabled==1) then
  1383.                 if getPlayerCount()<=15 and not (exports.global:isPlayerLeadAdmin(thePlayer)) then
  1384.                     outputChatBox("There must be more than 15 players to disable this chat.",thePlayer,255,2,2)
  1385.                     return
  1386.                 end
  1387.                 exports.global:setOOCState(0)
  1388.                
  1389.                 for k, arrayPlayer in ipairs(players) do
  1390.                     local logged = getElementData(arrayPlayer, "loggedin")
  1391.                     local admin = getElementData(arrayPlayer, "adminlevel")
  1392.                    
  1393.                     if  (logged==1) and (tonumber(admin)>0)then
  1394.                         outputChatBox("OOC Chat Disabled Silently by Admin " .. getPlayerName(thePlayer) .. ".", arrayPlayer, 255, 0, 0)
  1395.                     end
  1396.                 end
  1397.             end
  1398.         end
  1399.     end
  1400. end
  1401.  
  1402. addCommandHandler("togooc", toggleOOC, false, false)
  1403. addCommandHandler("stogooc", toggleOOC, false, false)
  1404.        
  1405. function togglePM(thePlayer, commandName)
  1406.     local logged = getElementData(thePlayer, "loggedin")
  1407.    
  1408.     if(logged==1) and ((exports.global:isPlayerAdmin(thePlayer)) or (exports.global:isPlayerBronzeDonator(thePlayer)))then
  1409.         local pmenabled = getElementData(thePlayer, "pmblocked")
  1410.        
  1411.         if (pmenabled==1) then
  1412.             exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "pmblocked", 0, false)
  1413.             outputChatBox("PM's are now enabled.", thePlayer, 0, 255, 0)
  1414.         else
  1415.             exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "pmblocked", 1, false)
  1416.             outputChatBox("PM's are now disabled.", thePlayer, 255, 0, 0)
  1417.         end
  1418.         mysql:query_free("UPDATE accounts SET pmblocked=" .. mysql:escape_string(getElementData(thePlayer, "pmblocked")) .. " WHERE id = " .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")))
  1419.     end
  1420. end
  1421. addCommandHandler("togpm", togglePM)
  1422. addCommandHandler("togglepm", togglePM)
  1423.  
  1424. function toggleAds(thePlayer, commandName)
  1425.     local logged = getElementData(thePlayer, "loggedin")
  1426.    
  1427.     if(logged==1) and (exports.global:isPlayerGoldDonator(thePlayer))then
  1428.         local adblocked = getElementData(thePlayer, "disableAds")
  1429.         if (adblocked) then -- enable the ads again
  1430.             exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "disableAds", false, false)
  1431.             outputChatBox("Ads are now enabled.", thePlayer, 0, 255, 0)
  1432.             mysql:query_free("UPDATE accounts SET adblocked=0 WHERE id = " .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")) )
  1433.         else -- disable them D:
  1434.             exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "disableAds", true, false)
  1435.             outputChatBox("Ads are now disabled.", thePlayer, 255, 0, 0)
  1436.             mysql:query_free("UPDATE accounts SET adblocked=1 WHERE id = " .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")) )
  1437.         end
  1438.     end
  1439. end
  1440. addCommandHandler("togad", toggleAds)
  1441. addCommandHandler("togglead", toggleAds)
  1442.  
  1443. -- /pay
  1444. function payPlayer(thePlayer, commandName, targetPlayerNick, amount)
  1445.     if exports['freecam-tv']:isPlayerFreecamEnabled(thePlayer) then return end
  1446.    
  1447.     local logged = getElementData(thePlayer, "loggedin")
  1448.    
  1449.     if (logged==1) then
  1450.         if not (targetPlayerNick) or not (amount) or not tonumber(amount) then
  1451.             outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick] [Amount]", thePlayer, 255, 194, 14)
  1452.         else
  1453.             local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPlayerNick)
  1454.            
  1455.             if targetPlayer then
  1456.                 local x, y, z = getElementPosition(thePlayer)
  1457.                 local tx, ty, tz = getElementPosition(targetPlayer)
  1458.                
  1459.                 local distance = getDistanceBetweenPoints3D(x, y, z, tx, ty, tz)
  1460.                
  1461.                 if (distance<=10) then
  1462.                     amount = math.floor(math.abs(tonumber(amount)))
  1463.                    
  1464.                     local hoursplayed = getElementData(thePlayer, "hoursplayed")
  1465.                    
  1466.                     if (targetPlayer==thePlayer) then
  1467.                         outputChatBox("You cannot pay money to yourself.", thePlayer, 255, 0, 0)
  1468.                     elseif amount == 0 then
  1469.                         outputChatBox("You need to enter an amount larger than 0.", thePlayer, 255, 0, 0)
  1470.                     elseif (hoursplayed<5) and (amount>50) and not exports.global:isPlayerAdmin(thePlayer) and not exports.global:isPlayerAdmin(targetPlayer) and not exports.global:isPlayerBronzeDonator(thePlayer) then
  1471.                         outputChatBox("You must play atleast 5 hours before transferring over 50$", thePlayer, 255, 0, 0)
  1472.                     elseif exports.global:takeMoney(thePlayer, amount) then
  1473.                         if hoursplayed < 5 and not exports.global:isPlayerAdmin(targetPlayer) and not exports.global:isPlayerBronzeDonator(thePlayer) then
  1474.                             local totalAmount = ( getElementData(thePlayer, "payAmount") or 0 ) + amount
  1475.                             if totalAmount > 200 then
  1476.                                 outputChatBox( "You can only /pay $200 per five minutes. /report for an admin to transfer a larger amoutn of cash.", thePlayer, 255, 0, 0 )
  1477.                                 return
  1478.                             end
  1479.                             exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "payAmount", totalAmount, false)
  1480.                             setTimer(
  1481.                                 function(thePlayer, amount)
  1482.                                     if isElement(thePlayer) then
  1483.                                         local totalAmount = ( getElementData(thePlayer, "payAmount") or 0 ) - amount
  1484.                                         exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "payAmount", totalAmount <= 0 and false or totalAmount, false)
  1485.                                     end
  1486.                                 end,
  1487.                                 300000, 1, thePlayer, amount
  1488.                             )
  1489.                         end
  1490.                        
  1491.                         exports.logs:logMessage("[Money Transfer From " .. getPlayerName(thePlayer) .. " To: " .. targetPlayerName .. "] Value: " .. amount .. "$", 5)
  1492.                         if (hoursplayed<5) then
  1493.                             exports.global:sendMessageToAdmins("AdmWarn: New Player '" .. getPlayerName(thePlayer) .. "' transferred " .. amount .. "$ to '" .. targetPlayerName .. "'.")
  1494.                         end
  1495.                        
  1496.                         exports.global:giveMoney(targetPlayer, amount)
  1497.                        
  1498.                         local gender = getElementData(thePlayer, "gender")
  1499.                         local genderm = "his"
  1500.                         if (gender == 1) then
  1501.                             genderm = "her"
  1502.                         end
  1503.                        
  1504.                         exports.global:sendLocalMeAction(thePlayer, "takes some dollar notes from " .. genderm .. " wallet and gives them to " .. targetPlayerName .. ".")
  1505.                         outputChatBox("You gave $" .. amount .. " to " .. targetPlayerName .. ".", thePlayer)
  1506.                         outputChatBox(getPlayerName(thePlayer) .. " gave you $" .. amount .. ".", targetPlayer)
  1507.  
  1508.                         exports.global:applyAnimation(thePlayer, "DEALER", "shop_pay", 4000, false, true, true)
  1509.                     else
  1510.                         outputChatBox("You do not have enough money.", thePlayer, 255, 0, 0)
  1511.                     end
  1512.                 else
  1513.                     outputChatBox("You are too far away from " .. targetPlayerName .. ".", thePlayer, 255, 0, 0)
  1514.                 end
  1515.             end
  1516.         end
  1517.     end
  1518. end
  1519. addCommandHandler("pay", payPlayer, false, false)
  1520.  
  1521. function removeAnimation(thePlayer)
  1522.     exports.global:removeAnimation(thePlayer)
  1523. end
  1524.  
  1525. -- /w(hisper)
  1526. function localWhisper(thePlayer, commandName, targetPlayerNick, ...)
  1527.     if exports['freecam-tv']:isPlayerFreecamEnabled(thePlayer) then return end
  1528.    
  1529.     local logged = tonumber(getElementData(thePlayer, "loggedin"))
  1530.      
  1531.     if (logged==1) then
  1532.         if not (targetPlayerNick) or not (...) then
  1533.             outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick / ID] [Message]", thePlayer, 255, 194, 14)
  1534.         else
  1535.             local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPlayerNick)
  1536.            
  1537.             if targetPlayer then
  1538.                 local x, y, z = getElementPosition(thePlayer)
  1539.                 local tx, ty, tz = getElementPosition(targetPlayer)
  1540.                
  1541.                 if (getDistanceBetweenPoints3D(x, y, z, tx, ty, tz)<3) then
  1542.                     local name = getPlayerName(thePlayer)
  1543.                     local message = table.concat({...}, " ")
  1544.                     exports.logs:logMessage("[IC: Whisper] " .. name .. " to " .. targetPlayerName .. ": " .. message, 1)
  1545.                     message = trunklateText( thePlayer, message )
  1546.                    
  1547.                     local languageslot = getElementData(thePlayer, "languages.current")
  1548.                     local language = getElementData(thePlayer, "languages.lang" .. languageslot)
  1549.                     local languagename = call(getResourceFromName("language-system"), "getLanguageName", language)
  1550.                    
  1551.                     message2 = trunklateText( targetPlayer, message2 )
  1552.                     local message2 = call(getResourceFromName("language-system"), "applyLanguage", thePlayer, targetPlayer, message, language)
  1553.                    
  1554.                     exports.global:sendLocalMeAction(thePlayer, "whispers to " .. targetPlayerName .. ".")
  1555.                     outputChatBox("[In Character] " .. name .. " whispers: " .. message, thePlayer, 255, 255, 255)
  1556.                     outputChatBox("[In Character] " .. name .. " whispers: " .. message2, targetPlayer, 255, 255, 255)
  1557.                     for i,p in ipairs(getElementsByType( "player" )) do
  1558.                         if (getElementData(p, "adminduty") == 1) then
  1559.                             if p ~= targetPlayer and p ~= thePlayer then
  1560.                                 local ax, ay, az = getElementPosition(p)
  1561.                                 if (getDistanceBetweenPoints3D(x, y, z, ax, ay, az)<4) then
  1562.                                     outputChatBox("[In Character] " .. name .. " whispers to " .. getPlayerName(targetPlayer):gsub("_"," ") .. ": " .. message, p, 255, 255, 255)
  1563.                                 end
  1564.                             end
  1565.                         end
  1566.                     end
  1567.                 else
  1568.                     outputChatBox("You are too far away from " .. targetPlayerName .. ".", thePlayer, 255, 0, 0)
  1569.                 end
  1570.             end
  1571.         end
  1572.     end
  1573. end
  1574. addCommandHandler("w", localWhisper, false, false)
  1575.  
  1576. -- /c(lose)
  1577. function localClose(thePlayer, commandName, ...)
  1578.     if exports['freecam-tv']:isPlayerFreecamEnabled(thePlayer) then return end
  1579.    
  1580.     local logged = tonumber(getElementData(thePlayer, "loggedin"))
  1581.      
  1582.     if (logged==1) then
  1583.         if not (...) then
  1584.             outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  1585.         else
  1586.             local name = getPlayerName(thePlayer)
  1587.             local message = table.concat({...}, " ")
  1588.             exports.logs:logMessage("[IC: Whisper] " .. name .. ": " .. message, 1)
  1589.             message = trunklateText( thePlayer, message )
  1590.            
  1591.             local languageslot = getElementData(thePlayer, "languages.current")
  1592.             local language = getElementData(thePlayer, "languages.lang" .. languageslot)
  1593.             local languagename = call(getResourceFromName("language-system"), "getLanguageName", language)
  1594.            
  1595.             for index, targetPlayers in ipairs( getElementsByType( "player" ) ) do
  1596.                 if getElementDistance( thePlayer, targetPlayers ) < 5 then
  1597.                     local message2 = message
  1598.                     if targetPlayers ~= thePlayer then
  1599.                         message2 = call(getResourceFromName("language-system"), "applyLanguage", thePlayer, targetPlayers, message, language)
  1600.                         message2 = trunklateText( targetPlayers, message2 )
  1601.                     end
  1602.                     local pveh = getPedOccupiedVehicle(targetPlayers)
  1603.                     if pveh then
  1604.                         if (exports['vehicle-system']:isVehicleWindowUp(pveh)) then        
  1605.                             outputChatBox( " [In Character] " .. name .. " whispers: " .. message2, targetPlayers, 255, 255, 255)
  1606.                         end
  1607.                     else
  1608.                         outputChatBox( " [In Character] " .. name .. " whispers: " .. message2, targetPlayers, 255, 255, 255)
  1609.                     end
  1610.                 end
  1611.             end
  1612.         end
  1613.     end
  1614. end
  1615. addCommandHandler("c", localClose, false, false)
  1616.  
  1617. ------------------
  1618. -- News Faction --
  1619. ------------------
  1620. -- /n(ews)
  1621. function newsMessage(thePlayer, commandName, ...)
  1622.     local logged = getElementData(thePlayer, "loggedin")
  1623.    
  1624.     if (logged==1) then
  1625.         local theTeam = getPlayerTeam(thePlayer)
  1626.         local factionType = getElementData(theTeam, "type")
  1627.        
  1628.         if(factionType==6)then -- news faction
  1629.            
  1630.             if not(...)then
  1631.                 outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  1632.             else
  1633.                 local message = table.concat({...}, " ")
  1634.                 local name = getPlayerName(thePlayer)
  1635.                
  1636.                 local abuse = true
  1637.                 if (getElementDimension(thePlayer) == 9902) then
  1638.                     abuse = false
  1639.                 end
  1640.                 for index, nearbyVehicle in ipairs( exports.global:getNearbyElements(thePlayer, "vehicle", 25) ) do
  1641.                     if (getElementModel(nearbyVehicle) == 582) then
  1642.                      abuse = false
  1643.                     end
  1644.                 end
  1645.                
  1646.                 if not abuse then
  1647.                     exports.logs:logMessage("[IC: News] " .. name .. ": " .. message, 18)
  1648.                 else
  1649.                     exports.logs:logMessage("[A" .. getElementDimension(thePlayer) .. "][IC: News] " .. name .. ": " .. message, 18)
  1650.                 end
  1651.                
  1652.                 for key, value in ipairs(exports.pool:getPoolElementsByType("player")) do
  1653.                        
  1654.                     if (getElementData(value, "loggedin")==1) then
  1655.                            
  1656.                         if not(getElementData(value, "tognews")==1) then
  1657.                             outputChatBox("[NEWS] ".. name .." says: ".. message, value, 200, 100, 200)
  1658.                         end
  1659.                     end
  1660.                 end
  1661.                
  1662.                 exports.global:giveMoney(theTeam, 200)
  1663.             end
  1664.         end
  1665.     end
  1666. end
  1667. addCommandHandler("san", newsMessage, false, false)
  1668.  
  1669. -- /tognews
  1670. function togNews(thePlayer, commandName)
  1671.     local logged = getElementData(thePlayer, "loggedin")
  1672.    
  1673.     if (logged==1) and (exports.global:isPlayerGoldDonator(thePlayer)) then
  1674.         local newsTog = getElementData(thePlayer, "tognews")
  1675.        
  1676.         if (newsTog~=1) then
  1677.             outputChatBox("/news disabled.", thePlayer, 255, 194, 14)
  1678.             exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "tognews", 1, false)
  1679.         else
  1680.             outputChatBox("/news enabled.", thePlayer, 255, 194, 14)
  1681.             exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "tognews", 0, false)
  1682.         end
  1683.         mysql:query_free("UPDATE accounts SET newsblocked=" .. mysql:escape_string(getElementData(thePlayer, "tognews")) .. " WHERE id = " .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")) )
  1684.     end
  1685. end
  1686. addCommandHandler("tognews", togNews, false, false)
  1687. addCommandHandler("togglenews", togNews, false, false)
  1688.  
  1689.  
  1690. -- /startinterview
  1691. function StartInterview(thePlayer, commandName, targetPartialPlayer)
  1692.     local logged = getElementData(thePlayer, "loggedin")
  1693.     if (logged==1) then
  1694.         local theTeam = getPlayerTeam(thePlayer)
  1695.         local factionType = getElementData(theTeam, "type")
  1696.         if(factionType==6)then -- news faction
  1697.             if not (targetPartialPlayer) then
  1698.                 outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick]", thePlayer, 255, 194, 14)
  1699.             else
  1700.                 local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPartialPlayer)
  1701.                 if targetPlayer then
  1702.                     local targetLogged = getElementData(targetPlayer, "loggedin")
  1703.                     if (targetLogged==1) then
  1704.                         if(getElementData(targetPlayer,"interview"))then
  1705.                             outputChatBox("This player is already being interviewed.", thePlayer, 255, 0, 0)
  1706.                         else
  1707.                             exports['anticheat-system']:changeProtectedElementDataEx(targetPlayer, "interview", true, false)
  1708.                             local playerName = getPlayerName(thePlayer)
  1709.                             outputChatBox(playerName .." has offered you for an interview.", targetPlayer, 0, 255, 0)
  1710.                             outputChatBox("((Use /i to talk during the interview.))", targetPlayer, 0, 255, 0)
  1711.                             local NewsFaction = getPlayersInTeam(getPlayerTeam(thePlayer))
  1712.                             for key, value in ipairs(NewsFaction) do
  1713.                                 outputChatBox("((".. playerName .." has invited " .. targetPlayerName .. " for an interview.))", value, 0, 255, 0)
  1714.                             end
  1715.                         end
  1716.                     end
  1717.                 end
  1718.             end
  1719.         end
  1720.     end
  1721. end
  1722. addCommandHandler("interview", StartInterview, false, false)
  1723.  
  1724. -- /endinterview
  1725. function endInterview(thePlayer, commandName, targetPartialPlayer)
  1726.     local logged = getElementData(thePlayer, "loggedin")
  1727.     if (logged==1) then
  1728.         local theTeam = getPlayerTeam(thePlayer)
  1729.         local factionType = getElementData(theTeam, "type")
  1730.         if(factionType==6)then -- news faction
  1731.             if not (targetPartialPlayer) then
  1732.                 outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick]", thePlayer, 255, 194, 14)
  1733.             else
  1734.                 local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPartialPlayer)
  1735.                 if targetPlayer then
  1736.                     local targetLogged = getElementData(targetPlayer, "loggedin")
  1737.                     if (targetLogged==1) then
  1738.                         if not(getElementData(targetPlayer,"interview"))then
  1739.                             outputChatBox("This player is not being interviewed.", thePlayer, 255, 0, 0)
  1740.                         else
  1741.                             exports['anticheat-system']:changeProtectedElementDataEx(targetPlayer, "interview")
  1742.                             local playerName = getPlayerName(thePlayer)
  1743.                             outputChatBox(playerName .." has ended your interview.", targetPlayer, 255, 0, 0)
  1744.                        
  1745.                             local NewsFaction = getPlayersInTeam(getPlayerTeam(thePlayer))
  1746.                             for key, value in ipairs(NewsFaction) do
  1747.                                 outputChatBox("((".. playerName .." has ended " .. targetPlayerName .. "'s interview.))", value, 255, 0, 0)
  1748.                             end
  1749.                         end
  1750.                     end
  1751.                 end
  1752.             end
  1753.         end
  1754.     end
  1755. end
  1756. addCommandHandler("endinterview", endInterview, false, false)
  1757.  
  1758. -- /i
  1759. function interviewChat(thePlayer, commandName, ...)
  1760.     local logged = getElementData(thePlayer, "loggedin")
  1761.     if (logged==1) then
  1762.         if(getElementData(thePlayer, "interview"))then
  1763.             if not(...)then
  1764.                 outputChatBox("SYNTAX: /" .. commandName .. "[Message]", thePlayer, 255, 194, 14)
  1765.             else
  1766.                 local message = table.concat({...}, " ")
  1767.                 local name = getPlayerName(thePlayer)
  1768.                
  1769.                 exports.logs:logMessage("[IC: Interview Guest] " .. name .. ": " .. message, 18)
  1770.                
  1771.                 for key, value in ipairs(exports.pool:getPoolElementsByType("player")) do
  1772.                     if (getElementData(value, "loggedin")==1) then
  1773.                         if not (getElementData(value, "tognews")==1) then
  1774.                             outputChatBox("[NEWS] Interview Guest " .. name .." says: ".. message, value, 200, 100, 200)
  1775.                         end
  1776.                     end
  1777.                 end
  1778.                
  1779.                 exports.global:giveMoney(getTeamFromName"San Andreas Network", 200)
  1780.             end
  1781.         end
  1782.     end
  1783. end
  1784. addCommandHandler("i", interviewChat, false, false)
  1785.  
  1786. -- news hotline /news
  1787. function newsHotline(thePlayer, commandName, ...)
  1788.     local logged = getElementData(thePlayer, "loggedin")
  1789.    
  1790.     if (logged==1) then
  1791.         if not (...) then
  1792.             outputChatBox("SYNTAX: /" .. commandName .. " [Description of Situation]", thePlayer, 255, 194, 14)
  1793.         else
  1794.             local playerName = getPlayerName(thePlayer)
  1795.             local dimension = getElementDimension(thePlayer)
  1796.             local interior = getElementInterior(thePlayer)
  1797.            
  1798.             local message = table.concat({...}, " ")
  1799.             message = string.gsub(message, "#%x%x%x%x%x%x", "") -- Remove colour codes
  1800.            
  1801.             -- Show chat to console, for admins + log
  1802.             exports.global:sendLocalMeAction(thePlayer,"dials a number on their cellphone.")
  1803.             for index, nearbyPlayer in ipairs(getElementsByType("player")) do
  1804.                 local dist = getElementDistance( thePlayer, targetPlayers )
  1805.                 if dist < 20 then
  1806.                     local nearbyPlayerDimension = getElementDimension(nearbyPlayer)
  1807.                     local nearbyPlayerInterior = getElementInterior(nearbyPlayer)
  1808.                     if (nearbyPlayerDimension==dimension) and (nearbyPlayerInterior==interior) then
  1809.                         local logged = tonumber(getElementData(nearbyPlayer, "loggedin"))
  1810.                         if not (isPedDead(nearbyPlayer)) and (logged==1) then
  1811.                             if dist < 4 then
  1812.                                 outputChatBox( "#EEEEEE" .. playerName .. " [Cellphone]: " .. message, nearbyPlayer, 255, 255, 255, true)
  1813.                             elseif dist < 8 then
  1814.                                 outputChatBox( "#DDDDDD" .. playerName .. " [Cellphone]: " .. message, nearbyPlayer, 255, 255, 255, true)
  1815.                             elseif dist < 12 then
  1816.                                 outputChatBox( "#CCCCCC" .. playerName .. " [Cellphone]: " .. message, nearbyPlayer, 255, 255, 255, true)
  1817.                             elseif dist < 16 then
  1818.                                 outputChatBox( "#BBBBBB" .. playerName .. " [Cellphone]: " .. message, nearbyPlayer, 255, 255, 255, true)
  1819.                             else
  1820.                                 outputChatBox( "#AAAAAA" .. playerName .. " [Cellphone]: " .. message, nearbyPlayer, 255, 255, 255, true)
  1821.                             end
  1822.                         end
  1823.                     end
  1824.                 end
  1825.             end
  1826.        
  1827.             outputChatBox("Thank you for calling the San Andreas Network Desk. Your tip will be forwarded to our staff.", thePlayer, 255, 194, 14)
  1828.             exports.global:sendLocalMeAction(thePlayer,"hangs up their cellphone.")
  1829.            
  1830.             local playerNumber = getElementData(thePlayer, "cellnumber")
  1831.             local theTeam = getTeamFromName("San Andreas Network")
  1832.             local teamMembers = getPlayersInTeam(theTeam)
  1833.            
  1834.             for key, value in ipairs(teamMembers) do
  1835.                 if(exports.global:hasItem(value,2))then
  1836.                     if getElementData( value, "phoneoff" ) ~= 1 then
  1837.                         for _,nearbyPlayer in ipairs(exports.global:getNearbyElements(value, "player")) do
  1838.                             triggerClientEvent(nearbyPlayer, "startRinging", value, 2)
  1839.                         end
  1840.                         exports.global:sendLocalMeAction(value,"receives a text message.")
  1841.                     end
  1842.                     outputChatBox("SMS From: News Desk - '".. message.."' Ph:".. playerNumber .." (("..getPlayerName(thePlayer) .."))", value)
  1843.                 end
  1844.             end
  1845.         end
  1846.     end
  1847. end
  1848. addCommandHandler("news", newsHotline, false, false)
  1849.  
  1850. function showRoadmap(thePlayer)
  1851.     local logged = getElementData(thePlayer, "loggedin")
  1852.     if (logged==1) then
  1853.         outputChatBox("Loading Progress... Please Wait...", thePlayer, 255, 194, 15)
  1854.         callRemote("", displayRoadmap, thePlayer)
  1855.     end
  1856. end
  1857. --addCommandHandler("roadmap", showRoadmap)
  1858. --addCommandHandler("progress", showRoadmap)
  1859.  
  1860. function displayRoadmap(thePlayer, version1, percent1, changes1, version2, percent2, changes2, version3, percent3, changes3, mtaversion, mtapercent, mtachanges)
  1861.     if (thePlayer~="ERROR") then
  1862.         outputChatBox("~~~~~~~~~~~~~~~~~~ Progress ~~~~~~~~~~~~~~~~~~", thePlayer, 255, 194, 15)
  1863.         outputChatBox("" .. version1 .. ": " .. percent1 .. ". Changes: " .. changes1 .. ".", thePlayer, 255, 194, 15)
  1864.         outputChatBox(" " .. version2 .. ": " .. percent2 .. ". Changes: " .. changes2 .. ".", thePlayer, 255, 194, 15)
  1865.         outputChatBox(" " .. version3 .. ": " .. percent3 .. ". Changes: " .. changes3 .. ".", thePlayer, 255, 194, 15)
  1866.         outputChatBox("MultiTheftAuto " .. mtaversion .. ": " .. mtapercent .. ". Changes: " .. mtachanges .. ".", thePlayer, 255, 194, 15)
  1867.     end
  1868. end
  1869.  
  1870. -- /charity
  1871. function charityCash(thePlayer, commandName, amount)
  1872.     if not (amount) then
  1873.         outputChatBox("SYNTAX: /" .. commandName .. " [Amount]", thePlayer, 255, 194, 14)
  1874.     else
  1875.         local donation = tonumber(amount)
  1876.         if (donation<=0) then
  1877.             outputChatBox("You must enter an amount greater than zero.", thePlayer, 255, 0, 0)
  1878.         else
  1879.             if not exports.global:takeMoney(thePlayer, donation) then
  1880.                 outputChatBox("You don't have that much money to remove.", thePlayer, 255, 0, 0)
  1881.             else
  1882.                 outputChatBox("You have donated $".. donation .." to charity.", thePlayer, 0, 255, 0)
  1883.                 if(donation>=1000)then
  1884.                     local name = getPlayerName(thePlayer)
  1885.                    
  1886.                     local gender = getElementData(thePlayer, "gender")
  1887.                     local genderm = "his"
  1888.                     if (gender == 1) then
  1889.                         genderm = "her"
  1890.                     end
  1891.                     outputChatBox("The hungry orphans would like to thank " ..name.. " for " .. genderm .. " sizable $" ..donation.. " donation to charity.", getRootElement())
  1892.                     exports.global:givePlayerAchievement(thePlayer, 37) -- The Good Samaritan
  1893.                 end
  1894.             end
  1895.         end
  1896.     end
  1897. end
  1898. addCommandHandler("charity", charityCash, false, false)
  1899.  
  1900. -- /bigears
  1901. function bigEars(thePlayer, commandName, targetPlayerNick)
  1902.     if exports.global:isPlayerAdmin(thePlayer) then
  1903.         local current = getElementData(thePlayer, "bigears")
  1904.         if not current and not targetPlayerNick then
  1905.             outputChatBox("SYNTAX: /" .. commandName .. " [player]", thePlayer, 255, 194, 14)
  1906.         elseif current and not targetPlayerNick then
  1907.             exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "bigears")
  1908.             outputChatBox("Big Ears turned off.", thePlayer, 255, 0, 0)
  1909.         else
  1910.             local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPlayerNick)
  1911.            
  1912.             if targetPlayer then
  1913.                 outputChatBox("Now Listening to " .. targetPlayerName .. ".", thePlayer, 0, 255, 0)
  1914.                 exports.logs:logMessage("[/bigears] " .. getElementData(thePlayer, "gameaccountusername") .. "/".. getPlayerName(thePlayer) .." started bigear on " .. targetPlayerName, 4)
  1915.                 exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "bigears", targetPlayer, false)
  1916.             end
  1917.         end
  1918.     end
  1919. end
  1920. addCommandHandler("bigears", bigEars)
  1921.  
  1922. function removeBigEars()
  1923.     for key, value in pairs( getElementsByType( "player" ) ) do
  1924.         if isElement( value ) and getElementData( value, "bigears" ) == source then
  1925.             exports['anticheat-system']:changeProtectedElementDataEx( value, "bigears" )
  1926.             outputChatBox("Big Ears turned off (Player Left).", value, 255, 0, 0)
  1927.         end
  1928.     end
  1929. end
  1930. addEventHandler( "onPlayerQuit", getRootElement(), removeBigEars)
  1931.  
  1932. function bigEarsFaction(thePlayer, commandName, factionID)
  1933.     if exports.global:isPlayerLeadAdmin(thePlayer) then
  1934.         factionID = tonumber( factionID )
  1935.         local current = getElementData(thePlayer, "bigearsfaction")
  1936.         if not current and not factionID then
  1937.             outputChatBox("SYNTAX: /" .. commandName .. " [faction id]", thePlayer, 255, 194, 14)
  1938.         elseif current and not factionID then
  1939.             exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "bigearsfaction")
  1940.             outputChatBox("Big Ears turned off.", thePlayer, 255, 0, 0)
  1941.         else
  1942.             local team = exports.pool:getElement("team", factionID)
  1943.             if not team then
  1944.                 outputChatBox("No faction with that ID found.", thePlayer, 255, 0, 0)
  1945.             else
  1946.                 outputChatBox("Now Listening to " .. getTeamName(team) .. " OOC Chat.", thePlayer, 0, 255, 0)
  1947.                 exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "bigearsfaction", team, false)
  1948.                 exports.logs:logMessage("[/bigearsf] " .. getElementData(thePlayer, "gameaccountusername") .. "/".. getPlayerName(thePlayer) .." started bigear on " .. getTeamName(team), 4)
  1949.             end
  1950.         end
  1951.     end
  1952. end
  1953. addCommandHandler("bigearsf", bigEarsFaction)
  1954.  
  1955. function disableMsg(message, player)
  1956.     cancelEvent()
  1957.  
  1958.     -- send it using our own PM etiquette instead
  1959.     pmPlayer(source, "pm", player, message)
  1960. end
  1961. addEventHandler("onPlayerPrivateMessage", getRootElement(), disableMsg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement