Skip to content

Instantly share code, notes, and snippets.

@TheMajical
Created March 10, 2018 14:05
Show Gist options
  • Save TheMajical/955f1e2dd2c8920a705ca6fd80a03f66 to your computer and use it in GitHub Desktop.
Save TheMajical/955f1e2dd2c8920a705ca6fd80a03f66 to your computer and use it in GitHub Desktop.
Random Events
__title__ = 'Dice'
__author__ = 'Assassin'
__version__ = '1.2'
import clr
clr.AddReferenceByPartialName("Fougerite")
import Fougerite
import System
from System import *
import math
import sys
path = Util.GetRootFolder()
sys.path.append(path + "\\Save\\Lib\\")
try:
import random
except ImportError:
raise ImportError("Failed to import random!")
import datetime
except ImportError:
raise ImportError("Missing Extra Libs folder! {DateTime module}")
"""
Config Starts from here
"""
# Cooldown time? 0 to disable | 300000 = 5 minutes
Cooldown = 300000
# Special Reward Item | for Example M4
SpecialReward = "Explosive Charge"
#Count Of Special Reward | for Example 2
SpecialRewardC = 2
green = "[color #009900]"
sys = "Dice"
class Dice:
def On_PluginInit(self):
DataStore.Flush("DiceCD")
def On_Command(self, Player, cmd, args):
if cmd == "dice":
r = random.randint(1, 15)
time = DataStore.Get("DiceCD", "DCD")
if time is None:
DataStore.Add("DiceCD", "DCD", 0)
time = 0
calc = System.Environment.TickCount - time
if calc < 0 or math.isnan(calc) or math.isnan(time):
DataStore.Add("DiceCD", "DCD", 0)
time = 0
if calc >= Cooldown or time == 0 or Cooldown == 0:
if r == 1:
Player.Inventory.Clear()
Player.MessageFrom(sys, "Oh!Your Inventory Has been Cleared!")
elif r == 2:
Player.Inventory.AddItem("P250")
Player.MessageFrom(sys, "Lucky!You got a P250!")
elif r == 3:
Player.Inventory.RemoveItem(36)
Player.Inventory.RemoveItem(37)
Player.Inventory.RemoveItem(38)
Player.Inventory.RemoveItem(39)
Player.MessageFrom(sys, "You lost all your Clothes!!")
elif r == 4:
Player.TeleportTo(-5253.3, 383.9, 4510.3)
Player.MessageFrom(sys, "You Teleported to an Unknown Place!!")
elif r == 5:
Player.Kill()
Player.MessageFrom(sys, "You did Suicide!!")
elif r == 6:
Player.MessageFrom(sys, "HAHA,Now I Will Tell Everyone You are NOOB!!")
Server.BroadcastFrom(sys," " + Player.Name + " is a real NOOB!")
elif r == 7:
Player.Inventory.AddItem("Rock", 40)
Player.MessageFrom(sys, "I Sent a Gift in your Inventory ;)")
elif r == 8:
World.Spawn(";res_woodpile", Player.Location)
Player.MessageFrom(sys, "Oh Looks Like You are in a Wood Pile")
elif r == 9:
World.Spawn("WeaponLootBox", Player.Location)
Player.MessageFrom(sys, "You Got a WeaponLoot Box!!")
elif r == 10:
World.Spawn(":boar_prefab", Player.Location)
Player.MessageFrom(sys, "You Got a Pig!Talk with it!")
elif r == 11:
Player.TeleportTo(6038.8, 373.5, -4658.5)
Player.MessageFrom(sys, "You Teleported On a Tree!You Can Sing a Song With Birds!")
elif r == 12:
Player.MessageFrom(sys, "Nothing Special!")
elif r == 13:
Player.Inventory.AddItem("Hatchet")
Player.MessageFrom(sys, "You got a Hatchet!")
elif r == 14:
Player.Inventory.AddItem("Bandage",4)
Player.MessageFrom(sys, "You got 4 Bandages!")
elif r == 15:
Player.Inventory.AddItem(SpecialReward, SpecialRewardC)
Player.MessageFrom(sys, "So Lucky!You got a SpeicalReward!")
Server.BroadcastFrom(sys," " + Player.Name + " Wins Special Reward!!!")
else:
Player.MessageFrom(sys, "Your Dice Has been Lost!You Can Use /dice again!")
else:
done = round((calc / 1000) / 60, 2)
done2 = round((Cooldown / 1000) / 60, 2)
Player.MessageFrom(sys, "Cooldown: " + str(done) + "/" + str(done2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment