Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.38 KB | None | 0 0
  1. Adm={Kubaws=1,Nicknamepll=1,Ouake=1}
  2. Ekw={}
  3.  
  4. 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")
  5.  
  6. tfm.exec.disableAutoNewGame(true)
  7. tfm.exec.disableAutoShaman(true)
  8. players={}
  9. toDespawn={}
  10. 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}
  11.  
  12. function eventPlayerDataLoaded(nick,data)
  13. Ekw[nick].PLIK=data
  14. if data:find("SAO") then
  15. for p in data:gmatch("{SAO:(%d+)}") do
  16. Ekw[nick].spkt={tonumber(p),0}
  17. end
  18. else
  19. Ekw[nick].spkt={0,0}
  20. end
  21. end
  22.  
  23. function eventPlayerLeft(nick)
  24. if nick:sub(1,1)~="*" then
  25. if Ekw[nick].PLIK:find("SNIP") then
  26. a=Ekw[nick].PLIK:find("SNIP")+4
  27. b=Ekw[nick].PLIK:sub(a):find("}")
  28. Ekw[nick].PLIK=Ekw[nick].PLIK:sub(1,a)..Ekw[nick].spkt[1]+Ekw[nick].spkt[2]..Ekw[nick].PLIK:sub(b)
  29. system.savePlayerData(nick,Ekw[nick].PLIK)
  30. else
  31. Ekw[nick].PLIK=Ekw[nick].PLIK.."{SNIP:"..Ekw[nick].spkt[1]+Ekw[nick].spkt[2].."}"
  32. system.savePlayerData(nick,Ekw[nick].PLIK)
  33. end
  34. end
  35. end
  36.  
  37. local players = {}
  38. local objects = {}
  39.  
  40. function main()
  41. objects = queue.new()
  42. tfm.exec.disableAutoScore(false)
  43. tfm.exec.setUIMapName('<ROSE><B><br><br><br><br><br>#SNIPER<br><br><br><br><br><br></B>')
  44. end
  45.  
  46. function eventNewGame()
  47. players = {}
  48. for name in pairs(tfm.get.room.playerList) do
  49. initPlayer(name)
  50. end
  51. end
  52.  
  53. function initPlayer(name)
  54. players[name] = {ammo = 1e99}
  55. ui.addTextArea(0, "", name, 10, 30, 6 * 15, 20, 0x010101, 0x000000, 0.5)
  56. system.bindMouse(name, true)
  57. end
  58.  
  59. function eventMouse(name, x, y)
  60. local player = players[name]
  61. if player and player.ammo > 0 then
  62. -- remove one ammo
  63. ui.removeTextArea(player.ammo * 2 - 1, name)
  64. ui.removeTextArea(player.ammo * 2, name)
  65. player.ammo = player.ammo - 1
  66.  
  67. local roomPlayer = tfm.get.room.playerList[name]
  68.  
  69. -- calculate angle between player and click
  70. local dx = x - roomPlayer.x
  71. local dy = y - roomPlayer.y
  72. local angle = math.atan2(dy, dx)
  73.  
  74. -- calculate speeds to direct arrow and always have the same total speed
  75. local vx = math.cos(angle)
  76. local vy = math.sin(angle)
  77.  
  78. -- spawn arrow and add to queue
  79. if Ekw[name].wyg then
  80. 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]))
  81. else
  82. 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)))
  83. end
  84. local recoil = -vx * 10
  85. -- workaround to avoid argument exception bug
  86. if recoil <= -1 or recoil >= 1 then
  87. tfm.exec.movePlayer(name, 0, 0, true, recoil, 0, true)
  88. end
  89.  
  90. -- remove first arrow when there are too many
  91. if objects.size > 12 then
  92. tfm.exec.removeObject(queue.remove(objects))
  93. end
  94. end
  95. end
  96.  
  97. local loopCount = 0
  98. function eventLoop()
  99. -- loopCount resets after a certain amount
  100. if loopCount == 0 then
  101. ammo()
  102. end
  103. loopCount = (loopCount + 3) % 2
  104. end
  105.  
  106. function ammo()
  107. for name, player in pairs(players) do
  108. local ammo = player.ammo
  109. if ammo < 6 then
  110. -- add one ammo
  111. player.ammo = ammo + 1
  112. ui.addTextArea(ammo * 2 + 1, "", name, 14 + ammo * 15, 39, 3, 3, 0x990000, 0x990000, 1)
  113. ui.addTextArea(ammo * 2 + 2, "", name, 15 + ammo * 15, 40, 1, 1, 0xff0000, 0xcc0000, 1)
  114. end
  115. end
  116. end
  117.  
  118. function eventNewPlayer(name)
  119. initPlayer(name)
  120. Ekw[name]={id={},kup={},spkt={0,0}}
  121. system.loadPlayerData(name)
  122. ui.addTextArea(901,"<a href='event:sklep'>Sklep</a>",name,750,30,n,n,n,n,1,true)
  123. if Adm[name] then
  124. ui.addTextArea(902,"<a href='event:KOM'>Komendy</a>",name,730,60,n,n,n,n,1,true)
  125. end
  126. end
  127.  
  128. -- simple queue for performance, much faster than system table queues, can contain nils
  129. queue = {}
  130.  
  131. function queue.new()
  132. return {
  133. tail = nil,
  134. head = nil,
  135. size = 0
  136. }
  137. end
  138.  
  139. function queue.insert(self, v)
  140. local i = {
  141. value = v,
  142. next = nil
  143. }
  144. if self.tail and self.head then
  145. self.tail.next = i
  146. else
  147. self.head = i
  148. end
  149. self.tail = i
  150. self.size = self.size + 1
  151. end
  152.  
  153. function queue.peek(self)
  154. if self.head then
  155. return self.head.value
  156. else
  157. error("queue is empty")
  158. end
  159. end
  160.  
  161. function queue.remove(self)
  162. local r = queue.peek(self)
  163. self.head = self.head.next
  164. if not self.head then
  165. tail = nil
  166. end
  167. self.size = self.size - 1
  168. return r
  169. end
  170.  
  171. function eventNewGame()
  172. for name in pairs(tfm.get.room.playerList) do
  173. system.bindMouse(name,true)
  174. end
  175. started=false
  176. for admin in pairs(Adm) do
  177. tfm.exec.setNameColor(admin,0xff0000)
  178. end
  179. end
  180.  
  181. function eventLoop(time,remaining)
  182. if time >= 3000 and not started then
  183. started=true
  184. end
  185. if remaining<=0 then
  186. tfm.exec.newGame(maps[math.random(#maps)])
  187. end
  188. for i,cannon in ipairs(toDespawn) do
  189. if cannon[1] <= os.time()-3000 then
  190. tfm.exec.removeObject(cannon[2])
  191. table.remove(toDespawn,i)
  192. end
  193. end
  194. end
  195.  
  196. function eventPlayerWon (n)
  197. system.bindMouse(n,false)
  198. p=tfm.get.room.playerList[n]
  199. for i=1,15 do
  200. tfm.exec.displayParticle(5,p.x,p.y,math.random(-20,20)/10,math.random(-20,20)/10,0,0)
  201. end
  202. end
  203.  
  204. function eventPlayerDied(name)
  205. local i=0
  206. local n
  207. system.bindMouse(name,false)
  208. for pname,player in pairs(tfm.get.room.playerList) do
  209. if not player.isDead then
  210. i=i+1
  211. n=pname
  212. end
  213. end
  214. if i==0 then
  215. tfm.exec.newGame(maps[math.random(#maps)])
  216. elseif i==1 then
  217. tfm.exec.giveCheese(n)
  218. tfm.exec.playerVictory(n)
  219. tfm.exec.setGameTime(5)
  220. Ekw[n].spkt[1]=Ekw[n].spkt[1]+1
  221. end
  222. end
  223.  
  224. function eventChatCommand(n,com)
  225. local arg={}
  226. for argument in com:gmatch("[^%s]+") do
  227. table.insert(arg,argument)
  228. end
  229. if com=="pomoc" then
  230. ui.addPopup(0,0,"Witaj w mnigrze Sniper Strzelasz myszką a pkt Za wygraną.",n,300,150,200,true)
  231. elseif Adm[n] then
  232. if arg[1]=='pkt' and Ekw[arg[3] or n] then
  233. Ekw[arg[3] or n].spkt[1]=Ekw[arg[3] or n].spkt[1]+(arg[2] and tonumber(arg[2]) or 0)
  234. elseif com:sub(0,2)=='q ' then
  235. tfm.exec.chatMessage("<j>• [Admin][Sniper]["..n.."] <n>"..com:sub(3),nil)
  236. elseif com:sub(0,2)=='p ' then
  237. tfm.exec.chatMessage("<R>• [Ogłoszenie] <n>"..com:sub(5),nil)
  238. end
  239. end
  240. end
  241. system.disableChatCommandDisplay("q",true)
  242. system.disableChatCommandDisplay("pkt",true)
  243. system.disableChatCommandDisplay("pomoc",true)
  244.  
  245. for name,player in pairs(tfm.get.room.playerList) do
  246. eventNewPlayer(name)
  247. end
  248.  
  249. tfm.exec.newGame(maps[math.random(#maps)])
  250.  
  251. main()
  252.  
  253. Bron={
  254. [0]={id=0,35,0},
  255.  
  256. {id=1,1,180,"HKy4bGl.png",297,100},
  257. {id=2,39,80,"uzunidM.png",390,95},
  258. {id=3,6,70,"Q7h1gpD.png",490,95},
  259. {id=4,10,100,"NA04CBA.png",590,95},
  260. {id=5,60,180,"CJg50t1.png",293,230},
  261. {id=6,28,200,"3DkeaIN.png",393,230},
  262. {id=7,32,50,"0MfStnq.png",490,230},
  263. {id=8,34,20,"L5ZXQX2.png",595,233},
  264.  
  265. {id=9,35,50,"OPMMdB2.jpg",305,120,"OPMMdB2.jpg",12,4},
  266. {id=10,35,50,"dKK184q.jpg",405,120,"dKK184q.jpg",12,4},
  267. {id=11,35,50,"Vf4FeDo.jpg",505,120,"Vf4FeDo.jpg",12,4},
  268. {id=12,35,50,"duZSI9V.jpg",605,120,"duZSI9V.jpg",12,4},
  269. {id=13,35,150,"fpv21hR.jpg",305,260,"fpv21hR.jpg",12,4},
  270. {id=14,10,150,"WYb9wSv.jpg",395,240,"WYb9wSv.jpg",15,15},
  271. {id=15,1,180,"T22TnA2.jpg",495,240,"T22TnA2.jpg",15,15},
  272. {id=16,1,130,"RyMLERx.jpg",595,240,"RyMLERx.jpg",15,15}
  273. }
  274.  
  275. function eventTextAreaCallback(id,name,cb)
  276. if cb=="sklep" then
  277. Ekw[name].str=1
  278. ui.addTextArea(1,"",name,100,50,603,300,0xa17e1d,0xa17e1d,1,true)
  279. 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)
  280. for v,id in pairs(Ekw[name].id) do
  281. if id then
  282. tfm.exec.removeImage(id,name)
  283. end
  284. end
  285. for i=1,8 do
  286. 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)
  287. 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)
  288. end
  289. ui.addTextArea(2,"",name,200,80,1,250,0x574204,0x574204,1,true)
  290. ui.addTextArea(3,"",name,100,50,603,12,0x574204,0x574204,1,true)
  291. 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)
  292. ui.addTextArea(5,"",name,101,362,600,14,0x574204,0x574204,1,true)
  293. ui.addTextArea(6,"<a href='event:z'>Zamknij</a>",name,370,361,272,25,0,0,1,true)
  294. ui.addTextArea(16,"1/1",name,430,330,500,500,0,0,1,true)
  295. elseif cb:sub(1,3)=="WEZ" then
  296. cb=tonumber(cb:sub(4))
  297. Ekw[name].br=Bron[cb][1]
  298. elseif cb:sub(1,3)=="KUP" then
  299. cb=tonumber(cb:sub(4))
  300. Ekw[name].br=Bron[cb][1]
  301. Ekw[name].wyg=(Bron[cb][6] and {Bron[cb][6],Bron[cb][7],Bron[cb][8]} or n)
  302. Ekw[name].kup[Bron[cb].id]=1
  303. Ekw[name].spkt[1]=Ekw[name].spkt[1]-Bron[cb][2]
  304. Ekw[name].spkt[2]=Ekw[name].spkt[2]+Bron[cb][2]
  305. eventTextAreaCallback(nil,name,"STR"..Ekw[name].str)
  306. elseif cb:sub(1,3)=="STR" then
  307. Ekw[name].str=tonumber(cb:sub(4))
  308. for v,id in pairs(Ekw[name].id) do
  309. tfm.exec.removeImage(id,name)
  310. end
  311. 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)
  312. for i=1,8 do
  313. if Bron[i+(Ekw[name].str-1)*8] then
  314. 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)
  315. 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)
  316. else
  317. ui.removeTextArea(i+7,name)
  318. end
  319. end
  320. elseif cb=="z" then
  321. for i=1,16 do
  322. ui.removeTextArea(i,name)
  323. end
  324. for v,id in pairs(Ekw[name].id) do
  325. tfm.exec.removeImage(id,name)
  326. end
  327. -- elseif cb=="KOM" then
  328. -- ui.addTextArea(900,"<a href='event:a'>Zdejmij</a>",name,120,80,n,n,0x324650,0x324650,0.0,true)
  329. end
  330. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement