//======================================================================================== //Title: Automated Russian Roulette //Version: 1.0 //Author: Sharpienero //Created: 03/24/2016 //Compatibility: Hercules //Credits: Thanks to Ghost for his original Russian Roulette Script. //======================================================================================== prontera,149,179,6, script Automated Russian 4_M_JOB_BLACKSMITH,{ set .@n$,"[^0000FFAutomated Roulette^000000]"; //Name of the NPC. Make sure you also change it above. set .@GMLevel, 40; //What is the minimum gm level to activate the event if (getgmlevel() >= .@GMLevel) { if (.OFStatus == 1) { mes .@n$; mes "The event is currently ^0000FFON^000000."; mes "What would you like to do?"; if (select("No, please don't stop the event.","Yes, please stop the event.") == 2) { set .OFStatus,0; set .Started,0; announce "The event has been stopped.", bc_map | bc_red; close2; callsub CleanUp; close; end; } close; } else { mes .@n$; mes "Greetings, "+strcharinfo(0)+". Would you like to start the Russian Roulette event?"; if (select("Yes, please start the event.:No, please don't start the event.") == 2) close; { close2; set .OFStatus,1; callsub OnStart; } } } else { mes .@n$; if (.OFStatus == 1 && .Started == 0) { for(set .@i, 0; .@i < .pReg; set .@i, .@i + 1){ if(.playerlist$[.@i] == strcharinfo(0)) { mes "You're already registered, "+strcharinfo(0)+"! Please wait for the game to start."; close; } } mes "Would you like to register, "+strcharinfo(0)+"?"; if (select("Yes:No") == 2) { close; } else { set .playerlist$[.pReg], strcharinfo(0); set .pReg, .pReg + 1; announce "["+.pReg+ "] "+strcharinfo(0)+" has registered.",bc_area; } } else { if (.Started == 1) { mes "The event is currently in progress and you cannot join."; close; } else { mes "This game is quite simple. When the event is active, simply click on me to start, and I will do the rest."; } } } close; OnInit: set .Timer,1; set .pReg, 0; set .RandVar,1; set .Prize,6265; set .PrizeAmount,1; set .OFStatus,0; set .RandVar,0; end; OnStart: OnClock0000: OnClock0200: OnClock0400: OnClock0600: OnClock1621: set .OFStatus,1; announce "Russian Roulette will begin in 3 minutes. Please come to the event area (@warp prontera x y) to join the event.", bc_all | bc_blue; sleep2 5000; set .Timer,1; if (.Timer == 0) end; announce "Russian Roulette will begin in 2 minutes.", bc_all | bc_blue; sleep2 5000; if (.Timer == 0) end; announce "Russian Roulette will begin in 1 minute.", bc_all | bc_blue; sleep2 5000; if (.Timer == 0) end; announce "Russian Roulette has begun! Registration is now closed. Good luck to everyone!", bc_all | bc_blue; set .Started,1; set .RandVar,0; if (.RandVar == 0) { for(set .@i, 0; .@i < getarraysize(.playerlist$); set .@i, .@i + 1){ set .@j, .@j + 1; } sleep2 2000; npctalk "First off, thank you all for joining Russian Roulette. It's been too long since I've seen people blow their brains out. Now, let's begin..."; sleep2 2000; callsub OnSpin; } OnSpin: set .spin, rand(0, .pReg - 1); attachrid(getcharid(3, .playerlist$[.spin])); callsub OnCheck; npctalk "*puts the revolver on the floor and spins it*"; sleep2 2000; npctalk "*the revolver slowly stops spinning, pointing to "+strcharinfo(0)+"*"; sleep2 2000; npctalk "*watches " +strcharinfo(0)+ " put the revolver against their head and pull the trigger.*"; sleep2 2000; callsub OnCheck; callsub OnShoot; sleep2 2000; callsub OnSpin; return; OnShoot: if(rand(1, 3) == 1){ sleep2 2300; announce "*BOOM*!",bc_area | bc_red; specialeffect2 669; specialeffect2 531; percentheal -100, -100; deletearray .playerlist$[.spin], 1; set .pReg, .pReg - 1; } else { sleep2 2300; announce "*CLICK*!",bc_area; specialeffect2 675; specialeffect2 522 + rand(1,14); } return; OnCheck: if(.pReg <= 0) { announce .@n$ +" There was no winner for Russian Roulette.", bc_all; set .OFStatus,0; callsub CleanUp; end; } else if (.pReg == 1) { npctalk "Aw, it looks like you're the last person alive.. "+strcharinfo(0)+" wins, I guess.."; sleep2 2000; announce ""+strcharinfo(0)+" is the winner of Russian Roulette!", bc_all; getitem .Prize,.PrizeAmount; callsub CleanUp; close; end; } return; OnPCLogoutEvent: if (.OFStatus == 1) { setarray .disqualified$[.@x], strcharinfo(0); set .@x, .@x + 1; for(set .@i, 0; .@i < .pReg; set .@i, .@i + 1) { if(.playerlist$[.@i] == strcharinfo(0)) { deletearray .playerlist$[.@i], 1; set .pReg, .pReg - 1; announce "" +strcharinfo(0)+ " has been disqualified.",bc_area, 0xFF0000; end; } } } end; CleanUp: set .Started,0; set .Timer,1; set .OFStatus,0; set .pReg, 0; set .RandVar,1; stopnpctimer; deletearray .playerlist$, 128; deletearray .copiedplayer$, 128; deletearray .disqualified$, 128; end; }