Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.73 KB | None | 0 0
  1. function isWalkable(pos, creature, proj, pz)-- by Nord
  2.     if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
  3.     if getTopCreature(pos).uid > 0 and creature then return false end
  4.     if getTileInfo(pos).protection and pz then return false, true end
  5.     local n = not proj and 3 or 2
  6.     for i = 0, 255 do
  7.         pos.stackpos = i
  8.         local tile = getTileThingByPos(pos)
  9.         if tile.itemid ~= 0 and not isCreature(tile.uid) then
  10.             if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
  11.                 return false
  12.             end
  13.         end
  14.     end
  15.     return true
  16. end
  17. function randearMap(cid)
  18.     local pos = {x=math.random(SBW_AREA[1].x, SBW_AREA[2].x), y=math.random(SBW_AREA[1].y,SBW_AREA[2].y), z=SBW_AREA[1].z}
  19.     if not isWalkable(pos, false, false, false) then
  20.         randearMap(cid)
  21.     else
  22.         doTeleportThing(cid, pos)
  23.         doSendMagicEffect(pos,6)
  24.     end
  25. end
  26. function onSay(cid, words, param, channel)
  27. local k = string.explode(param, ",")
  28. if(k[1] ~= nil) then
  29.         if(string.upper(k[1]) == 'INFO') then
  30.             local score = {}
  31.             local output =  "Voce tem " .. getPlayerStorageValue(cid, SBW_SCORE) .. " pontos.\nVoce tem "..getPlayerStorageValue(cid, SBW_AMMO).."x municoes.\n------------------\nO maior matador:\n"
  32.             for _, pid in ipairs(getPlayersOnline()) do
  33.                 if getPlayerStorageValue(pid, SBW_INEVENT) then
  34.                     table.insert(score, {getCreatureName(pid), getPlayerStorageValue(pid, SBW_SCORE)})
  35.                 end
  36.             end
  37.             local lx = table.getn(score)
  38.             if(lx > 3) then lx = 3 end
  39.                 table.sort(score, function(a, b) return a[2] > b[2] end)
  40.                 for k = 1,lx do
  41.                     output = output .. k..". "..score[k][1] .." [".. score[k][2] .."].\n"
  42.                 end
  43.                 doPlayerPopupFYI(cid, output)
  44.             end
  45. if (string.upper(k[1]) == 'ATIRAR') then
  46.     if(getPlayerStorageValue(cid, SBW_INEVENT) == 1) and not getTileInfo(getThingPos(cid)).protection then
  47.         if getPlayerStorageValue(cid, SBW_EXAUSTHED) <= 1 then
  48.             if(getPlayerStorageValue(cid, SBW_AMMO) > 0) then
  49.                 if SBW_STATUS == 'on' then
  50.                     if(SBW_AMMOINFI == false) then
  51.                         doPlayerSetStorageValue(cid, SBW_AMMO, getPlayerStorageValue(cid, SBW_AMMO)-1)
  52.                     end
  53.                     doPlayerSetStorageValue(cid, SBW_EXAUSTHED, 2)
  54.                     lineAnimation(getPlayerLookDirection(cid),getCreaturePosition(cid),12,cid,1,0,1,0,0,0,1,0)
  55.                     addEvent(doPlayerSetStorageValue, SBW_SHOOTEXAUSTHED, cid, SBW_EXAUSTHED, 1)
  56.                     if (getPlayerStorageValue(cid, SBW_AMMO) ~= 1) then
  57.                         doPlayerSendTextMessage(cid, 27, "Restam "..getPlayerStorageValue(cid, SBW_AMMO).."x bolas de neve.")
  58.                     else
  59.                         doPlayerSendTextMessage(cid, 27, "Usando sua ultima bola de neve.")
  60.                     end
  61.                 end
  62.             else
  63.                 doPlayerSendCancel(cid, "Voce esta sem bolas de neve, recarregue no centro do campo ou mate um inimigo.")
  64.                 doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)    
  65.             end
  66.         else
  67.             doPlayerPopupFYI(cid, "Voce nao pode atirar tao rapido.")
  68.             doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  69.             return false
  70.         end
  71.     else
  72.         doPlayerPopupFYI(cid, "Voce precisa estar no evento ou fora do protection zone.")
  73.         doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  74.     end
  75. end
  76. end
  77. return true
  78. end
  79.  
  80.  
  81.                 function lineAnimation(lookDir,playerPos,effect,cid,fvar,fpos,ffound,fposV,fcheck,fvcid,floopCounter,fvpid, name)
  82.                 local var = fvar
  83.                 local pos = fpos
  84.                 local found = ffound
  85.                 local posV = fposV
  86.                 local check = fcheck
  87.                 local vcid = fvcid
  88.                 local loopCounter = floopCounter
  89.                 local vpid = fvpid
  90.                 local storage = SBW_EXAUSTHED
  91.                         if var < 2 then
  92.                                 vcid = cid
  93.                         end
  94.                         pos = playerPos
  95.                         if not isInWallArray(convert(lookDir,pos)) then--isInWallArray({x=convert(lookDir,pos).x, y=convert(lookDir,pos).y,z=convert(lookDir,pos).z}) then --isInArray(t.onShoot.misc.walls_id, getThingfromPos({x=convert(lookDir,pos).x, y=convert(lookDir,pos).y,z=convert(lookDir,pos).z, stackpos=0}).itemid) then
  96.                                 doSendDistanceShoot(pos, convert(lookDir,pos),effect)
  97.                                 pos = convert(lookDir,pos)
  98.                                 var=var+1
  99.                                 posV = convertV(lookDir,playerPos)
  100.                                 for _, pid in ipairs(getPlayersOnline()) do
  101.                                         if (getCreaturePosition(pid).x == pos.x and getCreaturePosition(pid).y == pos.y and getCreaturePosition(pid).z == pos.z) then
  102.                                                 --if loopCounter > 2 then
  103.                                                 vpid = pid
  104.                                                 --end
  105.                                                 if (vpid ~= vcid) then
  106.                                                         if var > 2 then
  107.                                                                 if (getCreaturePosition(pid).x == posV.x and getCreaturePosition(pid).y == posV.y and getCreaturePosition(pid).z == posV.z) then
  108.                                                                         killPlayer(pid,pos,getCreatureName(vcid))
  109.                                                                         if (lookDir == 0) or (lookDir == 2) then
  110.                                                                                 var = 6
  111.                                                                         else
  112.                                                                                 var = 8
  113.                                                                         end
  114.                                                                 end
  115.                                                         end
  116.                                                         killPlayer(pid,pos,vcid)
  117.                                                         if (lookDir == 0) or (lookDir == 2) then
  118.                                                                 var = 6
  119.                                                         else
  120.                                                                 var = 8
  121.                                                         end
  122.                                                 end
  123.                                         end
  124.                                         loopCounter = loopCounter +1
  125.                                 end    
  126.                                 if (lookDir == 0) or (lookDir == 2) then
  127.                                         if var ~= 6 then
  128.                                                 addEvent(lineAnimation, SBW_BALLSPEED, lookDir,pos,effect,nil,var,pos,found,posV,check,vcid,loopCounter,vpid)
  129.                                         else
  130.                                                 var = 1
  131.                                         end
  132.                                 else
  133.                                         if var ~= 8 then
  134.                                                 addEvent(lineAnimation,  SBW_BALLSPEED, lookDir,pos,effect,nil,var,pos,found,posV,check,vcid,loopCounter,vpid)
  135.                                         else
  136.                                                 var = 1
  137.                                         end
  138.                                 end
  139.                         else
  140.                                 doSendMagicEffect(convert(lookDir,pos),2)
  141.                                 var = 1
  142.                         end
  143.                 end
  144.  
  145.                 local ret = {}
  146.                 function convert(lookDir,pos)
  147.                 local positions = {
  148.                         [0] = {x = pos.x, y = pos.y-1, z = pos.z},
  149.                         [1] = {x = pos.x+1, y = pos.y, z = pos.z},
  150.                         [2] = {x = pos.x, y = pos.y+1, z = pos.z},
  151.                         [3] = {x = pos.x-1, y = pos.y, z = pos.z}
  152.                         }
  153.                         ret = positions[lookDir]
  154.                 return ret
  155.                 end
  156.  
  157.  
  158.                 local ret = {}
  159.                 function convertV(lookDir,pos)
  160.                 local positions = {
  161.                         [0] = {x = pos.x, y = pos.y+1, z = pos.z},
  162.                         [1] = {x = pos.x-1, y = pos.y, z = pos.z},
  163.                         [2] = {x = pos.x, y = pos.y-1, z = pos.z},
  164.                         [3] = {x = pos.x+1, y = pos.y, z = pos.z}
  165.                         }
  166.                         ret = positions[lookDir]
  167.                 return ret
  168.                 end
  169.                
  170.                 function isInWallArray(pos)
  171.                         for k = 0, table.getn(SBW_WALLSID) do
  172.                                 if getTileItemById(pos, SBW_WALLSID[k]).itemid == SBW_WALLSID[k] then --this doesn't even make sense but tried other ways and it gave errors, so meh 2lazy2search
  173.                                     return true    
  174.                                 end
  175.                         end
  176.                         return false
  177.                 end
  178.                                
  179.                 function killPlayer(cid, pos, killer)
  180.                     randearMap(cid)
  181.                     doSendMagicEffect(pos,2)
  182.                     doSendAnimatedText(pos, getCreatureName(killer).." ", 55)
  183.                     doPlayerSendTextMessage(cid, 27, "Voce foi morto por "..getCreatureName(killer)..".")
  184.                     doPlayerSetStorageValue(killer, SBW_SCORE, getPlayerStorageValue(killer, SBW_SCORE)+SBW_POINTSKILL)            
  185.                     doPlayerSendTextMessage(killer, 27, "You've killed "..getCreatureName(cid)..".")
  186.                     if SBW_LOSTSCORE then
  187.                         doPlayerSetStorageValue(cid, SBW_SCORE, getPlayerStorageValue(cid, SBW_SCORE)-1)
  188.                     end
  189.                     if SBW_RESETAMMO then
  190.                         doPlayerSetStorageValue(cid, SBW_AMMO, SBW_MINAMMO)
  191.                     end
  192.                 end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement