Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.61 KB | None | 0 0
  1. onCreate
  2. {
  3. hairitemid = 8252
  4. hairhue = 1135
  5. hue = 33778
  6. blessed = true
  7. cantwalk = true
  8. name = "Ericka the Gold Raffle Ticket Vendor"
  9. bodyvalue = 401
  10. xmlints.price = 1000
  11. xmlints.totalSold = 0
  12. xmlstrings.currentPrize = "The Marble Island Castle"
  13. xmlstrings.endingTime = "Wednesday, 10:00pm EST"
  14. xmlstrings.moderator = "Alan"
  15. xmlints.active = 0
  16. SCRIPT().name = "Gold Raffle Vendor"
  17. SUBSCRIBETIMER(OneMinute)
  18. }
  19.  
  20. function finishRaffle()
  21. {
  22. xmlints.active = 0
  23. objs.now = NOW()
  24. LOG("LOG_RaffleGold.txt", "====== Raffle ending " + STRING(objs.now) + " ======")
  25. objs.raffleTicketAttachments = GLOBALGETATTACHMENTS("xmlvalue", "goldraffletickets", true)
  26. ints.totalNumTickets = GETATTACHMENTINTSUM("goldraffletickets", true)
  27. LOG("LOG_RaffleGold.txt", "==> total number of tickets: " + ints.totalNumTickets)
  28. if (ints.totalNumTickets == 0)
  29. {
  30. BCAST("The raffle has ended but no tickets were sold so there was no winner this time!", 38)
  31. return
  32. }
  33. BCAST("The raffle has ended!", 38)
  34. ints.winningDraw = RANDOM(ints.totalNumTickets)
  35. LOG("LOG_RaffleGold.txt", "==> winning draw: " + ints.winningDraw)
  36.  
  37. foreach (objs.raffleTicketAttachment ; objs.raffleTicketAttachments)
  38. {
  39. LOG("LOG_RaffleGold.txt", objs.raffleTicketAttachment.AttachedTo + " " + objs.raffleTicketAttachment.Value)
  40. if (xmlstrings.winner == null)
  41. {
  42. ints.winningDraw -= objs.raffleTicketAttachment.value
  43. if (ints.winningDraw < 0)
  44. {
  45. xmlstrings.winner = objs.raffleTicketAttachment.AttachedTo.name
  46. BCAST("Congratulations to " + xmlstrings.winner + " for winning " + xmlstrings.currentPrize + "! Thanks to all others who participated - better luck next time!", 38)
  47. objs.award = redbook
  48. {
  49. hue = 1161
  50. name = "Deed the Marble Island Castle"
  51. title = "Deed the Marble Island Castle"
  52. author = "Carl"
  53. writable = false
  54. loottype = blessed
  55. }
  56. LOG("LOG_RaffleGold.txt", objs.raffleTicketAttachment.AttachedTo + " IS THE WINNER OF THE " + objs.award + " " + xmlstrings.currentPrize)
  57. ADDTOPACK(objs.raffleTicketAttachment.AttachedTo, objs.award)
  58. }
  59. }
  60. }
  61. if (xmlstrings.winner != null)
  62. {
  63. xmlstrings.winner.dodelete = true
  64. }
  65. GLOBALDELATTACHMENTS("xmlvalue", "goldraffletickets", true)
  66. xmlints.totalSold = 0
  67. }
  68.  
  69. onOneMinute
  70. {
  71. if (xmlints.active == 0)
  72. {
  73. SAY(THIS(), "Our next 5 day raffle will be coming soon!")
  74. return
  75. }
  76.  
  77. objs.now = NOW()
  78. if (GETDAYOFWEEK(objs.now) == Wednesday && GETHOUR(objs.now) == 22)
  79. {
  80. finishRaffle()
  81. }
  82. else
  83. {
  84. SAY(THIS(), "Buy raffle tickets here for a chance at " + xmlstrings.currentPrize + "! Say \"info\" for directions! Raffle ends " + xmlstrings.endingTime + "!")
  85. }
  86.  
  87. }
  88. onSpeech
  89. {
  90. if (DISTANCE(THIS(),TRIGMOB()) < 5)
  91. {
  92. if (xmlints.active == 0)
  93. {
  94. if (SAID("info") || SAID("buy raffle ticket") || SAID("buy 5 raffle tickets") || SAID("buy 10 raffle tickets"))
  95. {
  96. SENDMSG(TRIGMOB(), "There is currently no Gold raffle running - check back another time!", 0x38)
  97. }
  98. return
  99. }
  100.  
  101.  
  102. if (SAID("info"))
  103. {
  104. SENDMSG(TRIGMOB(), "The current prize is: " + xmlstrings.currentPrize + " ... buying ends at " + xmlstrings.endingTime + " ... Tickets cost " + xmlints.price + " gold EACH and to buy tickets, say 'buy raffle ticket', 'buy 5 raffle tickets', or 'buy 10 raffle tickets'.", 0x38)
  105. if (STRING(TRIGMOB().accesslevel) != Player && STRING(TRIGMOB().accesslevel) != Counselor)
  106. {
  107. SENDMSG(TRIGMOB(), "Staff Message: So far " + xmlints.totalSold + " tickets have been sold in total during this raffle!", 38)
  108. }
  109. }
  110. elif (SAID("buy raffle ticket"))
  111. {
  112. if (TAKEGOLDFROM(TRIGMOB(),xmlints.price))
  113. {
  114. if (TRIGMOB().xmlints.goldraffletickets == null) { TRIGMOB().xmlints.goldraffletickets = 1; xmlints.totalSold += 1 }
  115. else { TRIGMOB().xmlints.goldraffletickets += 1; xmlints.totalSold += 1 }
  116. LOCALMSG(TRIGMOB(), "You spent " + xmlints.price + " gold and now have " + TRIGMOB().xmlints.goldraffletickets + " raffle tickets!")
  117. }
  118. else
  119. {
  120. SAY(THIS(), "I'm sorry, " + TRIGMOB().name + ", but you can't afford that!")
  121. }
  122. }
  123. elif (SAID("buy 5 raffle tickets"))
  124. {
  125. if (TAKEGOLDFROM(TRIGMOB(),xmlints.price * 5))
  126. {
  127. if (TRIGMOB().xmlints.goldraffletickets == null) { TRIGMOB().xmlints.goldraffletickets = 5; xmlints.totalSold += 5 }
  128. else { TRIGMOB().xmlints.goldraffletickets += 5; xmlints.totalSold += 5 }
  129. LOCALMSG(TRIGMOB(), "You spent " + (xmlints.price * 5) + " gold and now have " + TRIGMOB().xmlints.goldraffletickets + " raffle tickets!")
  130. }
  131. else
  132. {
  133. SAY(THIS(), "I'm sorry, " + TRIGMOB().name + ", but you can't afford that!")
  134. }
  135. }
  136. elif (SAID("buy 10 raffle tickets"))
  137. {
  138. if (TAKEGOLDFROM(TRIGMOB(),xmlints.price * 10))
  139. {
  140. if (TRIGMOB().xmlints.goldraffletickets == null) { TRIGMOB().xmlints.goldraffletickets = 10; xmlints.totalSold += 10 }
  141. else { TRIGMOB().xmlints.goldraffletickets += 10; xmlints.totalSold += 10 }
  142. LOCALMSG(TRIGMOB(), "You spent " + (xmlints.price * 10) + " gold and now have " + TRIGMOB().xmlints.goldraffletickets + " raffle tickets!")
  143. }
  144. else
  145. {
  146. SAY(THIS(), "I'm sorry, " + TRIGMOB().name + ", but you can't afford that!")
  147. }
  148. }
  149. elif (STRING(TRIGMOB().accesslevel) != Player && STRING(TRIGMOB().accesslevel) != Counselor && TRIGMOB().name == xmlstrings.moderator)
  150. {
  151. if (SAID("finish raffle"))
  152. {
  153. finishRaffle()
  154. }
  155. }
  156. }
  157. }
  158. onUse
  159. {
  160. if (xmlints.active == 0)
  161. {
  162. SENDMSG(TRIGMOB(), "There is currently no Gold raffle running - check back another time!", 0x38)
  163. return override
  164. }
  165.  
  166. if (TRIGMOB().xmlints.goldraffletickets == null)
  167. {
  168. LOCALMSG(TRIGMOB(), "You don't have any raffle tickets. Say 'info' for directions on buying some!")
  169. }
  170. else
  171. {
  172. LOCALMSG(TRIGMOB(), "You have " + TRIGMOB().xmlints.goldraffletickets + " raffle tickets! Say 'info' for directions on buying more!")
  173. }
  174. if (STRING(TRIGMOB().accesslevel) != Player && STRING(TRIGMOB().accesslevel) != Counselor)
  175. {
  176. SENDMSG(TRIGMOB(), "Staff Message: So far " + xmlints.totalSold + " tickets have been sold in total during this raffle!", 38)
  177. }
  178. return override
  179. }
  180.  
  181. onCreate
  182. {
  183. hairitemid = 8252
  184. hairhue = 1135
  185. hue = 33778
  186. blessed = true
  187. cantwalk = true
  188. name = "Ericka the Gold Raffle Ticket Vendor"
  189. bodyvalue = 401
  190. xmlints.price = 1000
  191. xmlints.totalSold = 0
  192. xmlstrings.moderator = "Alan"
  193. xmlints.active = 0
  194.  
  195. SCRIPT().name = "Gold Raffle Vendor"
  196. SUBSCRIBETIMER(OneMinute)
  197. }
  198.  
  199. function finishRaffle()
  200. {
  201. xmlints.active = 0
  202. objs.now = NOW()
  203. LOG("LOG_RaffleGold.txt", "====== Raffle ending " + STRING(objs.now) + " ======")
  204. objs.raffleTicketAttachments = GLOBALGETATTACHMENTS("xmlvalue", "goldraffletickets", true)
  205. ints.totalNumTickets = GETATTACHMENTINTSUM("goldraffletickets", true)
  206. LOG("LOG_RaffleGold.txt", "==> total number of tickets: " + ints.totalNumTickets)
  207. if (ints.totalNumTickets == 0)
  208. {
  209. BCAST("The raffle has ended but no tickets were sold so there was no winner this time!", 38)
  210. return
  211. }
  212. BCAST("The raffle has ended!", 38)
  213. ints.winningDraw = RANDOM(ints.totalNumTickets)
  214. LOG("LOG_RaffleGold.txt", "==> winning draw: " + ints.winningDraw)
  215.  
  216. foreach (objs.raffleTicketAttachment ; objs.raffleTicketAttachments)
  217. {
  218. LOG("LOG_RaffleGold.txt", objs.raffleTicketAttachment.AttachedTo + " " + objs.raffleTicketAttachment.Value)
  219. if (xmlstrings.winner == null)
  220. {
  221. ints.winningDraw -= objs.raffleTicketAttachment.value
  222. if (ints.winningDraw < 0)
  223. {
  224. xmlstrings.winner = objs.raffleTicketAttachment.AttachedTo.name
  225. BCAST("Congratulations to " + xmlstrings.winner + " for winning " + xmlstrings.currentPrize + "! Thanks to all others who participated - better luck next time!", 38)
  226. if (xmlstrings.bookName != null)
  227. {
  228. objs.award = redbook
  229. {
  230. hue = 1161
  231. name = THIS().xmlstrings.bookName
  232. title = THIS().xmlstrings.bookName
  233. author = "Carl"
  234. writable = false
  235. loottype = blessed
  236. }
  237. }
  238. else
  239. {
  240. objs.award = SPAWN(xmlstrings.itemType)
  241. if (xmlstrings.itemPath != null)
  242. {
  243. ADDSCRIPT(objs.award, xmlstrings.itemPath)
  244. }
  245. }
  246. LOG("LOG_RaffleGold.txt", objs.raffleTicketAttachment.AttachedTo + " IS THE WINNER OF THE " + objs.award + " " + xmlstrings.currentPrize)
  247. ADDTOPACK(objs.raffleTicketAttachment.AttachedTo, objs.award)
  248. }
  249. }
  250. }
  251. if (xmlstrings.winner != null)
  252. {
  253. xmlstrings.winner.dodelete = true
  254. }
  255. GLOBALDELATTACHMENTS("xmlvalue", "goldraffletickets", true)
  256. xmlints.totalSold = 0
  257. }
  258.  
  259. onOneMinute
  260. {
  261. if (xmlints.active == 0)
  262. {
  263. SAY(THIS(), "Our next 5 day raffle will be coming soon!")
  264. return
  265. }
  266.  
  267. objs.now = NOW()
  268. if (STRING(GETDAY(objs.now)) == xmlstrings.endDate && STRING(GETHOUR(objs.now)) == xmlstrings.endHour && STRING(GETDAYOFWEEK(objs.now)) == xmlstrings.endDayOfWeek) // don't check the month, that's just for announcing purposes
  269. {
  270. finishRaffle()
  271. }
  272. else
  273. {
  274. SAY(THIS(), "Buy raffle tickets here for a chance at " + xmlstrings.announcedItemName + "! Say \"info\" for directions! Raffle ends " + xmlstrings.endDayOfWeek + " " + xmlstrings.endMonth + " " + xmlstrings.endDate + " at " + xmlstrings.endHour + ":00 EST!")
  275. }
  276.  
  277. }
  278. onSpeech
  279. {
  280. if (DISTANCE(THIS(),TRIGMOB()) < 5)
  281. {
  282. if (xmlints.active == 0)
  283. {
  284. if (SAID("info") || SAID("buy raffle ticket") || SAID("buy 5 raffle tickets") || SAID("buy 10 raffle tickets"))
  285. {
  286. SENDMSG(TRIGMOB(), "There is currently no Gold raffle running - check back another time!", 0x38)
  287. }
  288. return
  289. }
  290.  
  291.  
  292. if (SAID("info"))
  293. {
  294. SENDMSG(TRIGMOB(), "The current prize is: " + xmlstrings.currentPrize + " ... buying ends at " + xmlstrings.endDayOfWeek + " " + xmlstrings.endMonth + " " + xmlstrings.endDate + " at " + xmlstrings.endHour + ":00 EST! ... Tickets cost " + xmlints.price + " gold EACH and to buy tickets, say 'buy raffle ticket', 'buy 5 raffle tickets', or 'buy 10 raffle tickets'.", 0x38)
  295. if (STRING(TRIGMOB().accesslevel) != Player && STRING(TRIGMOB().accesslevel) != Counselor)
  296. {
  297. SENDMSG(TRIGMOB(), "Staff Message: So far " + xmlints.totalSold + " tickets have been sold in total during this raffle!", 38)
  298. }
  299. }
  300. elif (SAID("buy raffle ticket"))
  301. {
  302. if (TAKEGOLDFROM(TRIGMOB(),xmlints.price))
  303. {
  304. if (TRIGMOB().xmlints.goldraffletickets == null) { TRIGMOB().xmlints.goldraffletickets = 1; xmlints.totalSold += 1 }
  305. else { TRIGMOB().xmlints.goldraffletickets += 1; xmlints.totalSold += 1 }
  306. LOCALMSG(TRIGMOB(), "You spent " + xmlints.price + " gold and now have " + TRIGMOB().xmlints.goldraffletickets + " raffle tickets!")
  307. }
  308. else
  309. {
  310. SAY(THIS(), "I'm sorry, " + TRIGMOB().name + ", but you can't afford that!")
  311. }
  312. }
  313. elif (SAID("buy 5 raffle tickets"))
  314. {
  315. if (TAKEGOLDFROM(TRIGMOB(),xmlints.price * 5))
  316. {
  317. if (TRIGMOB().xmlints.goldraffletickets == null) { TRIGMOB().xmlints.goldraffletickets = 5; xmlints.totalSold += 5 }
  318. else { TRIGMOB().xmlints.goldraffletickets += 5; xmlints.totalSold += 5 }
  319. LOCALMSG(TRIGMOB(), "You spent " + (xmlints.price * 5) + " gold and now have " + TRIGMOB().xmlints.goldraffletickets + " raffle tickets!")
  320. }
  321. else
  322. {
  323. SAY(THIS(), "I'm sorry, " + TRIGMOB().name + ", but you can't afford that!")
  324. }
  325. }
  326. elif (SAID("buy 10 raffle tickets"))
  327. {
  328. if (TAKEGOLDFROM(TRIGMOB(),xmlints.price * 10))
  329. {
  330. if (TRIGMOB().xmlints.goldraffletickets == null) { TRIGMOB().xmlints.goldraffletickets = 10; xmlints.totalSold += 10 }
  331. else { TRIGMOB().xmlints.goldraffletickets += 10; xmlints.totalSold += 10 }
  332. LOCALMSG(TRIGMOB(), "You spent " + (xmlints.price * 10) + " gold and now have " + TRIGMOB().xmlints.goldraffletickets + " raffle tickets!")
  333. }
  334. else
  335. {
  336. SAY(THIS(), "I'm sorry, " + TRIGMOB().name + ", but you can't afford that!")
  337. }
  338. }
  339. elif (STRING(TRIGMOB().accesslevel) != Player && STRING(TRIGMOB().accesslevel) != Counselor && TRIGMOB().name == xmlstrings.moderator)
  340. {
  341. if (SAID("finish raffle"))
  342. {
  343. finishRaffle()
  344. }
  345. }
  346. }
  347. }
  348. onUse
  349. {
  350. if (xmlints.active == 0)
  351. {
  352. SENDMSG(TRIGMOB(), "There is currently no Gold raffle running - check back another time!", 0x38)
  353. if (STRING(TRIGMOB().accesslevel) != Player && STRING(TRIGMOB().accesslevel) != Counselor)
  354. {
  355. SENDGUMP(TRIGMOB(), "alan\\raffle\\rafflecontrol.xml")
  356. }
  357. return override
  358. }
  359.  
  360. if (TRIGMOB().xmlints.raffletickets == null)
  361. {
  362. LOCALMSG(TRIGMOB(), "You don't have any raffle tickets. Say 'info' for directions on buying some!")
  363. }
  364. else
  365. {
  366. LOCALMSG(TRIGMOB(), "You have " + TRIGMOB().xmlints.raffletickets + " raffle tickets! Say 'info' for directions on buying more!")
  367. }
  368. if (STRING(TRIGMOB().accesslevel) != Player && STRING(TRIGMOB().accesslevel) != Counselor)
  369. {
  370. SENDMSG(TRIGMOB(), "Staff Message: So far " + xmlints.totalSold + " tickets have been sold in total during this raffle!", 38)
  371. SENDGUMP(TRIGMOB(), "alan\\raffle\\rafflecontrol.xml")
  372. }
  373. return override
  374. }
  375. onGumpResponse
  376. {
  377. if (strings.buttonPressed == "submit")
  378. {
  379. if (strings.bookName == EMPTYSTRING())
  380. {
  381. if (strings.itemType == EMPTYSTRING() && strings.itemPath == EMPTYSTRING())
  382. {
  383. LOCALMSG(TRIGMOB(), "You have to either enter a book name, an itemtype, or an itemPath (you can do itemtype and itemPath together)", 38)
  384. return
  385. }
  386. else
  387. {
  388. xmlstrings.bookName = null
  389. if (strings.itemType == EMPTYSTRING()) { xmlstrings.itemType = "UberScriptItem" }
  390. else { xmlstrings.itemType = TRIM(strings.itemType) }
  391. if (strings.itemPath == EMPTYSTRING()) { xmlstrings.itemPath = null }
  392. else { xmlstrings.itemPath = TRIM(strings.itemPath) }
  393.  
  394. }
  395. }
  396. else
  397. {
  398. xmlstrings.bookName = TRIM(strings.bookName)
  399. xmlstrings.itemType = null
  400. xmlstrings.itemPath = null
  401. }
  402.  
  403. // if (strings.endHour == null) { SENDMSG(TRIGMOB(), "null endhour") }
  404. xmlstrings.endMonth = TRIM(strings.endMonth)
  405. xmlstrings.endDate = TRIM(strings.endDate)
  406. xmlstrings.endDayOfWeek = TRIM(strings.endDayOfWeek)
  407. xmlstrings.endHour = TRIM(strings.endHour)
  408. xmlstrings.announcedItemName = TRIM(strings.announcedItemName)
  409.  
  410. xmlints.active = 1
  411.  
  412. // give a copy to the staff member who made it
  413. if (xmlstrings.bookName != null)
  414. {
  415. objs.award = redbook
  416. {
  417. hue = 1161
  418. name = THIS().xmlstrings.bookName
  419. title = THIS().xmlstrings.bookName
  420. author = "Carl"
  421. writable = false
  422. loottype = blessed
  423. }
  424. }
  425. else
  426. {
  427. objs.award = SPAWN(xmlstrings.itemType)
  428. if (xmlstrings.itemPath != null)
  429. {
  430. ADDSCRIPT(objs.award, xmlstrings.itemPath)
  431. }
  432. }
  433. ADDTOPACK(TRIGMOB(), objs.award)
  434. LOCALMSG(TRIGMOB(), "A copy of the award has been placed in your backpack (perhaps for display purposes). BE CAREFUL if it has a script with onUse triggers, as players could possibly use the item while locked down on the pedestal!")
  435. }
  436. else
  437. {
  438. LOCALMSG(TRIGMOB(), "You decide not to change the settings.")
  439. }
  440. }
  441.  
  442. onCreate
  443. {
  444. hairitemid = 8261
  445. hairhue = 1135
  446. hue = 33778
  447. blessed = true
  448. cantwalk = true
  449. name = "Sam the Donation Raffle Ticket Vendor"
  450. bodyvalue = 400
  451. xmlints.price = 200
  452. xmlints.totalSold = 0
  453. xmlstrings.moderator = "Alan"
  454. xmlints.active = 0
  455.  
  456. SCRIPT().name = "Donation Raffle Vendor"
  457. SUBSCRIBETIMER(OneMinute)
  458. }
  459.  
  460. function finishRaffle()
  461. {
  462. xmlints.active = 0
  463. objs.now = NOW()
  464. LOG("LOG_RaffleDonations.txt", "====== Raffle ending " + STRING(objs.now) + " ======")
  465. objs.raffleTicketAttachments = GLOBALGETATTACHMENTS("xmlvalue", "raffletickets", true)
  466. ints.totalNumTickets = GETATTACHMENTINTSUM("raffletickets", true)
  467. LOG("LOG_RaffleDonations.txt", "==> total number of tickets: " + ints.totalNumTickets)
  468. if (ints.totalNumTickets == 0)
  469. {
  470. BCAST("The raffle has ended but no tickets were sold so there was no winner this time!", 38)
  471. return
  472. }
  473. BCAST("The raffle has ended!", 38)
  474. ints.winningDraw = RANDOM(ints.totalNumTickets)
  475. LOG("LOG_RaffleDonations.txt", "==> winning draw: " + ints.winningDraw)
  476.  
  477. foreach (objs.raffleTicketAttachment ; objs.raffleTicketAttachments)
  478. {
  479. LOG("LOG_RaffleDonations.txt", objs.raffleTicketAttachment.AttachedTo + " " + objs.raffleTicketAttachment.Value)
  480. if (xmlstrings.winner == null)
  481. {
  482. ints.winningDraw -= objs.raffleTicketAttachment.value
  483. if (ints.winningDraw < 0)
  484. {
  485. xmlstrings.winner = objs.raffleTicketAttachment.AttachedTo.name
  486. BCAST("Congratulations to " + xmlstrings.winner + " for winning " + xmlstrings.currentPrize + "! Thanks to all others who participated - better luck next time!", 38)
  487.  
  488. if (xmlstrings.bookName != null)
  489. {
  490. objs.award = redbook
  491. {
  492. hue = 1161
  493. name = THIS().xmlstrings.bookName
  494. title = THIS().xmlstrings.bookName
  495. author = "Carl"
  496. writable = false
  497. loottype = blessed
  498. }
  499. }
  500. else
  501. {
  502. objs.award = SPAWN(xmlstrings.itemType)
  503. if (xmlstrings.itemPath != null)
  504. {
  505. ADDSCRIPT(objs.award, xmlstrings.itemPath)
  506. }
  507. }
  508. LOG("LOG_RaffleDonations.txt", objs.raffleTicketAttachment.AttachedTo + " IS THE WINNER OF THE " + objs.award + " " + xmlstrings.currentPrize)
  509. ADDTOPACK(objs.raffleTicketAttachment.AttachedTo, objs.award)
  510. }
  511. }
  512. }
  513. if (xmlstrings.winner != null)
  514. {
  515. xmlstrings.winner.dodelete = true
  516. }
  517. GLOBALDELATTACHMENTS("xmlvalue", "raffletickets", true)
  518. xmlints.totalSold = 0
  519. }
  520.  
  521. onOneMinute
  522. {
  523. if (xmlints.active == 0)
  524. {
  525. SAY(THIS(), "Our next 5 day raffle will be coming soon!")
  526. return
  527. }
  528.  
  529. objs.now = NOW()
  530. if (STRING(GETDAY(objs.now)) == xmlstrings.endDate && STRING(GETHOUR(objs.now)) == xmlstrings.endHour && STRING(GETDAYOFWEEK(objs.now)) == xmlstrings.endDayOfWeek) // don't check the month, that's just for announcing purposes
  531. {
  532. finishRaffle()
  533. }
  534. else
  535. {
  536. SAY(THIS(), "Buy raffle tickets here for a chance at " + xmlstrings.announcedItemName + "! Say \"info\" for directions! Raffle ends " + xmlstrings.endDayOfWeek + " " + xmlstrings.endMonth + " " + xmlstrings.endDate + " at " + xmlstrings.endHour + ":00 EST!")
  537. }
  538.  
  539. }
  540. onSpeech
  541. {
  542. if (DISTANCE(THIS(),TRIGMOB()) < 5)
  543. {
  544. if (xmlints.active == 0)
  545. {
  546. if (SAID("info") || SAID("buy raffle ticket") || SAID("buy 5 raffle tickets") || SAID("buy 10 raffle tickets"))
  547. {
  548. SENDMSG(TRIGMOB(), "There is currently no Donation Coin raffle running - check back another time!", 0x38)
  549. }
  550. return
  551. }
  552.  
  553.  
  554. if (SAID("info"))
  555. {
  556. SENDMSG(TRIGMOB(), "The current prize is: " + xmlstrings.currentPrize + " ... buying ends at " + xmlstrings.endDayOfWeek + " " + xmlstrings.endMonth + " " + xmlstrings.endDate + " at " + xmlstrings.endHour + ":00 EST! ... Tickets cost " + xmlints.price + " Donation Coins EACH and to buy tickets, say 'buy raffle ticket', 'buy 5 raffle tickets', or 'buy 10 raffle tickets'.", 0x38)
  557. if (STRING(TRIGMOB().accesslevel) != Player && STRING(TRIGMOB().accesslevel) != Counselor)
  558. {
  559. SENDMSG(TRIGMOB(), "Staff Message: So far " + xmlints.totalSold + " tickets have been sold in total during this raffle!", 38)
  560. }
  561. }
  562. elif (SAID("buy raffle ticket"))
  563. {
  564. if (GETAMOUNTINCONTAINER(TRIGMOB().bankbox, donationcoin) >= xmlints.price)
  565. {
  566. DELETEFROMCONTAINER(TRIGMOB().bankbox, donationcoin, xmlints.price)
  567. if (TRIGMOB().xmlints.raffletickets == null) { TRIGMOB().xmlints.raffletickets = 1; xmlints.totalSold += 1 }
  568. else { TRIGMOB().xmlints.raffletickets += 1; xmlints.totalSold += 1 }
  569. LOCALMSG(TRIGMOB(), "You spent " + xmlints.price + " Donation Coins and now have " + TRIGMOB().xmlints.raffletickets + " raffle tickets!")
  570. }
  571. else
  572. {
  573. SAY(THIS(), "I'm sorry, " + TRIGMOB().name + ", but you can't afford that!")
  574. }
  575. }
  576. elif (SAID("buy 5 raffle tickets"))
  577. {
  578. if (GETAMOUNTINCONTAINER(TRIGMOB().bankbox, donationcoin) >= xmlints.price * 5)
  579. {
  580. DELETEFROMCONTAINER(TRIGMOB().bankbox, donationcoin, xmlints.price * 5)
  581. if (TRIGMOB().xmlints.raffletickets == null) { TRIGMOB().xmlints.raffletickets = 5; xmlints.totalSold += 5 }
  582. else { TRIGMOB().xmlints.raffletickets += 5; xmlints.totalSold += 5 }
  583. LOCALMSG(TRIGMOB(), "You spent " + (xmlints.price * 5) + " Donation Coins and now have " + TRIGMOB().xmlints.raffletickets + " raffle tickets!")
  584. }
  585. else
  586. {
  587. SAY(THIS(), "I'm sorry, " + TRIGMOB().name + ", but you can't afford that!")
  588. }
  589. }
  590. elif (SAID("buy 10 raffle tickets"))
  591. {
  592. if (GETAMOUNTINCONTAINER(TRIGMOB().bankbox, donationcoin) >= xmlints.price * 10)
  593. {
  594. DELETEFROMCONTAINER(TRIGMOB().bankbox, donationcoin, xmlints.price * 10)
  595. if (TRIGMOB().xmlints.raffletickets == null) { TRIGMOB().xmlints.raffletickets = 10; xmlints.totalSold += 10 }
  596. else { TRIGMOB().xmlints.raffletickets += 10; xmlints.totalSold += 10 }
  597. LOCALMSG(TRIGMOB(), "You spent " + (xmlints.price * 10) + " Donation Coins and now have " + TRIGMOB().xmlints.raffletickets + " raffle tickets!")
  598. }
  599. else
  600. {
  601. SAY(THIS(), "I'm sorry, " + TRIGMOB().name + ", but you can't afford that!")
  602. }
  603. }
  604. elif (STRING(TRIGMOB().accesslevel) != Player && STRING(TRIGMOB().accesslevel) != Counselor && TRIGMOB().name == xmlstrings.moderator)
  605. {
  606. if (SAID("finish raffle"))
  607. {
  608. finishRaffle()
  609. }
  610. }
  611. }
  612. }
  613. onUse
  614. {
  615. if (xmlints.active == 0)
  616. {
  617. SENDMSG(TRIGMOB(), "There is currently no Donation Coin raffle running - check back another time!", 0x38)
  618. if (STRING(TRIGMOB().accesslevel) != Player && STRING(TRIGMOB().accesslevel) != Counselor)
  619. {
  620. SENDGUMP(TRIGMOB(), "alan\\raffle\\rafflecontrol.xml")
  621. }
  622. return override
  623. }
  624.  
  625. if (TRIGMOB().xmlints.raffletickets == null)
  626. {
  627. LOCALMSG(TRIGMOB(), "You don't have any raffle tickets. Say 'info' for directions on buying some!")
  628. }
  629. else
  630. {
  631. LOCALMSG(TRIGMOB(), "You have " + TRIGMOB().xmlints.raffletickets + " raffle tickets! Say 'info' for directions on buying more!")
  632. }
  633. if (STRING(TRIGMOB().accesslevel) != Player && STRING(TRIGMOB().accesslevel) != Counselor)
  634. {
  635. SENDMSG(TRIGMOB(), "Staff Message: So far " + xmlints.totalSold + " tickets have been sold in total during this raffle!", 38)
  636. SENDGUMP(TRIGMOB(), "alan\\raffle\\rafflecontrol.xml")
  637. }
  638. return override
  639. }
  640. onGumpResponse
  641. {
  642. if (strings.buttonPressed == "submit")
  643. {
  644. if (strings.bookName == EMPTYSTRING())
  645. {
  646. if (strings.itemType == EMPTYSTRING() && strings.itemPath == EMPTYSTRING())
  647. {
  648. LOCALMSG(TRIGMOB(), "You have to either enter a book name, an itemtype, or an itemPath (you can do itemtype and itemPath together)", 38)
  649. return
  650. }
  651. else
  652. {
  653. xmlstrings.bookName = null
  654. if (strings.itemType == EMPTYSTRING()) { xmlstrings.itemType = "UberScriptItem" }
  655. else { xmlstrings.itemType = TRIM(strings.itemType) }
  656. if (strings.itemPath == EMPTYSTRING()) { xmlstrings.itemPath = null }
  657. else { xmlstrings.itemPath = TRIM(strings.itemPath) }
  658.  
  659. }
  660. }
  661. else
  662. {
  663. xmlstrings.bookName = TRIM(strings.bookName)
  664. xmlstrings.itemType = null
  665. xmlstrings.itemPath = null
  666. }
  667.  
  668. // if (strings.endHour == null) { SENDMSG(TRIGMOB(), "null endhour") }
  669. xmlstrings.endMonth = TRIM(strings.endMonth)
  670. xmlstrings.endDate = TRIM(strings.endDate)
  671. xmlstrings.endDayOfWeek = TRIM(strings.endDayOfWeek)
  672. xmlstrings.endHour = TRIM(strings.endHour)
  673. xmlstrings.announcedItemName = TRIM(strings.announcedItemName)
  674.  
  675. xmlints.active = 1
  676.  
  677. // give a copy to the staff member who made it
  678. if (xmlstrings.bookName != null)
  679. {
  680. objs.award = redbook
  681. {
  682. hue = 1161
  683. name = THIS().xmlstrings.bookName
  684. title = THIS().xmlstrings.bookName
  685. author = "Carl"
  686. writable = false
  687. loottype = blessed
  688. }
  689. }
  690. else
  691. {
  692. objs.award = SPAWN(xmlstrings.itemType)
  693. if (xmlstrings.itemPath != null)
  694. {
  695. ADDSCRIPT(objs.award, xmlstrings.itemPath)
  696. }
  697. }
  698. ADDTOPACK(TRIGMOB(), objs.award)
  699. LOCALMSG(TRIGMOB(), "A copy of the award has been placed in your backpack (perhaps for display purposes). BE CAREFUL if it has a script with onUse triggers, as players could possibly use the item while locked down on the pedestal!")
  700. }
  701. else
  702. {
  703. LOCALMSG(TRIGMOB(), "You decide not to change the settings.")
  704. }
  705. }
  706.  
  707. onCreate
  708. {
  709. hairitemid = 8261
  710. hairhue = 1135
  711. hue = 33778
  712. blessed = true
  713. cantwalk = true
  714. name = "Sam the Donation Raffle Ticket Vendor"
  715. bodyvalue = 400
  716. xmlints.price = 200
  717. xmlints.totalSold = 0
  718. xmlstrings.currentPrize = "Item Bless Deed"
  719. xmlstrings.endingTime = "Wednesday, 10:00pm EST"
  720. xmlstrings.moderator = "Alan"
  721. xmlints.active = 0
  722. SCRIPT().name = "Donation Raffle Vendor"
  723. SUBSCRIBETIMER(OneMinute)
  724. }
  725.  
  726. function finishRaffle()
  727. {
  728. xmlints.active = 0
  729. objs.now = NOW()
  730. LOG("LOG_RaffleDonations.txt", "====== Raffle ending " + STRING(objs.now) + " ======")
  731. objs.raffleTicketAttachments = GLOBALGETATTACHMENTS("xmlvalue", "raffletickets", true)
  732. ints.totalNumTickets = GETATTACHMENTINTSUM("raffletickets", true)
  733. LOG("LOG_RaffleDonations.txt", "==> total number of tickets: " + ints.totalNumTickets)
  734. if (ints.totalNumTickets == 0)
  735. {
  736. BCAST("The raffle has ended but no tickets were sold so there was no winner this time!", 38)
  737. return
  738. }
  739. BCAST("The raffle has ended!", 38)
  740. ints.winningDraw = RANDOM(ints.totalNumTickets)
  741. LOG("LOG_RaffleDonations.txt", "==> winning draw: " + ints.winningDraw)
  742.  
  743. foreach (objs.raffleTicketAttachment ; objs.raffleTicketAttachments)
  744. {
  745. LOG("LOG_RaffleDonations.txt", objs.raffleTicketAttachment.AttachedTo + " " + objs.raffleTicketAttachment.Value)
  746. if (xmlstrings.winner == null)
  747. {
  748. ints.winningDraw -= objs.raffleTicketAttachment.value
  749. if (ints.winningDraw < 0)
  750. {
  751. xmlstrings.winner = objs.raffleTicketAttachment.AttachedTo.name
  752. BCAST("Congratulations to " + xmlstrings.winner + " for winning " + xmlstrings.currentPrize + "! Thanks to all others who participated - better luck next time!", 38)
  753. objs.award = redbook
  754. {
  755. hue = 1161
  756. name = "Item Bless Deed"
  757. title = "Item Bless Deed"
  758. author = "Carl"
  759. writable = false
  760. loottype = blessed
  761. }
  762. LOG("LOG_RaffleDonations.txt", objs.raffleTicketAttachment.AttachedTo + " IS THE WINNER OF THE " + objs.award + " " + xmlstrings.currentPrize)
  763. ADDTOPACK(objs.raffleTicketAttachment.AttachedTo, objs.award)
  764. }
  765. }
  766. }
  767. if (xmlstrings.winner != null)
  768. {
  769. xmlstrings.winner.dodelete = true
  770. }
  771. GLOBALDELATTACHMENTS("xmlvalue", "raffletickets", true)
  772. xmlints.totalSold = 0
  773. }
  774.  
  775. onOneMinute
  776. {
  777. if (xmlints.active == 0)
  778. {
  779. SAY(THIS(), "Our next 5 day raffle will be coming soon!")
  780. return
  781. }
  782.  
  783. objs.now = NOW()
  784. //if (GETDAYOFWEEK(objs.now) == Saturday && GETHOUR(objs.now) == 22)
  785. if (GETDAY(objs.now) == 9 && GETHOUR(objs.now) == 20)
  786. {
  787. finishRaffle()
  788. }
  789. else
  790. {
  791. SAY(THIS(), "Buy raffle tickets here for a chance at " + xmlstrings.currentPrize + "! Say \"info\" for directions! Raffle ends " + xmlstrings.endingTime + "!")
  792. }
  793.  
  794. }
  795. onSpeech
  796. {
  797. if (DISTANCE(THIS(),TRIGMOB()) < 5)
  798. {
  799. if (xmlints.active == 0)
  800. {
  801. if (SAID("info") || SAID("buy raffle ticket") || SAID("buy 5 raffle tickets") || SAID("buy 10 raffle tickets"))
  802. {
  803. SENDMSG(TRIGMOB(), "There is currently no Donation Coin raffle running - check back another time!", 0x38)
  804. }
  805. return
  806. }
  807.  
  808.  
  809. if (SAID("info"))
  810. {
  811. SENDMSG(TRIGMOB(), "The current prize is: " + xmlstrings.currentPrize + " ... buying ends at " + xmlstrings.endingTime + " ... Tickets cost " + xmlints.price + " Donation Coins EACH and to buy tickets, say 'buy raffle ticket', 'buy 5 raffle tickets', or 'buy 10 raffle tickets'.", 0x38)
  812. if (STRING(TRIGMOB().accesslevel) != Player && STRING(TRIGMOB().accesslevel) != Counselor)
  813. {
  814. SENDMSG(TRIGMOB(), "Staff Message: So far " + xmlints.totalSold + " tickets have been sold in total during this raffle!", 38)
  815. }
  816. }
  817. elif (SAID("buy raffle ticket"))
  818. {
  819. if (GETAMOUNTINCONTAINER(TRIGMOB().bankbox, donationcoin) >= xmlints.price)
  820. {
  821. DELETEFROMCONTAINER(TRIGMOB().bankbox, donationcoin, xmlints.price)
  822. if (TRIGMOB().xmlints.raffletickets == null) { TRIGMOB().xmlints.raffletickets = 1; xmlints.totalSold += 1 }
  823. else { TRIGMOB().xmlints.raffletickets += 1; xmlints.totalSold += 1 }
  824. LOCALMSG(TRIGMOB(), "You spent " + xmlints.price + " Donation Coins and now have " + TRIGMOB().xmlints.raffletickets + " raffle tickets!")
  825. }
  826. else
  827. {
  828. SAY(THIS(), "I'm sorry, " + TRIGMOB().name + ", but you can't afford that!")
  829. }
  830. }
  831. elif (SAID("buy 5 raffle tickets"))
  832. {
  833. if (GETAMOUNTINCONTAINER(TRIGMOB().bankbox, donationcoin) >= xmlints.price * 5)
  834. {
  835. DELETEFROMCONTAINER(TRIGMOB().bankbox, donationcoin, xmlints.price * 5)
  836. if (TRIGMOB().xmlints.raffletickets == null) { TRIGMOB().xmlints.raffletickets = 5; xmlints.totalSold += 5 }
  837. else { TRIGMOB().xmlints.raffletickets += 5; xmlints.totalSold += 5 }
  838. LOCALMSG(TRIGMOB(), "You spent " + (xmlints.price * 5) + " Donation Coins and now have " + TRIGMOB().xmlints.raffletickets + " raffle tickets!")
  839. }
  840. else
  841. {
  842. SAY(THIS(), "I'm sorry, " + TRIGMOB().name + ", but you can't afford that!")
  843. }
  844. }
  845. elif (SAID("buy 10 raffle tickets"))
  846. {
  847. if (GETAMOUNTINCONTAINER(TRIGMOB().bankbox, donationcoin) >= xmlints.price * 10)
  848. {
  849. DELETEFROMCONTAINER(TRIGMOB().bankbox, donationcoin, xmlints.price * 10)
  850. if (TRIGMOB().xmlints.raffletickets == null) { TRIGMOB().xmlints.raffletickets = 10; xmlints.totalSold += 10 }
  851. else { TRIGMOB().xmlints.raffletickets += 10; xmlints.totalSold += 10 }
  852. LOCALMSG(TRIGMOB(), "You spent " + (xmlints.price * 10) + " Donation Coins and now have " + TRIGMOB().xmlints.raffletickets + " raffle tickets!")
  853. }
  854. else
  855. {
  856. SAY(THIS(), "I'm sorry, " + TRIGMOB().name + ", but you can't afford that!")
  857. }
  858. }
  859. elif (STRING(TRIGMOB().accesslevel) != Player && STRING(TRIGMOB().accesslevel) != Counselor && TRIGMOB().name == xmlstrings.moderator)
  860. {
  861. if (SAID("finish raffle"))
  862. {
  863. finishRaffle()
  864. }
  865. }
  866. }
  867. }
  868. onUse
  869. {
  870. if (xmlints.active == 0)
  871. {
  872. SENDMSG(TRIGMOB(), "There is currently no Donation Coin raffle running - check back another time!", 0x38)
  873. return override
  874. }
  875.  
  876. if (TRIGMOB().xmlints.raffletickets == null)
  877. {
  878. LOCALMSG(TRIGMOB(), "You don't have any raffle tickets. Say 'info' for directions on buying some!")
  879. }
  880. else
  881. {
  882. LOCALMSG(TRIGMOB(), "You have " + TRIGMOB().xmlints.raffletickets + " raffle tickets! Say 'info' for directions on buying more!")
  883. }
  884. if (STRING(TRIGMOB().accesslevel) != Player && STRING(TRIGMOB().accesslevel) != Counselor)
  885. {
  886. SENDMSG(TRIGMOB(), "Staff Message: So far " + xmlints.totalSold + " tickets have been sold in total during this raffle!", 38)
  887. }
  888. return override
  889. }
  890.  
  891. <Gump>
  892. <VBox padding="10" backgroundID="9250">
  893. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="3500" horizontalGap="0" padding="20">
  894. <Label x="0" y="0" hue="0">"Announced Item Name (not actually applied to the item):"</Label>
  895. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="9300" horizontalGap="0" padding="2">
  896. <TextEntry x="0" y="0" name="announcedItemName" size="230" width="400" height="22" default="" />
  897. </HBox>
  898. </HBox>
  899. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="3500" horizontalGap="0" padding="20">
  900. <Label x="0" y="0" hue="0">"If a blaze book is used, enter the name of the book here:"</Label>
  901. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="9300" horizontalGap="0" padding="2">
  902. <TextEntry x="0" y="0" name="bookName" size="230" width="400" height="22" default="" />
  903. </HBox>
  904. </HBox>
  905. <Label x="0" y="0" hue="1153">"If you did NOT enter a blaze book name (above), then enter a script file and item type for the reward here:"</Label>
  906. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="3500" horizontalGap="0" padding="20">
  907. <Label x="0" y="0" hue="0">"Item type (e.g. bodysash):"</Label>
  908. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="9300" horizontalGap="0" padding="2">
  909. <TextEntry x="0" y="0" name="itemType" size="230" width="400" height="22" default="" />
  910. </HBox>
  911. </HBox>
  912. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="3500" horizontalGap="0" padding="20">
  913. <Label x="0" y="0" hue="0">"Item Script Path (e.g. rares\layered.us):"</Label>
  914. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="9300" horizontalGap="0" padding="2">
  915. <TextEntry x="0" y="0" name="itemPath" size="230" width="400" height="22" default="" />
  916. </HBox>
  917. </HBox>
  918. <Spacer/>
  919. <Label x="0" y="0" hue="1153">"Raffle End Time:"</Label>
  920. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="3500" horizontalGap="0" padding="20">
  921. <Label x="0" y="0" hue="0">"Month to End Raffle for Announcing Purposes:"</Label>
  922. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="9300" horizontalGap="0" padding="2">
  923. <TextEntry x="0" y="0" name="endMonth" size="11" width="70" height="22" default="" />
  924. </HBox>
  925. </HBox>
  926. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="3500" horizontalGap="0" padding="20">
  927. <Label x="0" y="0" hue="0">"Date to end raffle (e.g. 29):"</Label>
  928. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="9300" horizontalGap="0" padding="2">
  929. <TextEntry x="0" y="0" name="endDate" size="2" width="25" height="22" default="" />
  930. </HBox>
  931. </HBox>
  932. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="3500" horizontalGap="0" padding="20">
  933. <Label x="0" y="0" hue="0">"Day of week to end raffle (e.g. Monday):"</Label>
  934. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="9300" horizontalGap="0" padding="2">
  935. <TextEntry x="0" y="0" name="endDayOfWeek" size="9" width="70" height="22" default="" />
  936. </HBox>
  937. </HBox>
  938. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="3500" horizontalGap="0" padding="20">
  939. <Label x="0" y="0" hue="0">"Hour EST to end raffle (e.g. 22 for 10pm):"</Label>
  940. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="9300" horizontalGap="0" padding="2">
  941. <TextEntry x="20" y="0" name="endHour" size="2" width="25" height="22" default="" />
  942. </HBox>
  943. </HBox>
  944.  
  945. <Spacer/>
  946. <Label x="0" y="0" hue="1153">"Submit this raffle:"</Label>
  947. <HBox fitToContents="true" x="0" y="0" width="44" height="44" backgroundID="3500" horizontalGap="0" padding="20">
  948. <Label x="0" y="0" hue="0">"SUBMIT ONLY AFTER FILLING EVERYTHING OUT!"</Label>
  949. <Button x="0" y="0" name="submit" normalID="2074" pressedID="2075" />
  950. </HBox>
  951. </VBox>
  952. </Gump>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement