Advertisement
LuckOake

RadBr Banishment System

Nov 3rd, 2012
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.89 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <mod name="RadBr Banishment System" version="1.0" author="LuckOake" contact="none" enabled="yes">
  3. ------------------------------------------------------------------------------------
  4. <config name="radban"><![CDATA[
  5. barid = 9971 -- ID das barras para desbanir
  6.  
  7. function getPlayerAccountStorageValue(name, key)
  8.     local result, ret = db.getResult("SELECT `value` FROM `account_storage` WHERE `acc_id` = '".. getAccountIdByName(name) .."' AND `key` = ".. key ..";")
  9.     if result:getID() == -1 then
  10.         return nil
  11.     end
  12.     ret = result:getDataInt("value")
  13.     result:free()
  14.     return ret
  15. end
  16.  
  17. function setPlayerAccountStorageValue(name, key, value)
  18.     local result = db.getResult("SELECT * FROM `account_storage` WHERE `acc_id` = ".. getAccountIdByName(name) .." AND `key` = ".. key ..";")
  19.     if result:getID() == -1 then
  20.         return db.executeQuery("INSERT INTO `account_storage` (`acc_id`, `key`, `value`) VALUES (".. getAccountIdByName(name) ..", ".. key ..", ".. value ..");")
  21.     else
  22.         result:free()
  23.         return db.executeQuery("UPDATE `account_storage` SET `value` = ".. value .." WHERE `acc_id` = ".. getAccountIdByName(name) .." AND `key` = ".. key ..";")
  24.     end
  25. end
  26.  
  27. function getWarnings(name)
  28.     return getPlayerAccountStorageValue(name, 21798)
  29. end
  30.  
  31. function setWarnings(name, count)
  32.     return setPlayerAccountStorageValue(name, 21798, count)
  33. end
  34. ]]></config>
  35. ------------------------------------------------------------------------------------
  36. <talkaction words="/ban" event="buffer"><![CDATA[
  37. domodlib('radban')
  38.         local t = string.explode(param, ",")
  39.         local a = {
  40.             [1] = 7,
  41.             [2] = 14,
  42.             [3] = 30,
  43.             [4] = 60,
  44.             [5] = 9999,
  45.             [6] = 9999,
  46.             [7] = 9999,
  47.             [8] = 9999,
  48.             [9] = 9999,
  49.             [10] = 9999,
  50.             [11] = 9999,
  51.         }
  52.        
  53.         local b = a[t[3]]
  54.        
  55.         if not t[2] or tonumber(t[2]) or t[3] and not tonumber(t[3]) or t[4] then
  56.             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Especifique nome,motivo,warnings(opcional).") return true
  57.         elseif not getPlayerGUIDByName(t[1]) then
  58.             doPlayerSendCancel(cid, "O jogador "..t[1].." não existe.") return true
  59.         elseif isAccountBanished(getAccountIdByName(t[1])) then
  60.             doPlayerSendCancel(cid, "O player "..t[1].." já está banido.") return true
  61.         elseif t[3] and tonumber(t[3]) < 1 then
  62.             doPlayerSendCancel(cid, "Desculpe, mas o mínimo de warnings é 1.") return true
  63.         elseif t[3] and tonumber(t[3]) > 11 then
  64.             doPlayerSendCancel(cid, "Desculpe, mas o máximo de warnings é 11.") return true
  65.         elseif not getWarnings(t[1]) or getWarnings(t[1]) < 0 then
  66.             setWarnings(t[1], 0)
  67.         elseif t[3] and tonumber(t[3]) <= getWarnings(t[1]) then
  68.             doPlayerSendCancel(cid, "Desculpe, mas esse player já tem "..getWarnings(t[1]).." warnings.") return true
  69.         end
  70.        
  71.         if getPlayerByName(t[1]) then
  72.             doRemoveCreature(getPlayerByName(t[1]))
  73.         end
  74.         if t[3] then
  75.             doAddAccountBanishment(getAccountIdByName(t[1]), target, os.time() + (a[tonumber(t[3])]*3600*24), 5, 2, t[2], 0)
  76.             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você baniu o jogador "..t[1]..". Warnings setadas de "..getWarnings(t[1]).." para "..t[3]..".")
  77.             broadcastMessage("Jogador "..t[1].." notificado por "..getCreatureName(cid)..". Notificações setadas de "..getWarnings(t[1]).." para "..t[3]..". Comentário: "..t[2]..".")
  78.             setWarnings(t[1], tonumber(t[3]))
  79.         else
  80.             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você baniu o jogador "..t[1]..". Warnings setadas de "..getWarnings(t[1]).." para "..(getWarnings(t[1])+1)..".")
  81.             broadcastMessage("Jogador "..t[1].." notificado por "..getCreatureName(cid)..". Notificações setadas de "..getWarnings(t[1]).." para "..(getWarnings(t[1])+1)..". Comentário: "..t[2]..".")
  82.             setWarnings(t[1], getWarnings(t[1])+1)
  83.             doAddAccountBanishment(getAccountIdByName(t[1]), target, os.time() + (a[getWarnings(t[1])]*3600*24), 5, 2, t[2], 0)
  84.         end
  85. return true
  86. ]]></talkaction>
  87. ------------------------------------------------------------------------------------
  88. <talkaction words="!unban" event="buffer"><![CDATA[
  89. domodlib('radban')
  90.     local a = {
  91.         [1] = 20,
  92.         [2] = 40,
  93.         [3] = 60,
  94.         [4] = 90,
  95.         [5] = 120,
  96.         [6] = 150,
  97.         [7] = 250,
  98.         [8] = 350,
  99.         [9] = 500,
  100.         [10] = 750,
  101.         [11] = 999,
  102.     }
  103.    
  104.     b = a[getWarnings(param)]
  105.    
  106.         if not getPlayerGUIDByName(param) then
  107.             doPlayerSendCancel(cid, "O jogador "..param.." não existe.") return true
  108.         elseif not isAccountBanished(getAccountIdByName(param)) then
  109.             doPlayerSendCancel(cid, "Esse jogador não está banido.") return true
  110.         elseif not doPlayerRemoveItem(cid, barid, b) then
  111.             doPlayerSendCancel(cid, "Você deve ter "..b.." gold ingots para desbanir esse jogador.") return true
  112.         end
  113.        
  114.         doRemoveAccountBanishment(getAccountIdByName(param))
  115.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você desbaniu o jogador "..param.." pelo preço de "..b.." gold ingots.")
  116. return true
  117. ]]></talkaction>
  118. </mod>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement