/*************************************************************************** * plugin_sank_dice.sma * Author: Luke Sankey * November 27, 2001 - Beginning * December 4, 2001 - Initial release * November 15, 2002 - No more gambling when dead. * * Fuctionality of this plugin: * It is a fun plugin to play dice. Users may gamble when admin_dice is set. * The sum of the numbers rolled determines what their fate is. The rewards * are as follows: * 2 or 12 Godmode * 3 or 11 Noclip * 4 or 10 Stuck * 5 or 9 Glow * 6 or 8 Slap * 7 Death * * My most deepest thanks goes to [SCR]Lightfoot-TA- (lightfoot_sf@yahoo.ca) * for he was the one who wrote the original, however buggy it may have been. ***************************************************************************/ // Functions included in this plugin // admin_dice <on|off> // say "roll the dice" or "I feel lucky" // Access required to enable gambling #define ACCESS_DICE 512 // Time of rewards, in seconds #define GODMODE_TIME 10 #define NOCLIP_TIME 20 #define STUCK_TIME 10 #define GLOW_TIME 15 // Delay required between gambling, in seconds #define GAMBLE_DELAY 60 /****************************************************************************/ /****************************************************************************/ /************** DO NOT MODIFY CONTENTS BELOW THIS LINE !!! ******************/ /************** DO NOT MODIFY CONTENTS BELOW THIS LINE !!! ******************/ /************** DO NOT MODIFY CONTENTS BELOW THIS LINE !!! ******************/ /****************************************************************************/ /****************************************************************************/ #include <core> #include <console> #include <string> #include <admin> #include <adminlib> new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.50"; // Global variables indicating if dice games are enabled or not new bool:bGamesEnabled = true; new bool:bIsGambling = false; new LastGambleTime[MAX_PLAYERS]; /****************************************************************************/ /************************** Plugin Entry Point ******************************/ /****************************************************************************/ public plugin_init() { plugin_registerinfo("Roll The Dice Plugin", "Roll to win!.", STRING_VERSION); plugin_registercmd("say", "HandleSay", ACCESS_ALL); plugin_registercmd("admin_dice", "admin_dice", ACCESS_DICE, "admin_dice <on|off>: Turns dice games on or off."); return PLUGIN_CONTINUE; } public plugin_connect(HLUserName, HLIP, UserIndex) { if (UserIndex >= 1 && UserIndex <= MAX_PLAYERS) LastGambleTime[UserIndex] = 0; return PLUGIN_CONTINUE; } /****************************************************************************/ /************************** User called functions ***************************/ /****************************************************************************/ public admin_dice(HLCommand, HLData, HLUserName, UserIndex) { new Data[MAX_DATA_LENGTH]; new User[MAX_NAME_LENGTH]; new Text[MAX_TEXT_LENGTH]; new Red = random(256); new Green = random(256); new Blue = random(256); convert_string(HLData, Data, MAX_COMMAND_LENGTH); convert_string(HLUserName, User, MAX_NAME_LENGTH); if (check_param(Data) == 1) { bGamesEnabled = true; snprintf(Text, MAX_TEXT_LENGTH, "Let the games begin!"); centersay(Text, 5, Red, Green, Blue); } else { bGamesEnabled = false; snprintf(Text, MAX_TEXT_LENGTH, "The casino is now closed."); centersay(Text, 5, Red, Green, Blue); } snprintf(Text, MAX_TEXT_LENGTH, "admin_dice %d", bGamesEnabled); selfmessage(Text); return PLUGIN_HANDLED; } public HandleSay(HLCommand, HLData, HLUserName, UserIndex) { new Data[MAX_DATA_LENGTH]; new User[MAX_NAME_LENGTH]; new Text[MAX_TEXT_LENGTH]; new Roll; new Red = random(256); new Green = random(256); new Blue = random(256); new X; new Y; new Z; convert_string(HLData, Data, MAX_DATA_LENGTH); convert_string(HLUserName, User, MAX_NAME_LENGTH); // Remove quotes, if there are any strstripquotes(Data); if ( ((strcasecmp(Data, "roll the dice") == 0) || (strcasecmp(Data, "i feel lucky") == 0)) && (bGamesEnabled == true) ) { new CurTime = systemtime(); // Limit gambling frequency new iDead; playerinfo(UserIndex, Text, MAX_TEXT_LENGTH, _, _, _, iDead, _); if (iDead != 0) { messageex(User, "<Dice Dealer> Dead men tell no tales (nor do they gamble).", print_chat); return PLUGIN_CONTINUE; } else if (CurTime < (LastGambleTime[UserIndex] + GAMBLE_DELAY)) { messageex(User, "<Dice Dealer> You gambled recently; try again later.", print_chat); return PLUGIN_CONTINUE; } else if (bIsGambling == true) { messageex(User, "<Dice Dealer> I'm busy with someone else; please wait.", print_chat); return PLUGIN_CONTINUE; } else { // Roll the dice new Dieone = random(6) + 1; new Dietwo = random(6) + 1; // Calculate the total roll Roll = Dieone + Dietwo; snprintf(Text, MAX_TEXT_LENGTH, "<Dice Dealer> %s rolled [%d] [%d]", User, Dieone, Dietwo); say(Text); if ((Roll == 2) || (Roll == 12)) { bIsGambling = true; snprintf(Text, MAX_TEXT_LENGTH, "<Dice Dealer> Congratulations, %s won Godmode!", User); godmode(User, 1); set_timer("Godmode_Timer", 1, GODMODE_TIME); snprintf(Text, MAX_TEXT_LENGTH, "Godmode Winner:^n%s!!", User); centersay(Text, 3, Red, Green, Blue); } else if ((Roll == 3) || (Roll == 11)) { bIsGambling = true; snprintf(Text, MAX_TEXT_LENGTH, "<Dice Dealer> Congratulations, %s won Noclip!", User); noclip(User, 1); set_timer("Noclip_Timer", 1, NOCLIP_TIME); snprintf(Text, MAX_TEXT_LENGTH, "Noclip Winner:^n%s!!", User); centersay(Text, 3, Red, Green, Blue); } else if ((Roll == 4) || (Roll == 10)) { bIsGambling = true; snprintf(Text, MAX_TEXT_LENGTH, "<Dice Dealer> %s lost, and is stuck!", User); get_userorigin(User, X, Y, Z); Z -= 40; teleport(User, X, Y, Z); set_timer("Stuck_Timer", 1, STUCK_TIME); } else if ((Roll == 5) || (Roll == 9)) { bIsGambling = true; snprintf(Text, MAX_TEXT_LENGTH, "<Dice Dealer> Congratulations, %s is glowing!", User); glow(User, Red, Green, Blue); set_timer("Glow_Timer", 1, GLOW_TIME); } else if ((Roll == 6) || (Roll == 8)) { snprintf(Text, MAX_TEXT_LENGTH, "<Dice Dealer> Ouch! %s won a slap!", User); slap(User); } else if (Roll == 7) { snprintf(Text, MAX_TEXT_LENGTH, "<Dice Dealer> %s did not win.", User); slay(User); } LastGambleTime[UserIndex] = CurTime; say(Text); } } return PLUGIN_CONTINUE; } /****************************************************************************/ /*************************** Timer Functions ********************************/ /****************************************************************************/ public Glow_Timer(Timer, Repeat, HLUserName, HLParam) { new Text[MAX_TEXT_LENGTH]; new User[MAX_NAME_LENGTH]; new Red = random(256); new Green = random(256); new Blue = random(256); convert_string(HLUserName, User, MAX_NAME_LENGTH); if (Repeat-1 == 0) { glow(User, 0, 0, 0); snprintf(Text, MAX_TEXT_LENGTH, "%s is no longer glowing", User); bIsGambling = false; } else { glow(User, Red, Green, Blue); snprintf(Text, MAX_TEXT_LENGTH, "%s is glowing for %d", User, Repeat-1); } typesay(Text, 1, Red, Green, Blue); } public Godmode_Timer(Timer, Repeat, HLUserName, HLParam) { new Text[MAX_TEXT_LENGTH]; new User[MAX_NAME_LENGTH]; new Red = random(256); new Green = random(256); new Blue = random(256); convert_string(HLUserName, User, MAX_NAME_LENGTH); if (Repeat-1 == 0) { godmode(User, 0); snprintf(Text, MAX_TEXT_LENGTH, "%s no longer has Godmode", User); bIsGambling = false; } else { snprintf(Text, MAX_TEXT_LENGTH, "%s has Godmode for %d", User, Repeat-1); } typesay(Text, 1, Red, Green, Blue); } public Noclip_Timer(Timer, Repeat, HLUserName, HLParam) { new Text[MAX_TEXT_LENGTH]; new User[MAX_NAME_LENGTH]; new Red = random(256); new Green = random(256); new Blue = random(256); convert_string(HLUserName, User, MAX_NAME_LENGTH); if (Repeat-1 == 0) { noclip(User, 0); snprintf(Text, MAX_TEXT_LENGTH, "%s no longer has Noclip", User); bIsGambling = false; } else { snprintf(Text, MAX_TEXT_LENGTH, "%s has Noclip for %d", User, Repeat-1); } typesay(Text, 1, Red, Green, Blue); } public Stuck_Timer(Timer, Repeat, HLUserName, HLParam) { new Text[MAX_TEXT_LENGTH]; new User[MAX_NAME_LENGTH]; new Red = random(256); new Green = random(256); new Blue = random(256); new X; new Y; new Z; convert_string(HLUserName, User, MAX_NAME_LENGTH); if (Repeat-1 == 0) { get_userorigin(User, X, Y, Z); Z += 50; teleport(User, X, Y, Z); snprintf(Text, MAX_TEXT_LENGTH, "%s has been unstuck", User); bIsGambling = false; } else { snprintf(Text, MAX_TEXT_LENGTH, "%s has been stuck for %d", User, Repeat-1); } typesay(Text, 1, Red, Green, Blue); }