Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Adm={Kubaws=1,Nicknamepll=1,Ouake=1}
- Ekw={}
- tfm.exec.chatMessage("Welcome to <rose>#Sniper<BL>. Use the mouse to aim and shoot!\nBy <rose>Kubaws<BL> and <rose>Ouake<BL>\nCredits: Gunitor and Nicknamepll")
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoShaman(true)
- players={}
- toDespawn={}
- maps={521833,401421,541917,541928,541936,541943,527935,559634,559644,888052,878047,885641,770600,770656,772172,891472,589736,589800,589708,900012,901062,754380,901337,901411,907870,910078,1190467,1252043,1124380,1016258,1252299,1255902,1256808,986790,1285380,1271249,1255944,1255983,1085344,1273114,1276664,1279258,1286824,1280135,1280342,1284861,1287556,1057753,1196679,1288489,1292983,1298164,1298521,1293189,1296949,1308378,1311136,1314419,1314982,1318248,1312411,1312589,1312845,1312933,1313969,1338762,1339474,1349878,1297154,644588,1351237,1354040,1354375,1362386,1283234,1370578,1306592,1360889,1362753,1408124,1407949,1407849,1343986,1408028,1441370,1443416,1389255,1427349,1450527,1424739,869836,1459902,1392993,1426457,1542824,1533474,1561467,1563534,1566991,1587241,1416119,1596270,1601580,1525751,1582146,1558167,1420943,1466487,1642575,1648013,1646094,1393097,1643446,1545219,1583484,1613092,1627981,1633374,1633277,1633251,1585138,1624034,1616785,1625916,1667582,1666996,1675013,1675316,1531316,1665413,1681719,1699880,1688696,623770,1727243,1531329,1683915,1689533,1738601,3756146,912118,3326933,3722005,3566478,1456622,1357994,1985670,1884075,1708065,1700322,2124484,3699046,2965313,4057963,4019126,3335202,2050466}
- function eventPlayerDataLoaded(nick,data)
- Ekw[nick].PLIK=data
- if data:find("SAO") then
- for p in data:gmatch("{SAO:(%d+)}") do
- Ekw[nick].spkt={tonumber(p),0}
- end
- else
- Ekw[nick].spkt={0,0}
- end
- end
- function eventPlayerLeft(nick)
- if nick:sub(1,1)~="*" then
- if Ekw[nick].PLIK:find("SNIP") then
- a=Ekw[nick].PLIK:find("SNIP")+4
- b=Ekw[nick].PLIK:sub(a):find("}")
- Ekw[nick].PLIK=Ekw[nick].PLIK:sub(1,a)..Ekw[nick].spkt[1]+Ekw[nick].spkt[2]..Ekw[nick].PLIK:sub(b)
- system.savePlayerData(nick,Ekw[nick].PLIK)
- else
- Ekw[nick].PLIK=Ekw[nick].PLIK.."{SNIP:"..Ekw[nick].spkt[1]+Ekw[nick].spkt[2].."}"
- system.savePlayerData(nick,Ekw[nick].PLIK)
- end
- end
- end
- local players = {}
- local objects = {}
- function main()
- objects = queue.new()
- tfm.exec.disableAutoScore(false)
- tfm.exec.setUIMapName('<ROSE><B><br><br><br><br><br>#SNIPER<br><br><br><br><br><br></B>')
- end
- function eventNewGame()
- players = {}
- for name in pairs(tfm.get.room.playerList) do
- initPlayer(name)
- end
- end
- function initPlayer(name)
- players[name] = {ammo = 1e99}
- ui.addTextArea(0, "", name, 10, 30, 6 * 15, 20, 0x010101, 0x000000, 0.5)
- system.bindMouse(name, true)
- end
- function eventMouse(name, x, y)
- local player = players[name]
- if player and player.ammo > 0 then
- -- remove one ammo
- ui.removeTextArea(player.ammo * 2 - 1, name)
- ui.removeTextArea(player.ammo * 2, name)
- player.ammo = player.ammo - 1
- local roomPlayer = tfm.get.room.playerList[name]
- -- calculate angle between player and click
- local dx = x - roomPlayer.x
- local dy = y - roomPlayer.y
- local angle = math.atan2(dy, dx)
- -- calculate speeds to direct arrow and always have the same total speed
- local vx = math.cos(angle)
- local vy = math.sin(angle)
- -- spawn arrow and add to queue
- if Ekw[name].wyg then
- queue.insert(objects, tfm.exec.addImage(Ekw[name].wyg[1],"#"..tfm.exec.addShamanObject((Ekw[name].br or 35), roomPlayer.x + 20 * vx, roomPlayer.y + 20 * vy, angle*180/math.pi, 50 * vx, 50 * vy,(Ekw[name].br and Ekw[name].br==32)),-Ekw[name].wyg[2],-Ekw[name].wyg[3]))
- else
- queue.insert(objects, tfm.exec.addShamanObject((Ekw[name].br or 35), roomPlayer.x + 20 * vx, roomPlayer.y + 20 * vy, angle*180/math.pi, 50 * vx, 50 * vy,(Ekw[name].br and Ekw[name].br==32)))
- end
- local recoil = -vx * 10
- -- workaround to avoid argument exception bug
- if recoil <= -1 or recoil >= 1 then
- tfm.exec.movePlayer(name, 0, 0, true, recoil, 0, true)
- end
- -- remove first arrow when there are too many
- if objects.size > 12 then
- tfm.exec.removeObject(queue.remove(objects))
- end
- end
- end
- local loopCount = 0
- function eventLoop()
- -- loopCount resets after a certain amount
- if loopCount == 0 then
- ammo()
- end
- loopCount = (loopCount + 3) % 2
- end
- function ammo()
- for name, player in pairs(players) do
- local ammo = player.ammo
- if ammo < 6 then
- -- add one ammo
- player.ammo = ammo + 1
- ui.addTextArea(ammo * 2 + 1, "", name, 14 + ammo * 15, 39, 3, 3, 0x990000, 0x990000, 1)
- ui.addTextArea(ammo * 2 + 2, "", name, 15 + ammo * 15, 40, 1, 1, 0xff0000, 0xcc0000, 1)
- end
- end
- end
- function eventNewPlayer(name)
- initPlayer(name)
- Ekw[name]={id={},kup={},spkt={0,0}}
- system.loadPlayerData(name)
- ui.addTextArea(901,"<a href='event:sklep'>Sklep</a>",name,750,30,n,n,n,n,1,true)
- if Adm[name] then
- ui.addTextArea(902,"<a href='event:KOM'>Komendy</a>",name,730,60,n,n,n,n,1,true)
- end
- end
- -- simple queue for performance, much faster than system table queues, can contain nils
- queue = {}
- function queue.new()
- return {
- tail = nil,
- head = nil,
- size = 0
- }
- end
- function queue.insert(self, v)
- local i = {
- value = v,
- next = nil
- }
- if self.tail and self.head then
- self.tail.next = i
- else
- self.head = i
- end
- self.tail = i
- self.size = self.size + 1
- end
- function queue.peek(self)
- if self.head then
- return self.head.value
- else
- error("queue is empty")
- end
- end
- function queue.remove(self)
- local r = queue.peek(self)
- self.head = self.head.next
- if not self.head then
- tail = nil
- end
- self.size = self.size - 1
- return r
- end
- function eventNewGame()
- for name in pairs(tfm.get.room.playerList) do
- system.bindMouse(name,true)
- end
- started=false
- for admin in pairs(Adm) do
- tfm.exec.setNameColor(admin,0xff0000)
- end
- end
- function eventLoop(time,remaining)
- if time >= 3000 and not started then
- started=true
- end
- if remaining<=0 then
- tfm.exec.newGame(maps[math.random(#maps)])
- end
- for i,cannon in ipairs(toDespawn) do
- if cannon[1] <= os.time()-3000 then
- tfm.exec.removeObject(cannon[2])
- table.remove(toDespawn,i)
- end
- end
- end
- function eventPlayerWon (n)
- system.bindMouse(n,false)
- p=tfm.get.room.playerList[n]
- for i=1,15 do
- tfm.exec.displayParticle(5,p.x,p.y,math.random(-20,20)/10,math.random(-20,20)/10,0,0)
- end
- end
- function eventPlayerDied(name)
- local i=0
- local n
- system.bindMouse(name,false)
- for pname,player in pairs(tfm.get.room.playerList) do
- if not player.isDead then
- i=i+1
- n=pname
- end
- end
- if i==0 then
- tfm.exec.newGame(maps[math.random(#maps)])
- elseif i==1 then
- tfm.exec.giveCheese(n)
- tfm.exec.playerVictory(n)
- tfm.exec.setGameTime(5)
- Ekw[n].spkt[1]=Ekw[n].spkt[1]+1
- end
- end
- function eventChatCommand(n,com)
- local arg={}
- for argument in com:gmatch("[^%s]+") do
- table.insert(arg,argument)
- end
- if com=="pomoc" then
- ui.addPopup(0,0,"Witaj w mnigrze Sniper Strzelasz myszką a pkt Za wygraną.",n,300,150,200,true)
- elseif Adm[n] then
- if arg[1]=='pkt' and Ekw[arg[3] or n] then
- Ekw[arg[3] or n].spkt[1]=Ekw[arg[3] or n].spkt[1]+(arg[2] and tonumber(arg[2]) or 0)
- elseif com:sub(0,2)=='q ' then
- tfm.exec.chatMessage("<j>• [Admin][Sniper]["..n.."] <n>"..com:sub(3),nil)
- elseif com:sub(0,2)=='p ' then
- tfm.exec.chatMessage("<R>• [Ogłoszenie] <n>"..com:sub(5),nil)
- end
- end
- end
- system.disableChatCommandDisplay("q",true)
- system.disableChatCommandDisplay("pkt",true)
- system.disableChatCommandDisplay("pomoc",true)
- for name,player in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- tfm.exec.newGame(maps[math.random(#maps)])
- main()
- Bron={
- [0]={id=0,35,0},
- {id=1,1,180,"HKy4bGl.png",297,100},
- {id=2,39,80,"uzunidM.png",390,95},
- {id=3,6,70,"Q7h1gpD.png",490,95},
- {id=4,10,100,"NA04CBA.png",590,95},
- {id=5,60,180,"CJg50t1.png",293,230},
- {id=6,28,200,"3DkeaIN.png",393,230},
- {id=7,32,50,"0MfStnq.png",490,230},
- {id=8,34,20,"L5ZXQX2.png",595,233},
- {id=9,35,50,"OPMMdB2.jpg",305,120,"OPMMdB2.jpg",12,4},
- {id=10,35,50,"dKK184q.jpg",405,120,"dKK184q.jpg",12,4},
- {id=11,35,50,"Vf4FeDo.jpg",505,120,"Vf4FeDo.jpg",12,4},
- {id=12,35,50,"duZSI9V.jpg",605,120,"duZSI9V.jpg",12,4},
- {id=13,35,150,"fpv21hR.jpg",305,260,"fpv21hR.jpg",12,4},
- {id=14,10,150,"WYb9wSv.jpg",395,240,"WYb9wSv.jpg",15,15},
- {id=15,1,180,"T22TnA2.jpg",495,240,"T22TnA2.jpg",15,15},
- {id=16,1,130,"RyMLERx.jpg",595,240,"RyMLERx.jpg",15,15}
- }
- function eventTextAreaCallback(id,name,cb)
- if cb=="sklep" then
- Ekw[name].str=1
- ui.addTextArea(1,"",name,100,50,603,300,0xa17e1d,0xa17e1d,1,true)
- ui.addTextArea(7,"<B><a href='event:KUP0'>Zdejmij</a>\n\n\t"..Ekw[name].spkt[1].."\n\n\n<a href='event:STR1'>Strona 1</a>\n<a href='event:STR2'>Strona 2</a>\n<a href='event:STR3'>Strona 3</a>",name,120,80,n,n,0x324650,0x324650,0.0,true)
- for v,id in pairs(Ekw[name].id) do
- if id then
- tfm.exec.removeImage(id,name)
- end
- end
- for i=1,8 do
- ui.addTextArea(i+7,"<p align='center'>"..(Ekw[name].kup[Bron[i+(Ekw[name].str-1)*8].id] and "<I><a href='event:WEZ"..(i+(Ekw[name].str-1)*8).."'>Weź" or Ekw[name].spkt[1]>=Bron[i+(Ekw[name].str-1)*8][2] and "<I><a href='event:KUP"..(i+(Ekw[name].str-1)*8).."'>Kup" or Bron[i+(Ekw[name].str-1)*8][2]),name,300+100*((i-1)%4),150+140*math.floor((i-1)/4),30,20,0x574204,0x574204,nil,true)
- Ekw[name].id[i]=tfm.exec.addImage(Bron[i+(Ekw[name].str-1)*8][3],"&1",Bron[i+(Ekw[name].str-1)*8][4],Bron[i+(Ekw[name].str-1)*8][5],name)
- end
- ui.addTextArea(2,"",name,200,80,1,250,0x574204,0x574204,1,true)
- ui.addTextArea(3,"",name,100,50,603,12,0x574204,0x574204,1,true)
- ui.addTextArea(4,"<p align='center'><font size='15' color='#009D9D'><b>Sklep</b></font></p>",name,100,45,603,25,0,0,1,true)
- ui.addTextArea(5,"",name,101,362,600,14,0x574204,0x574204,1,true)
- ui.addTextArea(6,"<a href='event:z'>Zamknij</a>",name,370,361,272,25,0,0,1,true)
- ui.addTextArea(16,"1/1",name,430,330,500,500,0,0,1,true)
- elseif cb:sub(1,3)=="WEZ" then
- cb=tonumber(cb:sub(4))
- Ekw[name].br=Bron[cb][1]
- elseif cb:sub(1,3)=="KUP" then
- cb=tonumber(cb:sub(4))
- Ekw[name].br=Bron[cb][1]
- Ekw[name].wyg=(Bron[cb][6] and {Bron[cb][6],Bron[cb][7],Bron[cb][8]} or n)
- Ekw[name].kup[Bron[cb].id]=1
- Ekw[name].spkt[1]=Ekw[name].spkt[1]-Bron[cb][2]
- Ekw[name].spkt[2]=Ekw[name].spkt[2]+Bron[cb][2]
- eventTextAreaCallback(nil,name,"STR"..Ekw[name].str)
- elseif cb:sub(1,3)=="STR" then
- Ekw[name].str=tonumber(cb:sub(4))
- for v,id in pairs(Ekw[name].id) do
- tfm.exec.removeImage(id,name)
- end
- ui.addTextArea(7,"<B><a href='event:KUP0'>Zdejmij</a>\n\n\t"..Ekw[name].spkt[1].."\n\n\n<a href='event:STR1'>Bronie</a>\n<a href='event:STR2'>Strzały</a>",name,120,80,n,n,0x324650,0x324650,0.0,true)
- for i=1,8 do
- if Bron[i+(Ekw[name].str-1)*8] then
- ui.addTextArea(i+7,"<p align='center'>"..(Ekw[name].kup[Bron[i+(Ekw[name].str-1)*8].id] and "<I><a href='event:WEZ"..(i+(Ekw[name].str-1)*8).."'>Weź" or Ekw[name].spkt[1]>=Bron[i+(Ekw[name].str-1)*8][2] and "<I><a href='event:KUP"..(i+(Ekw[name].str-1)*8).."'>Kup" or Bron[i+(Ekw[name].str-1)*8][2]),name,300+100*((i-1)%4),150+140*math.floor((i-1)/4),30,20,0x574204,0x574204,nil,true)
- Ekw[name].id[i]=tfm.exec.addImage(Bron[i+(Ekw[name].str-1)*8][3],"&1",Bron[i+(Ekw[name].str-1)*8][4],Bron[i+(Ekw[name].str-1)*8][5],name)
- else
- ui.removeTextArea(i+7,name)
- end
- end
- elseif cb=="z" then
- for i=1,16 do
- ui.removeTextArea(i,name)
- end
- for v,id in pairs(Ekw[name].id) do
- tfm.exec.removeImage(id,name)
- end
- -- elseif cb=="KOM" then
- -- ui.addTextArea(900,"<a href='event:a'>Zdejmij</a>",name,120,80,n,n,0x324650,0x324650,0.0,true)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement