/**
*
* Title: Custom Clantag changer
* Author: drakewild#2853 / drakewild#0001
* Description: Custom clantag with sync.
*
**/
aliases = [];
var cur_time;
function init(){
custom_tag = require("custom_clantags.js");
c_tag = custom_tag.clantags;
last_time = Globals.Curtime();
i = 0;
for(alias in c_tag){
aliases.push(alias);
}
UI.AddSubTab(["Misc.", "SUBTAB_MGR"], "Clantag");
UI.AddCheckbox(["Misc.", "Clantag", "Clantag"], 'Enable');
UI.AddDropdown(["Misc.","Clantag", "Clantag"], "Custom clantag", aliases ,0);
UI.AddSliderFloat(["Misc.", "Clantag", "Clantag"], "Animation Speed", 0, 5);
UI.AddSliderInt(["Misc.", "Clantag", "Clantag"], "Sync Speed", 1, 100);
UI.AddCheckbox(["Misc.", "Clantag", "Clantag"], 'Sync');
Cheat.RegisterCallback("Draw", "animate");
Cheat.RegisterCallback("Draw", "sync");
Cheat.RegisterCallback("Unload", "onUnload");
}
function animate(){
cur_time = Globals.Curtime();
if(!UI.GetValue(["Misc.", "Clantag", "Enable"])){
//basically sets ur clantag to empty line if checkbox is disabled
if(cur_time >= last_time+1){
Local.SetClanTag(" ");
last_time = Globals.Curtime();
}
return;
}
if(UI.GetValue(["Misc.", "Clantag", "Sync"]))
return;
if (cur_time >= last_time+(5.01-UI.GetValue(["Misc.","Clantag","Animation Speed"]))){
last_time = Globals.Curtime();
if(i >= c_tag[aliases[UI.GetValue(["Misc.", "Clantag", "Custom clantag"])]].length)
i = 0;
Local.SetClanTag(c_tag[aliases[UI.GetValue(["Misc.", "Clantag", "Custom clantag"])]][i]);
i++;
}
}
function sync(){
(UI.GetValue( ["Misc.", "Clantag", "Sync"] )) ? UI.SetEnabled(["Misc.", "Clantag", 'Animation Speed'],0) : UI.SetEnabled(["Misc.", "Clantag", 'Animation Speed'], 1);
(UI.GetValue( ["Misc.", "Clantag", "Sync"] )) ? UI.SetEnabled(["Misc.", "Clantag", 'Sync Speed'],1) : UI.SetEnabled(["Misc.", "Clantag", 'Sync Speed'], 0);
if(!UI.GetValue(["Misc.", "Clantag", "Enable"])){
if(cur_time >= last_time+1){
Local.SetClanTag(" ");
last_time = Globals.Curtime();
}
return;
}
if(!UI.GetValue(["Misc.", "Clantag", "Sync"]))
return;
clanSync(c_tag[aliases[UI.GetValue(["Misc.", "Clantag", "Custom clantag"])]].length);
}
/*
Sync function
I'm sure it can be done more efficient
*/
function clanSync(len){
i = 0;
speed = (UI.GetValue(["Misc.", "Clantag", "Sync Speed"]) >=10) ? (UI.GetValue(["Misc.", "Clantag", "Sync Speed"])/10) : 1;
server_time = (Globals.TickInterval()*Globals.Tickcount())*speed;
value = server_time % len;
if(i % len == 0){
if( cur_time >= last_time+0.02){
Local.SetClanTag(c_tag[aliases[UI.GetValue(["Misc.", "Clantag", "Custom clantag"])]][Math.floor( value )]);
last_time = Globals.Curtime();
}
i++;
}
}
function onUnload() {
Local.SetClanTag(' ');
}
init();