so i started to create a plugin called battlerroyale but since i have to work allot i cannot be always bussy with it
so i allow everyone to help me developing on my plugin
CODE!!!!
so i allow everyone to help me developing on my plugin
CODE!!!!
Python:
__title__ = 'BattleRoyale'
__author__ = 'ice cold'
__version__ = '1.0 Beta'
import clr
clr.AddReferenceByPartialName("Fougerite")
clr.AddReferenceByPartialName("UnityEngine")
import UnityEngine
from UnityEngine import *
from Fougerite import Entity
import Fougerite
import re
sys = "BattleRoyale"
class BattleRoyale:
AirDropTimer = None
PlayTime = None
WaitTime = None
LootableObject = None
LootableObjects = None
def On_PluginInit(self):
DataStore.Flush("Playing")
DataStore.Save()
Util.ConsoleLog( __title__ +" by " + __author__ + " Version: " + __version__ + " loaded.", False)
ini = self.BattleRoyale()
self.LootableObject = Util.TryFindReturnType("LootableObject")
self.AirDropTimer = int(ini.GetSetting("Settings", "AirDropTimer"))
self.PlayTime = int(ini.GetSetting("Settings", "PlayTime"))
self.WaitTime = int(ini.GetSetting("Settings", "WaitTime"))
def BattleRoyale(self):
if not Plugin.IniExists("BattleRoyale"):
ini = Plugin.CreateIni("BattleRoyale")
ini.AddSetting("Settings", "AirDropTimer", "600000")
ini.AddSetting("Settings", "PlayTime", "3600000")
ini.AddSetting("Settings", "WaitTime", "5000")
ini.AddSetting("Messages", "StartMsg", "START!! Kill or be killed")
ini.AddSetting("Messages", "EndMsg", "Battle royale has been ended")
ini.AddSetting("Notices", "StartNotice", "FIGHT!!!! live and let die babe")
ini.AddSetting("Notices", "EndNotice", "The bloody Massacre has ended")
ini.Save()
return Plugin.GetIni("BattleRoyale")
def On_Command(self, Player, cmd, args):
if cmd == "br":
if Player.Admin:
Player.MessageFrom(sys, __title__ + " by ice cold")
Player.MessageFrom(sys, "/brsetlobby - here people wil spawn when they die or connect while plugin is running")
Player.MessageFrom(sys, "/brabout - shows info about BattleRoyale")
return
else:
Player.MessageFrom(sys, "You cannot use this Command")
return
elif cmd == "brsetlobby":
if Player.Admin:
Player.MessageFrom(sys, "Lobby set")
DataStore.Add("Lobby", "set", Player.Location)
DataStore.Save()
return
elif cmd == "brabout":
Player.MessageFrom(sys, "Battle Royale created by ice cold")
Player.MessageFrom(sys, "This plugin is designed to let people pvp to eachother and finding loot that wil be speared around the map")
Player.MessageFrom(sys, "When the match starts everyone wil get teleport in rad town valley and they need the loot")
return
elif cmd == "brlootcheck":
if Player.Admin:
World.Spawn("WeaponLootBox", 5797, 397, -3439)
World.Spawn("MedicalLootBox", 5797, 397, -3439)
World.Spawn("SupplyCrate", 5716, 406, -3400)
World.Spawn("BoxLoot", 5716, 406, -3400)
World.Spawn("SupplyCrate", 5716, 406, -3400)
World.Spawn("MedicalLootBox", 5716, 406, -3400)
World.Spawn("SupplyCrate", 5716, 406, -3400)
World.Spawn("AmmoLootBox", 6140, 383, -3429)
World.Spawn("SupplyCrate", 6377, 393, -3393)
World.Spawn("WeaponLootBox", 6611, 358, -3398)
World.Spawn("SupplyCrate", 6766, 367, -3443)
World.Spawn("SupplyCrate", 6670, 353, -3862)
World.Spawn("AmmoLootBox", 6832, 340, -4226)
World.Spawn("BoxLoot", 6816, 342, -4209)
World.Spawn("MedicalLootBox", 6739, 346, -4113)
World.Spawn("WeaponLootBox", 6616, 356, -4186)
World.Spawn("BoxLoot", 6637, 353, -4246)
World.Spawn("AmmoLootBox", 6631, 363, -4333)
World.Spawn("BoxLoot", 6762, 330, -4391)
World.Spawn("WeaponLootBox", 6407, 360, -4612)
World.Spawn("MedicalLootBox", 6351, 360, -4684)
World.Spawn("SupplyCrate", 6292, 364, -4804)
World.Spawn("AmmoLootBox", 6031, 391, -4441)
World.Spawn("WeaponLootBox", 6110, 385, -4417)
World.Spawn("AmmoLootBox", 6158, 378, -4360)
World.Spawn("MedicalLootBox", 5702, 414, -4247)
World.Spawn("WeaponLootBox", 5764, 409, -4292)
World.Spawn("SupplyCrate", 5206, 371, -4778)
World.Spawn("BoxLoot", 5239, 371, -4796)
World.Spawn("MedicalLootBox", 5215, 370, -4851)
World.Spawn("MedicalLootBox", 4544, 478, -4387)
World.Spawn("BoxLoot", 4552, 477, -4381)
World.Spawn("WeaponLootBox", 6047, 385, -3584)
World.Spawn("BoxLoot", 6079, 375, -3524)
World.Spawn("MedicalLootBox", 6020, 391, -3782)
return
elif cmd == "cleanloot":
if Player.Admin:
self.LootableObjects = UnityEngine.Object.FindObjectsOfType(self.LootableObject)
for x in self.LootableObjects:
if "lootsack" or "boxloot" or "weaponlootbox" or "medicallootbox" or "supplycrate" or "ammolootbox" in x.name.lower():
x._inventory.Clear()
Util.DestroyObject(x.gameObject)
elif cmd == "brstart":
home = DataStore.Get("Lobby", "set")
if Player.Admin:
if DataStore.Get("Lobby", "set") is not None:
Plugin.CreateTimer("WaitTime", self.WaitTime).Start()
for pl in Server.Players:
pl.TeleportTo(home)
pl.Notice("Battle starts in 60 seconds")
DataStore.Add("inlobby", pl.SteamID)
else:
Player.MessageFrom(sys, "You cannot starts the battle becaus its already active /brstop to stop")
def On_PlayerSpawned(self, Player, SpawnEvent):
if not DataStore.ContainsKey("Playing", Player.SteamID):
lobby = DataStore.Get("Lobby", "set")
Player.TeleportTo(lobby)
DataStore.Add("inlobby", Player.SteamID)
def WaitTimeCallback(self, timer):
timer.Kill()
Plugin.CreateTimer("AirDrop", self.AirDropTimer).Start()
Plugin.CreateTimer("PlayTime", self.PlayTime).Start()
ini = self.BattleRoyale()
startmessage = ini.GetSetting("Messages", "StartMsg")
startnotice = ini.GetSetting("Notices", "StartNotice")
World.Spawn("WeaponLootBox", 5797, 397, -3439)
World.Spawn("MedicalLootBox", 5797, 397, -3439)
World.Spawn("SupplyCrate", 5716, 406, -3400)
World.Spawn("AmmoLootBox", 6140, 383, -3429)
World.Spawn("SupplyCrate", 6377, 393, -3393)
World.Spawn("WeaponLootBox", 6611, 358, -3398)
World.Spawn("SupplyCrate", 6766, 367, -3443)
World.Spawn("SupplyCrate", 6670, 353, -3862)
World.Spawn("AmmoLootBox", 6832, 340, -4226)
World.Spawn("BoxLoot", 6816, 342, -4209)
World.Spawn("MedicalLootBox", 6739, 346, -4113)
World.Spawn("WeaponLootBox", 6616, 356, -4186)
World.Spawn("BoxLoot", 6637, 353, -4246)
World.Spawn("AmmoLootBox", 6631, 363, -4333)
World.Spawn("BoxLoot", 6762, 330, -4391)
World.Spawn("WeaponLootBox", 6407, 360, -4612)
World.Spawn("MedicalLootBox", 6351, 360, -4684)
World.Spawn("SupplyCrate", 6292, 364, -4804)
World.Spawn("AmmoLootBox", 6031, 391, -4441)
World.Spawn("WeaponLootBox", 6110, 385, -4417)
World.Spawn("AmmoLootBox", 6158, 378, -4360)
World.Spawn("MedicalLootBox", 5702, 414, -4247)
World.Spawn("WeaponLootBox", 5764, 409, -4292)
World.Spawn("SupplyCrate", 5206, 371, -4778)
World.Spawn("BoxLoot", 5239, 371, -4796)
World.Spawn("MedicalLootBox", 5215, 370, -4851)
World.Spawn("MedicalLootBox", 4544, 478, -4387)
World.Spawn("BoxLoot", 4552, 477, -4381)
World.Spawn("WeaponLootBox", 6047, 385, -3584)
World.Spawn("BoxLoot", 6079, 375, -3524)
World.Spawn("MedicalLootBox", 6020, 391, -3782)
for pl in Server.Players:
pl.TeleportTo(6622, 358, -3396)
pl.Notice("☢", startnotice, 20)
pl.MessageFrom(sys, startmessage)
pl.Inventory.AddItem("Rock", 1)
pl.Inventory.AddItem("Bandage", 3)
DataStore.Add("Playing", pl.SteamID)
DataStore.Flush("inlobby")
def AirDropCallBack(self, timer):
World.AirDrop()
timer.Kill()
Plugin.CreateTimer("AirDrop", self.AirDropTimer).Start()
for pl in Server.Players:
pl.Notice("✈", "Airdrop Incomming")
def PlayTimeCallBack(self, timer):
timer.Kill()
Plugin.CreateTimer("WaitTime", self.WaitTime).Start()
DataStore.Flush("Playing")
DataStore.Save()
endmessage = ini.GetSetting("Messages", "EndMsg")
endnotice = ini.GetSetting("Notices", "EndNotice")
lobby = DataStore.Get("Lobby", "set")
for pl in Server.Players:
if DataStore.ContainsKey("Playing", pl.SteamID):
pl.TeleportTo(lobby)
pl.Inventory.ClearAll()
pl.Notice("☢", endnotice, 20)
pl.MessageFrom(sys, endmessage)
self.LootableObjects = UnityEngine.Object.FindObjectsOfType(self.LootableObject)
for x in self.LootableObjects:
if "lootsack" or "boxloot" or "weaponlootbox" or "medicallootbox" or "supplycrate" or "ammolootbox" in x.name.lower():
x._inventory.Clear()
Util.DestroyObject(x.gameObject)
def On_PlayerKilled(self, DeathEvent):
if DeathEvent.VictimIsPlayer and DeathEvent.AttackerIsPlayer:
attacker = DeathEvent.Attacker.Name
victim = DeathEvent.Victim.Name
weapon = str(DeathEvent.Weapon.Name)
vid = DeathEvent.Victim.SteamID
# Server.BroadcastFrom(sys, attacker + " Has Destroyed " + victim + " With a " + weapon)
DataStore.Remove("Playing", vid)
return
elif DataStore.Count("Playing") == 1:
for pl in Server.Players:
home = DataStore.Get("Lobby", "set")
pl.TeleportTo(home)
pl.Kill()
pl.Notice("☢", "Game wil restart in 60 seconds")
if Plugin.GetTimer("Playing") is not None:
timer.Kill("Playing")
Plugin.CreateTimer("WaitTime", self.WaitTime).Start()
Server.Broadcast("Worked")
self.LootableObjects = UnityEngine.Object.FindObjectsOfType(self.LootableObject)
for x in self.LootableObjects:
if "lootsack" or "boxloot" or "weaponlootbox" or "medicallootbox" or "supplycrate" or "ammolootbox" in x.name.lower():
x._inventory.Clear()
Util.DestroyObject(x.gameObject)
else:
Server.BroadcastNotice("Something went wrong while loading new match RESTARTING SERVER")
Console.RunServerCommand("rustpp.shutdown")
def On_PlayerHurt(self, HurtEvent):
if HurtEvent.VictimIsPlayer and HurtEvent.AttackerIsPlayer:
if DataStore.ContainsKey("lobby", HurtEvent.Victim.SteamID) or DataStore.ContainsKey("lobby", HurtEvent.Attacker.SteamID):
HurtEvent.DamageAmount = 0
HurtEvent.Attacker.MessageFrom(sys, "You cannot kill while in lobby")