179 lines
6.5 KiB
Plaintext
179 lines
6.5 KiB
Plaintext
global function pulseInit
|
|
global function GetWeaponStatsFromToneAPI
|
|
global function GetMapStatsFromToneAPI
|
|
global function getWeaponKillsFromToneApi
|
|
global function getNemesisWeaponFromToneAPI
|
|
global function getDWEFromToneAPI
|
|
global function getMapKillFromToneAPI
|
|
global function getMapDeathFromToneAPI
|
|
global function getMapDistFromToneAPI
|
|
global function getMapMDistFromToneAPI
|
|
|
|
global table globalToneAPIKillData = {}
|
|
global table globalToneAPIDeathData = {}
|
|
global table globalToneAPIDWEData = {}
|
|
global table globalToneAPIMapDeathData = {}
|
|
global table globalToneAPIMapDistData = {}
|
|
global table globalToneAPIMapKillData = {}
|
|
global table globalToneAPIMapMDistData = {}
|
|
|
|
string prefix = "default"
|
|
string HTTPrequestURL = "default"
|
|
int weaponEntries = 0
|
|
int mapEntries = 0
|
|
int weaponRefCount = 0
|
|
int weaponRefKills = 0
|
|
int weaponRefDeaths = 0
|
|
int weaponRefDWE = 0
|
|
int mapRefCount = 0
|
|
int mapRefKills = 0
|
|
int mapRefDeaths = 0
|
|
int mapRefDist = 0
|
|
int mapRefMDist = 0
|
|
|
|
void function pulseInit()
|
|
{
|
|
HTTPrequestURL = GetConVarString("ToneURL")
|
|
prefix = "\x1b[38;2;255;178;102m[PULSE]\x1b[0m "
|
|
print(prefix + "v1.2.0 has been loaded.")
|
|
}
|
|
|
|
void function GetWeaponStatsFromToneAPI()
|
|
{
|
|
print(prefix + "Getting kill data...")
|
|
HttpRequest getWeaponStats
|
|
getWeaponStats.method = HttpRequestMethod.GET
|
|
getWeaponStats.url = HTTPrequestURL + "/weapons"
|
|
getWeaponStats.queryParameters["player"] <- [NSGetLocalPlayerUID()]
|
|
void functionref(HttpRequestResponse) onSuccess = void function(HttpRequestResponse response)
|
|
{
|
|
print(prefix + "Kill data received, processing...")
|
|
table JSONForConversion = DecodeJSON(response.body)
|
|
foreach (var key, var value in JSONForConversion) {
|
|
table test = expect table(value)
|
|
globalToneAPIKillData[string(key)] <- test.kills
|
|
globalToneAPIDeathData[string(key)] <- test.deaths
|
|
globalToneAPIDWEData[string(key)] <- test.deaths_while_equipped
|
|
weaponEntries += 1
|
|
}
|
|
print(prefix + "Kill data has been processed with a total of " + string(weaponEntries) + " entries.")
|
|
}
|
|
|
|
void functionref(HttpRequestFailure) onFailure = void function(HttpRequestFailure failure)
|
|
{
|
|
print(prefix + "Encountered an error getting kill data...")
|
|
}
|
|
|
|
NSHttpRequest(getWeaponStats, onSuccess, onFailure)
|
|
}
|
|
|
|
void function GetMapStatsFromToneAPI()
|
|
{
|
|
print(prefix + "Getting map data...")
|
|
HttpRequest getMapStats
|
|
getMapStats.method = HttpRequestMethod.GET
|
|
getMapStats.url = HTTPrequestURL + "/maps"
|
|
getMapStats.queryParameters["player"] <- [NSGetLocalPlayerUID()]
|
|
void functionref(HttpRequestResponse) onSuccess = void function(HttpRequestResponse response)
|
|
{
|
|
print(prefix + "Map data received, processing...")
|
|
table JSONForConversion = DecodeJSON(response.body)
|
|
foreach (var key, var value in JSONForConversion) {
|
|
table test = expect table(value)
|
|
globalToneAPIMapKillData[string(key)] <- test.kills
|
|
globalToneAPIMapDeathData[string(key)] <- test.deaths
|
|
globalToneAPIMapDistData[string(key)] <- test.total_distance
|
|
globalToneAPIMapMDistData[string(key)] <- test.max_distance
|
|
mapEntries += 1
|
|
}
|
|
print(prefix + "Map data has been processed with a total of " + string(mapEntries) + " entries.")
|
|
}
|
|
|
|
void functionref(HttpRequestFailure) onFailure = void function(HttpRequestFailure failure)
|
|
{
|
|
print(prefix + "Encountered an error getting map data...")
|
|
}
|
|
|
|
NSHttpRequest(getMapStats, onSuccess, onFailure)
|
|
}
|
|
|
|
int function getWeaponKillsFromToneApi(string weaponRef){
|
|
|
|
if(weaponRef in globalToneAPIKillData){
|
|
weaponRefCount += 1
|
|
weaponRefKills += expect int(globalToneAPIKillData[weaponRef])
|
|
return expect int(globalToneAPIKillData[weaponRef])
|
|
}
|
|
print(prefix + "Found a total of " + string(weaponRefCount) + " weapon references with " + string(weaponRefKills) + " total kills.")
|
|
return 0
|
|
}
|
|
|
|
int function getNemesisWeaponFromToneAPI(string weaponRef){
|
|
|
|
if(weaponRef in globalToneAPIDeathData){
|
|
weaponRefCount += 1
|
|
weaponRefDeaths += expect int(globalToneAPIDeathData[weaponRef])
|
|
return expect int(globalToneAPIDeathData[weaponRef])
|
|
}
|
|
print(prefix + "Found a total of " + string(weaponRefCount) + " weapon references with " + string(weaponRefDeaths) + " total deaths.")
|
|
return 0
|
|
}
|
|
|
|
int function getDWEFromToneAPI(string weaponRef){
|
|
|
|
if(weaponRef in globalToneAPIDWEData){
|
|
weaponRefCount += 1
|
|
weaponRefDWE += expect int(globalToneAPIDWEData[weaponRef])
|
|
return expect int(globalToneAPIDWEData[weaponRef])
|
|
}
|
|
print(prefix + "Found a total of " + string(weaponRefCount) + " weapon references with " + string(weaponRefDWE) + " total deaths with weapon.")
|
|
return 0
|
|
}
|
|
|
|
int function getMapKillFromToneAPI(string mapName){
|
|
|
|
mapName = mapName.slice(3)
|
|
if(mapName in globalToneAPIMapKillData){
|
|
mapRefCount += 1
|
|
mapRefKills += expect int(globalToneAPIMapKillData[mapName])
|
|
return expect int(globalToneAPIMapKillData[mapName])
|
|
}
|
|
print(prefix + "Found a total of " + string(mapRefCount) + " map references with " + string(mapRefKills) + " total kills.")
|
|
return 0
|
|
}
|
|
|
|
int function getMapDeathFromToneAPI(string mapName){
|
|
|
|
mapName = mapName.slice(3)
|
|
if(mapName in globalToneAPIMapDeathData){
|
|
mapRefCount += 1
|
|
mapRefDeaths += expect int(globalToneAPIMapDeathData[mapName])
|
|
return expect int(globalToneAPIMapDeathData[mapName])
|
|
}
|
|
print(prefix + "Found a total of " + string(mapRefCount) + " map references with " + string(mapRefDeaths) + " total deaths.")
|
|
return 0
|
|
}
|
|
|
|
int function getMapMDistFromToneAPI(string mapName){
|
|
|
|
mapName = mapName.slice(3)
|
|
if(mapName in globalToneAPIMapMDistData){
|
|
mapRefCount += 1
|
|
mapRefMDist += expect int(globalToneAPIMapMDistData[mapName])
|
|
return expect int(globalToneAPIMapMDistData[mapName])
|
|
}
|
|
print(prefix + "Found a total of " + string(mapRefCount) + " map references with " + string(mapRefMDist) + " total maximum distance in Hammer units.")
|
|
return 0
|
|
}
|
|
|
|
int function getMapDistFromToneAPI(string mapName){
|
|
|
|
mapName = mapName.slice(3)
|
|
if(mapName in globalToneAPIMapDistData){
|
|
mapRefCount += 1
|
|
mapRefDist += expect int(globalToneAPIMapDistData[mapName])
|
|
return expect int(globalToneAPIMapDistData[mapName])
|
|
}
|
|
print(prefix + "Found a total of " + string(mapRefCount) + " map references with " + string(mapRefDist) + " total distance in Hammer units.")
|
|
return 0
|
|
} |