Advertisement
Guest User

Untitled

a guest
Jan 19th, 2014
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.80 KB | None | 0 0
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <mod name="Rush Event" version="1.0" author="ChaitoSoft.com" contact="[email protected]" enabled="yes">
  3. <description>
  4. Configuration tutorial:
  5. q - message displayed when event starts
  6. d_1 - red team start position
  7. d_2 - blue team start position
  8. x - message displayed when event is not ready
  9. w - waiting room position
  10. lvl - minimal level to join event
  11. v - number of frags team needs to earn to win event
  12. mn - minimal amount of players to start event
  13. m - maximal amount of players to start event
  14. o - message displayed when red team wins
  15. y - message displayed when blue team wins
  16. i_1 - reward id (now is crystal coin = 2160)
  17. i_2 - amount of reward (now it is 10 crystal coins)
  18. t - time to start event (now it is 5 minutes)
  19. r - time that results of the battle will be shown to players (now it is 3 minutes)
  20.  
  21. Add this to 050-function.lua:
  22. -------------------------------------------------------------------------------------------------
  23. function doPlayerRemoveLethalConditions(cid)
  24. local tmp = {1, 2, 4, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 32768, 65536}
  25. for i = 1, #tmp do
  26. if(hasCondition(cid, tmp)) then doRemoveCondition(cid, tmp) end
  27. end
  28. return true
  29. end
  30. -------------------------------------------------------------------------------------------------
  31. Add this to login.lua:
  32. -------------------------------------------------------------------------------------------------
  33. registerCreatureEvent(cid, "RushCombat")
  34. registerCreatureEvent(cid, "RushAttack")
  35. registerCreatureEvent(cid, "RushDead")
  36. registerCreatureEvent(cid, "RushOutfit")
  37. -------------------------------------------------------------------------------------------------
  38. According to tutorial above you may set configuration yourself here(and something about locking knowledge):
  39. </description>
  40. <config name="re"><![CDATA[
  41. t = {
  42. a = 32145,
  43. g = 32146,
  44. l = 32147,
  45. u = 32148,
  46. h = 32149,
  47. wv = 32150,
  48. c = 0,
  49. q = "Rush Event has been started! Enjoy and have fun!",
  50. f = 5447,
  51. f_1 = 5448,
  52. f_2 = 5449,
  53. d_1 = {x = 570, y = 316, z = 10}, -- red temple
  54. d_2 = {x = 627, y = 284, z = 10}, -- blue temple
  55. x = "Event won't start bacause too few people were willing to participate",
  56. w = {x = 600, y = 362, z = 10},
  57. lvl = 50,
  58. v = 4,
  59. mn = 2,
  60. m = 40,
  61. o = "Event was completed, RED TEAM has won Rush Event!",
  62. y = "Event was completed, BLUE TEAM has won Rush Event!",
  63. i_1 = 2160,
  64. i_2 = 10,
  65. t = 1,
  66. r = 3
  67. }
  68. ]]></config>
  69. <globalevent name="Recognition" interval="150000" event="script"><![CDATA[
  70. domodlib('re')
  71. function onThink(interval, lastExecution, thinkInterval)
  72. if(getGlobalStorageValue(t.a) == 1) then
  73. for _, pid in ipairs(getPlayersOnline()) do
  74. if getPlayerStorageValue(pid, t.f) == 1 then
  75. if(getPlayerStorageValue(pid, t.f_1) == 0) then
  76. doSendAnimatedText(getCreaturePosition(pid), "RED TEAM", TEXTCOLOR_RED)
  77. elseif(getPlayerStorageValue(pid, t.f_1) == 1) then
  78. doSendAnimatedText(getCreaturePosition(pid), "BLUE TEAM", TEXTCOLOR_LIGHTBLUE)
  79. end
  80. end
  81. end
  82. return true
  83. end
  84. return true
  85. end
  86. ]]></globalevent>
  87. <talkaction words="!start" event="script"><![CDATA[
  88. domodlib('re')
  89. function onSay(cid, words, param, channel)
  90. if getPlayerGroupId(cid) > 3 then
  91. setGlobalStorageValue(t.g, 1)
  92. setGlobalStorageValue(t.u, 0)
  93. setGlobalStorageValue(t.l, 0)
  94. setGlobalStorageValue(t.a, 1)
  95. setGlobalStorageValue(t.c, 0)
  96. setGlobalStorageValue(t.wv, 0)
  97. doBroadcastMessage("Attention! Immediately register to Rush Event, event will start for ".. t.t .." minutes. All players can join to event typing this command: !rush", MESSAGE_STATUS_WARNING)
  98. addEvent(function()
  99. doBroadcastMessage("Rush event, started in 2 minutes. If you want to join, type this command: !rush", MESSAGE_STATUS_WARNING)
  100. end, (t.t - 2) * 1000 * 60)
  101. addEvent(function()
  102. doBroadcastMessage("Rush event, started in a minute. If you want to join, type this command: !rush", MESSAGE_STATUS_WARNING)
  103. end, (t.t - 1) * 1000 * 60)
  104. addEvent(start, t.t * 1000 * 60)
  105. return true
  106. end
  107. return true
  108. end
  109. function results()
  110. if(getGlobalStorageValue(t.a) == 1) then
  111. local red = getGlobalStorageValue(t.l)
  112. local blue = getGlobalStorageValue(t.u)
  113. doBroadcastMessage("Rush Events, results:\nRed Team scored: ".. red .." frags.\nBlue Team scored: ".. blue .." frags.\nMatch is under way to ".. t.v .." frags.", MESSAGE_STATUS_WARNING)
  114. addEvent(results, t.r * 1000 * 60)
  115. end
  116. end
  117. function start()
  118. if(getGlobalStorageValue(t.a) == 1 and getGlobalStorageValue(t.c) >= t.mn) then
  119. doBroadcastMessage(t.q, MESSAGE_STATUS_WARNING)
  120. setGlobalStorageValue(t.wv, 1)
  121. addEvent(results, t.r * 1000 * 60)
  122. for _, pid in ipairs(getPlayersOnline()) do
  123. local myOutfit = getCreatureOutfit(pid)
  124. local red = {lookType = myOutfit.lookType, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94, lookTypeEx = 0, lookAddons = myOutfit.lookAddons}
  125. local blue = {lookType = myOutfit.lookType, lookHead = 86, lookBody = 86, lookLegs = 86, lookFeet = 86, lookTypeEx = 0, lookAddons = myOutfit.lookAddons}
  126. if getPlayerStorageValue(pid, t.f) == 1 then
  127. doCreatureAddHealth(pid, getCreatureMaxHealth(pid))
  128. doCreatureAddMana(pid, getCreatureMaxMana(pid))
  129. if((getPlayerStorageValue(pid, t.g) % 2) == 1) then
  130. doCreatureChangeOutfit(pid, red)
  131. setPlayerStorageValue(pid, t.h, 0)
  132. doTeleportThing(pid, t.d_1)
  133. setPlayerStorageValue(pid, t.f, 1)
  134. setPlayerStorageValue(pid, t.f_1, 0)
  135. setPlayerStorageValue(pid, t.f_2, 1)
  136. doSendMagicEffect(getCreaturePosition(pid), 10)
  137. doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You are in RED TEAM!\nThis battle will continue up to ".. t.v .." frags!")
  138. else
  139. doCreatureChangeOutfit(pid, blue)
  140. doTeleportThing(pid, t.d_2)
  141. setPlayerStorageValue(pid, t.h, 0)
  142. setPlayerStorageValue(pid, t.f, 1)
  143. setPlayerStorageValue(pid, t.f_1, 1)
  144. setPlayerStorageValue(pid, t.f_2, 0)
  145. doSendMagicEffect(getCreaturePosition(pid), 10)
  146. doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You are in BLUE TEAM!\nThis battle will continue up to ".. t.v .." frags!")
  147. end
  148. end
  149. end
  150. elseif(getGlobalStorageValue(t.c) < t.mn) then
  151. doBroadcastMessage(t.x, MESSAGE_STATUS_WARNING)
  152. setGlobalStorageValue(t.a, 0)
  153. for _, pid in ipairs(getPlayersOnline()) do
  154. if getPlayerStorageValue(pid, t.f) == 1 then
  155. setPlayerStorageValue(pid, t.f, -1)
  156. doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)))
  157. doSendMagicEffect(getCreaturePosition(pid), CONST_ME_TELEPORT)
  158. end
  159. end
  160. end
  161. end
  162. ]]></talkaction>
  163. <globalevent name="RushStart" time="17:34" event="script"><![CDATA[
  164. domodlib('re')
  165. function onTime(interval, lastExecution)
  166. setGlobalStorageValue(t.g, 1)
  167. setGlobalStorageValue(t.u, 0)
  168. setGlobalStorageValue(t.l, 0)
  169. setGlobalStorageValue(t.a, 1)
  170. setGlobalStorageValue(t.c, 0)
  171. setGlobalStorageValue(t.wv, 0)
  172. doBroadcastMessage("Attention! Immediately register to Rush Event, event will start for ".. t.t .." minutes. All players can join to event typing this command: !rush", MESSAGE_STATUS_WARNING)
  173. addEvent(start, t.t * 1000 * 60)
  174. end
  175. function results()
  176. if(getGlobalStorageValue(t.a) == 1) then
  177. local red = getGlobalStorageValue(t.l)
  178. local blue = getGlobalStorageValue(t.u)
  179. doBroadcastMessage("Rush Events, results:\nRed Team scored: ".. red .." frags.\nBlue Team scored: ".. blue .." frags.\nMatch is under way to ".. t.v .." frags.", MESSAGE_STATUS_WARNING)
  180. addEvent(results, t.r * 1000 * 60)
  181. end
  182. end
  183. function start()
  184. if(getGlobalStorageValue(t.a) == 1 and getGlobalStorageValue(t.c) >= t.mn) then
  185. doBroadcastMessage(t.q, MESSAGE_STATUS_WARNING)
  186. setGlobalStorageValue(t.wv, 1)
  187. addEvent(results, t.r * 1000 * 60)
  188. for _, pid in ipairs(getPlayersOnline()) do
  189. local myOutfit = getCreatureOutfit(pid)
  190. local red = {lookType = myOutfit.lookType, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94, lookTypeEx = 0, lookAddons = myOutfit.lookAddons}
  191. local blue = {lookType = myOutfit.lookType, lookHead = 86, lookBody = 86, lookLegs = 86, lookFeet = 86, lookTypeEx = 0, lookAddons = myOutfit.lookAddons}
  192. if getPlayerStorageValue(pid, t.f) == 1 then
  193. doCreatureAddHealth(pid, getCreatureMaxHealth(pid))
  194. doCreatureAddMana(pid, getCreatureMaxMana(pid))
  195. if((getPlayerStorageValue(pid, t.g) % 2) == 1) then
  196. doCreatureChangeOutfit(pid, red)
  197. setPlayerStorageValue(pid, t.h, 0)
  198. doTeleportThing(pid, t.d_1)
  199. setPlayerStorageValue(pid, t.f, 1)
  200. setPlayerStorageValue(pid, t.f_1, 0)
  201. setPlayerStorageValue(pid, t.f_2, 1)
  202. doSendMagicEffect(getCreaturePosition(pid), 10)
  203. doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You are in RED TEAM!\nThis battle will continue up to ".. t.v .." frags!")
  204. else
  205. doCreatureChangeOutfit(pid, blue)
  206. setPlayerStorageValue(pid, t.h, 0)
  207. doTeleportThing(pid, t.d_2)
  208. setPlayerStorageValue(pid, t.f, 1)
  209. setPlayerStorageValue(pid, t.f_1, 1)
  210. setPlayerStorageValue(pid, t.f_2, 0)
  211. doSendMagicEffect(getCreaturePosition(pid), 10)
  212. doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You are in BLUE TEAM!\nThis battle will continue up to ".. t.v .." frags!")
  213. end
  214. end
  215. end
  216. elseif(getGlobalStorageValue(t.c) < t.mn) then
  217. doBroadcastMessage(t.x, MESSAGE_STATUS_WARNING)
  218. setGlobalStorageValue(t.a, 0)
  219. for _, pid in ipairs(getPlayersOnline()) do
  220. if getPlayerStorageValue(pid, t.f) == 1 then
  221. setPlayerStorageValue(pid, t.f, -1)
  222. doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)))
  223. doSendMagicEffect(getCreaturePosition(pid), CONST_ME_TELEPORT)
  224. end
  225. end
  226. end
  227. end
  228. ]]></globalevent>
  229. <talkaction words="!rush" event="script"><![CDATA[
  230. domodlib('re')
  231. function onSay(cid, words, param, channel)
  232. if getGlobalStorageValue(t.a) == 1 and getGlobalStorageValue(t.wv) ~= 1 then
  233. if getPlayerLevel(cid) >= t.lvl then
  234. if getPlayerStorageValue(cid, t.f) == -1 then
  235. if getTilePzInfo(getPlayerPosition(cid)) == true then
  236. if getGlobalStorageValue(t.c) < t.m then
  237. setGlobalStorageValue(t.c, getGlobalStorageValue(t.c)+1)
  238. if getGlobalStorageValue(t.c) == t.m then
  239. doPlayerSendCancel(cid, "Event is full [" .. getGlobalStorageValue(t.c) .. " players]!")
  240. else
  241. doBroadcastMessage("" .. getPlayerName(cid) .. " has joined to Rush Event! Actually we have: " .. getGlobalStorageValue(t.c) .. " players!", 19)
  242. end
  243. setPlayerStorageValue(cid, t.f, 1)
  244. setPlayerStorageValue(cid, t.h, -1)
  245. doTeleportThing(cid, t.w)
  246. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
  247. setPlayerStorageValue(cid, t.g, getGlobalStorageValue(t.g))
  248. setGlobalStorageValue(t.g, tonumber(getGlobalStorageValue(t.g))+1)
  249. else
  250. doPlayerSendCancel(cid, "Event is full [" .. getGlobalStorageValue(t.c) .. " players]!")
  251. return true
  252. end
  253. else
  254. doPlayerSendCancel(cid, "You must be in protection zone.")
  255. return true
  256. end
  257. else
  258. doPlayerSendCancel(cid, "You are already registered in this event.")
  259. return true
  260. end
  261. else
  262. doPlayerSendCancel(cid, "Your level is too low to participate in this event.")
  263. return true
  264. end
  265. else
  266. doPlayerSendCancel(cid, "At the moment there are no records for this event.")
  267. return true
  268. end
  269. return true
  270. end
  271. ]]></talkaction>
  272. <event type="combat" name="RushCombat" event="script"><![CDATA[
  273. domodlib('re')
  274. function onCombat(cid, target)
  275. if(getGlobalStorageValue(t.a) == 1) then
  276. if isPlayer(cid) and isPlayer(target) then
  277. if getPlayerStorageValue(cid, t.f) == 1 and getPlayerStorageValue(target, t.f) == 1 then
  278. if getPlayerStorageValue(cid, t.f_1) == getPlayerStorageValue(target, t.f_1) then
  279. return doPlayerSendCancel(cid, "Sorry, you cannot attack your own team.") and false
  280. end
  281. end
  282. end
  283. end
  284. return true
  285. end
  286. ]]></event>
  287. <event type="attack" name="RushAttack" event="script"><![CDATA[
  288. domodlib('re')
  289. function onAttack(cid, target)
  290. if(getGlobalStorageValue(t.a) == 1) then
  291. if isPlayer(cid) and isPlayer(target) then
  292. if getPlayerStorageValue(cid, t.f) == 1 and getPlayerStorageValue(target, t.f) == 1 then
  293. if getPlayerStorageValue(cid, t.f_1) == getPlayerStorageValue(target, t.f_1) then
  294. return doPlayerSendCancel(cid, "Sorry, you cannot attack your own team.") and false
  295. end
  296. end
  297. end
  298. end
  299. return true
  300. end
  301. ]]></event>
  302. <event type="preparedeath" name="RushDead" event="script"><![CDATA[
  303. domodlib('re')
  304. function onPrepareDeath(cid, deathList)
  305. if(not isPlayer(cid)) then
  306. return true
  307. end
  308. if getGlobalStorageValue(t.a) == 1 then
  309. local strings = {""}
  310. local j, position, corpse = 1, 1, 0
  311. for _, pid in ipairs(deathList) do
  312. if isCreature(pid) == true then
  313. strings[position] = j == 1 and "" or strings[position] .. ", "
  314. strings[position] = strings[position] .. getCreatureName(pid) .. ""
  315. j = j + 1
  316. else
  317. strings[position] = j == 1 and "" or strings[position] .. ", "
  318. strings[position] = strings[position] .."a field item"
  319. j = j + 1
  320. end
  321. end
  322. for i, str in ipairs(strings) do
  323. if(str:sub(str:len()) ~= ",") then
  324. str = str .. "."
  325. end
  326. desc = "You recognize "
  327. desc = desc .. "" .. getCreatureName(cid) .. ". He was killed by " .. str
  328. end
  329. if(getPlayerSex(cid) == 1) then
  330. corpse = doCreateItem(3058, getCreaturePosition(cid))
  331. else
  332. corpse = doCreateItem(3065, getCreaturePosition(cid))
  333. end
  334. doItemSetAttribute(corpse, "description", desc)
  335. if((getPlayerStorageValue(cid, t.g) % 2) == 1) then
  336. setGlobalStorageValue(t.u, getGlobalStorageValue(t.u)+1)
  337. else
  338. setGlobalStorageValue(t.l, getGlobalStorageValue(t.l)+1)
  339. end
  340. local red = getGlobalStorageValue(t.l)
  341. local blue = getGlobalStorageValue(t.u)
  342. if blue < t.v or red < t.v then
  343. if(isPlayer(cid) == false) then
  344. return true
  345. end
  346. if((getPlayerStorageValue(cid, t.g) % 2) == 1) then
  347. doTeleportThing(cid, t.d_1)
  348. doSendMagicEffect(getCreaturePosition(cid), 10)
  349. doCreatureAddHealth(cid, getCreatureMaxHealth(cid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true)
  350. doCreatureAddMana(cid, getCreatureMaxMana(cid))
  351. doPlayerRemoveLethalConditions(cid)
  352. if getCreatureSkullType(cid) == SKULL_WHITE then
  353. doCreatureSetSkullType(cid, 0)
  354. end
  355. else
  356. doTeleportThing(cid, t.d_2)
  357. doSendMagicEffect(getCreaturePosition(cid), 10)
  358. doCreatureAddHealth(cid, getCreatureMaxHealth(cid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true)
  359. doCreatureAddMana(cid, getCreatureMaxMana(cid))
  360. doPlayerRemoveLethalConditions(cid)
  361. if getCreatureSkullType(cid) == SKULL_WHITE then
  362. doCreatureSetSkullType(cid, 0)
  363. end
  364. end
  365. end
  366. if blue >= t.v then
  367. doBroadcastMessage(t.y, MESSAGE_STATUS_WARNING)
  368. setGlobalStorageValue(t.h, 1)
  369. for _, pid in ipairs(getPlayersOnline()) do
  370. if(getPlayerStorageValue(pid, t.f_1) == 1) then
  371. db.executeQuery('UPDATE accounts SET premium_points=premium_points+100 WHERE id=' .. getPlayerAccountId(cid))
  372. end
  373. end
  374. elseif red >= t.v then
  375. doBroadcastMessage(t.o, MESSAGE_STATUS_WARNING)
  376. setGlobalStorageValue(t.h, 1)
  377. for _, pid in ipairs(getPlayersOnline()) do
  378. if(getPlayerStorageValue(pid, t.f_2) == 1) then
  379. db.executeQuery('UPDATE accounts SET premium_points=premium_points+100 WHERE id=' .. getPlayerAccountId(cid))
  380. end
  381. end
  382. end
  383. if getGlobalStorageValue(t.h) == 1 then
  384. setGlobalStorageValue(t.a, 0)
  385. setGlobalStorageValue(t.h, 0)
  386. setGlobalStorageValue(t.wv, -1)
  387. setPlayerStorageValue(cid, t.f, -1)
  388. setPlayerStorageValue(cid, t.g, 0)
  389. setPlayerStorageValue(cid, t.l, 0)
  390. setPlayerStorageValue(cid, t.u, 0)
  391. setPlayerStorageValue(cid, t.f_1, -1)
  392. setPlayerStorageValue(cid, t.f_2, -1)
  393. setPlayerStorageValue(cid, t.h, -1)
  394. doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
  395. doSendMagicEffect(getCreaturePosition(cid), 10)
  396. doCreatureAddHealth(cid, getCreatureMaxHealth(cid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true)
  397. doCreatureAddMana(cid, getCreatureMaxMana(cid))
  398. doPlayerRemoveLethalConditions(cid)
  399. for _, pid in ipairs(getPlayersOnline()) do
  400. if(getPlayerStorageValue(pid, t.f_1) == 1 or getPlayerStorageValue(pid, t.f_2) == 1) then
  401. setPlayerStorageValue(pid, t.f, -1)
  402. doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)))
  403. doSendMagicEffect(getCreaturePosition(pid), CONST_ME_TELEPORT)
  404. setPlayerStorageValue(pid, t.g, 0)
  405. setPlayerStorageValue(pid, t.l, 0)
  406. setPlayerStorageValue(pid, t.u, 0)
  407. setPlayerStorageValue(pid, t.f_1, -1)
  408. setPlayerStorageValue(pid, t.f_2, -1)
  409. setPlayerStorageValue(pid, t.h, -1)
  410. doCreatureAddHealth(pid, getCreatureMaxHealth(pid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true)
  411. doCreatureAddMana(pid, getCreatureMaxMana(pid))
  412. doPlayerRemoveLethalConditions(pid)
  413. end
  414. end
  415. return false
  416. end
  417. return false
  418. end
  419. return true
  420. end
  421. ]]></event>
  422. <event type="outfit" name="RushOutfit" event="script"><![CDATA[
  423. domodlib('re')
  424. function onOutfit(cid, old, current)
  425. if(getGlobalStorageValue(t.a) == 1) then
  426. if getPlayerGroupId(cid) > 3 then
  427. return true
  428. end
  429. if getPlayerStorageValue(cid, t.h) == 0 then
  430. if getPlayerStorageValue(cid, t.f) > -1 then
  431. doPlayerSendCancel(cid, "You cannot change your outfit during the event.")
  432. return false
  433. end
  434. end
  435. end
  436. return true
  437. end
  438. ]]></event>
  439. </mod>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement