Also, changing it to thread didn't work either, but it seems elgbot is printing that it's running...
Code:
main:
waitframe
level waittill spawn
///debugging help
level.debug = 0
if(level.elgbotDone == 1)
{
end
}
level.elgbotDone = 1
//get if elgbot is on
level.elgboton = getcvar "elgbot"
if(level.elgboton == "")
{
//set elgbot on
setcvar "elgbot" "1"
level.elgboton = 1
}
else
{
if(level.elgboton == "0" || int(level.elgboton) == 0)
{
level.elgboton = 0
end
}
else
{
level.elgboton = 1
}
}
//dont crash!
level waittill prespawn
//Register Events
thread eventregister "connected" elgbot/eventhandlers.scr::connected
waitframe
thread eventregister "disconnected" elgbot/eventhandlers.scr::disconnected
waitframe
thread eventregister "spawn" elgbot/eventhandlers.scr::spawn
waitframe
thread eventregister "damage" elgbot/eventhandlers.scr::damage
waitframe
thread eventregister "kill" elgbot/eventhandlers.scr::kill
waitframe
thread eventregister "keypress" elgbot/eventhandlers.scr::keypress
waitframe
thread eventregister "intermission" elgbot/eventhandlers.scr::intermission
waitframe
//set elgbot version
local.version = "2.2.1"
setcvar "elgbot_version" local.version
//just let console know we are running the mod
conprintf "Running Elgbot"
conprintf ("Elgbot Version: " + local.version )
level.elgbot_sounds = int(getcvar "elgbot_sounds")
if(!level.elgbot_sounds)
{
//set elgbot_sounds to local
setcvar "elgbot_sounds" "1"
conprintf "Elgbot warning: elgbot_sounds not srt, local (1) set by default"
level.elgbot_sounds = 1
}
else if(level.elgbot_sounds == 2)
{
//generate sounds to play over all the map
local.master = spawn scriptmaster
local.master aliascache headshot sounds/headshot.wav soundparms 1.2 0.1 0.9 0.2 320 4000 voice loaded maps "m dm obj"
local.master aliascache dominating sounds/dominating.wav soundparms 1.2 0.1 0.9 0.2 320 4000 voice loaded maps "m dm obj"
local.master aliascache double_kill sounds/double_kill.wav soundparms 1.2 0.1 0.9 0.2 320 4000 voice loaded maps "m dm obj"
local.master aliascache firstblood sounds/firstblood.wav soundparms 1.2 0.1 0.9 0.2 320 4000 voice loaded maps "m dm obj"
local.master aliascache godlike sounds/godlike.wav soundparms 1.2 0.1 0.9 0.2 320 4000 voice loaded maps "m dm obj"
local.master aliascache holyshit sounds/holyshit.wav soundparms 1.2 0.1 0.9 0.2 320 4000 voice loaded maps "m dm obj"
local.master aliascache killingspree sounds/killingspree.wav soundparms 1.2 0.1 0.9 0.2 320 4000 voice loaded maps "m dm obj"
local.master aliascache monsterkill sounds/monsterkill.wav soundparms 1.2 0.1 0.9 0.2 320 4000 voice loaded maps "m dm obj"
local.master aliascache multikill sounds/multikill.wav soundparms 1.2 0.1 0.9 0.2 320 4000 voice loaded maps "m dm obj"
local.master aliascache rampage sounds/rampage.wav soundparms 1.2 0.1 0.9 0.2 320 4000 voice loaded maps "m dm obj"
local.master aliascache ultrakill sounds/ultrakill.wav soundparms 1.2 0.1 0.9 0.2 320 4000 voice loaded maps "m dm obj"
local.master aliascache unstoppable sounds/unstoppable.wav soundparms 1.2 0.1 0.9 0.2 320 4000 voice loaded maps "m dm obj"
}
//For tracking weapon stats
level.weaponmodels = makearray
"models/fx/m2fgrenadeexplosion.tik" "m2frag"
"models/fx/m2fgrenadeexplosion.tik" "stielhandgranate"
"models/weapons/bar.tik" "bar"
"models/weapons/bazooka.tik" "bazooka"
"models/weapons/colt45.tik" "colt"
"models/weapons/kar98.tik" "kar98"
"models/weapons/KAR98sniper.tik" "kar98sniper"
"models/weapons/m1_garand.tik" "m1_garand"
"models/weapons/mp40.tik" "mp40"
"models/weapons/mp44.tik" "mp44"
"models/weapons/p38.tik" "p38"
"models/weapons/panzerschreck.tik" "panzerschreck"
"models/weapons/shotgun.tik" "axisshotgun"
"models/weapons/shotgun.tik" "shotgun"
"models/weapons/springfield.tik" "springfield"
"models/weapons/thompsonsmg.tik" "thompson"
endarray
//for quickly getting the name of a model, too lazy to loop and do conversions, just get it here, hope it saves a cpu cycle or two
level.weaponmodeltoname["models/weapons/bar.tik"] = "bar"
level.weaponmodeltoname["models/weapons/bazooka.tik"] = "bazooka"
level.weaponmodeltoname["models/weapons/colt45.tik"] = "colt"
level.weaponmodeltoname["models/weapons/kar98.tik"] = "kar98"
level.weaponmodeltoname["models/weapons/KAR98sniper.tik"] = "kar98sniper"
level.weaponmodeltoname["models/weapons/m1_garand.tik"] = "m1_garand"
level.weaponmodeltoname["models/weapons/mp40.tik"] = "mp40"
level.weaponmodeltoname["models/weapons/mp44.tik"] = "mp44"
level.weaponmodeltoname["models/weapons/p38.tik"] = "p38"
level.weaponmodeltoname["models/weapons/panzerschreck.tik"] = "panzerschreck"
level.weaponmodeltoname["models/weapons/shotgun.tik"] = "shotgun"
level.weaponmodeltoname["models/weapons/springfield.tik"] = "springfield"
level.weaponmodeltoname["models/weapons/thompsonsmg.tik"] = "thompson"
//Messages and sound names for double kills
//More could be added
level.doublekillmessages = makearray
"Double-Kill!!" "double_kill" "dblkill"
"Multi-Kill!!" "multikill" "multikill"
"Ultra-Kill!!" "ultrakill" "ultrakill"
"MONSTERKILL!!" "monsterkill" "monstkill"
endarray
//Messages and sound names first blood event
level.firstblood = makearray
"FIRST BLOOD!!" "firstblood"
endarray
//Messages and sound names getting a bash event
//message, sound
level.bashmessage = makearray
"BASH!!" ""
endarray
//these are all the known stats
// These are the stats to read and write (save)
// NOTE: Locations are not included
level.readwritestats = makearray
//temp, to grab from last round
"time"
"kdr"
"damage"
"accuracy"
"timeplayed"
"assists"
"rounds"
"allies"
"axis"
"gotbash"
"wasbashed"
"firstblood"
"suicides"
"deathsnokill"
"killsnodeath"
"kills"
"deaths"
"endedspree"
"teamkills"
endarray
// freze tag stats
level.freezetagstats = makearray
"melts"
endarray
//Messages and sounds for location events
//Must keep them the same order,
//
//1
//location ID INT
//
//2
//message on screen
// This only shows for a "killer"
//
//3
//sound file to play
//
//4
//stat name for records
level.locations = makearray
-1 "" "" "unknown"
0 "HEADSHOT!!" "headshot" "head"
//"1" "" "" ""
2 "" "" "neck"
3 "" "" "torso"
4 "" "" "torso"
5 "" "" "torso"
6 "" "" "torso"
7 "" "" "arm"
8 "" "" "arm"
9 "" "" "leg"
10 "" "" "leg"
11 "" "" "arm"
12 "" "" "arm"
13 "" "" "arm"
14 "" "" "leg"
//15 "" "" "leg"
//16 "" "" "leg"
17 "" "" "leg"
18 "" "" "leg"
endarray
//Killing spree messages and sounds
//Must keep them the same order,
//
//1
//kills needed for event INT
//
//2
//message on screen
//
//3
//sound file to play
//
//4
//stat name for records
level.killingspreemessages = makearray
5 "Killing-Spree!!" "killingspree" "kspree"
10 "Rampage!!" "rampage" "rampage"
15 "Dominating!!" "dominating" "dominating"
20 "Unstoppable!!" "unstoppable" "unstoppable"
25 "God-Like!!" "godlike" "godlike"
30 "HOLY-SHIT!!" "holyshit" "holyshit"
endarray
//instructions to show
// this is no longer used. but left here so you can reenable instructionslocal_old or intructions
// ..maybe for educational reasons
/*
// Removed by OwN-3m-All
level.instructions = makearray
"INSTRUCTIONS:"
""
"Elgbot Serverside Kill Streak Mod"
"by Elgan"
""
"You can view your personal server STATS"
"View your round STATS, Your Server Stats, Your scoreboard by:"
"Console Bind these commands for stats, by typing in console the following:"
"Bind KEY \"keyp 1\" -This is your round stats"
"Bind KEY \"keyp 2\" -This is your server stats"
"Bind KEY \"keyp 3\" -This is your weapon stats"
"Bind KEY \"keyp 4\" -This is your player kills scoreboard"
"Bind KEY \"keyp 5\" -This is the server all time top players scoreboard"
"Where KEY, is a key on your keyboard. Enable console in MOAHA options"
""
"UT Style Sounds Available"
"Headshotm, Killing Spree! Double Kill!"
"Download At:"
"www.ModTheater.com"
"www.x-null.net"
""
"This menu will ONLY show this once, press USE to hide, or join a team"
endarray
*/
//make instructions
// OwN-3m-All Edited Removed Instructions
// waitthread makeinstructions
//Type of message displayed at the bottom,
//should NOT edit these 2 lines.
level.messagetype_yellow = 1
level.messagetype_white = 0
//get gametype from cvar for ease
level.gametype = int(getcvar "g_gametype")
level.announceend = getcvar "elgbot_announceend"
if(level.announceend == "")
{
conprintf "ELGBOT elgbot_announceend NOT set"
//set elgbot_announceend on
setcvar "elgbot_announceend" "1"
level.announceend = 1
}
else
{
//get its value
level.announceend = int level.announceend
}
//BOOL have we done first blood or not yet
level.donefirstblood = 0
//set the time between double kills
local.cvar = int(getcvar "elgbot_dbltime")
//if its not set, make it 5
if(local.cvar <= 0)
{
//set double kill time
conprintf "ELGBOT elgbot_dbltime NOT set, using 20"
setcvar "elgbot_dbltime" "20"
local.cvar = 5
}
//check if we are in a round based type
local.gametype = int(getcvar "g_gametype")
//so we can detect team kills efficiently
level.freidnlyfire = int(getcvar "g_teamdamage ")
//set time between double kills
level.quickkilltime = local.cvar
//delay in seconds while showing our credits scoreboard
level.creditsdisplayfor = 5 //seconds
//chance in percent of displaying our credits.
level.creditsdisplaychance = 50
//delay in seconds between showing our scoreboard
level.scoreboarddisplaydelay = 60 //seconds
//create a server object to keep satts
level.server = local CreateListener
//tagrtname
level.server.targetname = "elgbot"
//let them know we are the server
level.server.areserver = 1
//proetend entnum
level.server.cvar = "elgbot_statserve"
//list of types of stats
//by adding to this array you will record top 5 for each category added
//named the same as the stats above
level.serverstats = makearray
"damage" "elgbot" "Most Damaging!"
"accuracy" "elgbot" "Most Accurate!"
"kdr" "elgbot" "Most Lethal"
"timeplayed" "elgbot" ""
"kills" "elgbot" "Most Deadly!"
"deaths" "elgbot" ""
"killsnodeath" "elgbot" "Streak King!"
"deathsnokill" "elgbot" "Target"
"rounds" "elgbot" ""
// "teamkills" "elgbot" ""
"gotbash" "elgbot" "Bash king!"
//not used other than totals
"head" "killloc" "Headhunter!"
"melts" "ft" "Melt King!"
endarray
//because it works ona rrays
local.serverstatkeys = makearray
"player1"
"score1"
"player2"
"score2"
"player3"
"score3"
"player4"
"score4"
"player5"
"score5"
endarray
//how many stats do we have?
level.server.stats = 0
//init stats for 5 players
for(local.i = 1; local.i <= level.serverstats.size; local.i++)
{
//get the sections of top players from the list
local.section = level.serverstats[local.i][1]
//init to find the best player in this category
level.server.elgbot[local.section]["player"] = NIL
level.server.elgbot[local.section]["score"] = 0
//local what is the cvar
local.cvar = ("elgbot_most" + local.section)
//get best player from last round for this stat
level.award[local.section] = getcvar local.cvar
// now clear the cvars, we dont want them anymore.
setcvar local.cvar ""
//Initilise stats for the server
//waitthread elgbot/elgbot.scr::initstat "stat" local.section local.serverstats 1
level.server waitthread elgbot/elgbot.scr::initstat local.section local.serverstatkeys 1
}
//do file stuff and grab a
level.server thread serverfile
//when some players have spawned
level waittill playerspawn
//run scoreboard
thread elgbot/hud.scr::scoreboard
//this is a new map/round. print best players from last round/
//display a little hud for this
waitthread elgbot/hud.scr::bestplayers
end
//////////////////////////////////////////
// serverfile
// runs threads to read server file
//////////////////////////////////////////
serverfile:
// Bug found by OwN-3m-All
// dont execute too fast or BOOM
// level waittill prespawn
//open a file object for the sever
self.elgbotfile = waitthread elgbot/files.scr::openserverfile
//now all the stats are initiated:
//try getting stats back from the cvar...(if we changed round, map or something...)
//if not, then read from the file
if(!(waitthread elgbot/elgbot.scr::readstatscvar))
{
//read the file
waitthread elgbot/files.scr::readstats
}
else
{
//save our stats to file,
waitthread elgbot/files.scr::writestats
//and delete
waitthread self.elgbotfile.deletefile
}
end local.elgbotfile
//////////////////////////////////////////
// makeinstructions
// build the instruction text from the array
//////////////////////////////////////////
makeinstructions:
//buffer
local.text = ""
//New instructions, just text
//loop through the above and turn the array in to text
//loop through and join the lines, but then strip the spaces too
for(local.i=1;local.i<=level.instructions.size ;local.i++ )
{
//get the instruction string.
//add the string to the scrll text
local.text += "\n" + level.instructions[local.i][1]
}
//reassign the instructions
level.instructions = local.text
end
//////////////////////////////////////////
// eventregister
// Registering events
//////////////////////////////////////////
eventregister local.event local.script:
// Unregister event first
// local.unregged = unregisterev local.event
//try to register
local.regged = registerev local.event local.script
//did we fail
if(local.regged > 0)
{
conprintf ("Elgbot Error: Failed to register event \"" + local.event + "\" Error Code: \"" + local.regged + "\"" )
}
end