more code cleanup

This commit is contained in:
2019-11-02 15:06:14 +01:00
parent 4e648e21c4
commit 7842375220
5 changed files with 39 additions and 40 deletions

View File

@@ -20,7 +20,7 @@ public Action:Timer_MapStart(Handle:timer){
public Action:Timer_RoundStart(Handle:timer){
LogActiveClients(logfile, "0x42,round_start_active,");
char map[SNAME_LEN];
MapName("0x42,mapname,",map, sizeof(map));
MapName("0x42,mapname,", map, sizeof(map));
LogToOpenFile(logfile, map);
return Plugin_Continue;
}
@@ -42,26 +42,26 @@ public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadca
public Action:Event_PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast){
LogClientEventFormat(logfile, event, "0x42,disconnect,");
LogActiveClients(logfile, "0x42,dc,");
return Plugin_Continue;
return Plugin_Continue;
}
public Action:Event_PlayerChangedTeam(Handle:event, const String:name[], bool:dontBroadcast){
LogActiveClients(logfile, "0x42,tc,");
LogClientEventFormat(logfile, event,"0x42,teamchange,");
return Plugin_Continue;
LogClientEventFormat(logfile, event, "0x42,teamchange,");
return Plugin_Continue;
}
public OnMapStart(){
CreateTimer(5.0,Timer_MapStart);
CreateTimer(5.0, Timer_MapStart);
}
/* ---------------------- Plugin ---------------------- */
public Plugin:myinfo = {
name = "skillbird-query",
author = "FAUSheppy",
description = "Backend for trueskill rating system",
version = "2.0",
url = "https://github.com/FAUSheppy/skillbird-sourcemod"
name = "skillbird-data-collection,
author = "FAUSheppy",
description = "Module to collect data for the skillbird framework",
version = "2.0",
url = "https://github.com/FAUSheppy/skillbird-sourcemod"
};
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max){
@@ -73,12 +73,12 @@ public OnPluginStart(){
/* get and verify server name for output file */
char server[SNAME_LEN];
ServerName(server, sizeof(server));
logfile = OpenFile(server,"at",false,NULL_STRING);
logfile = OpenFile(server, "at", false, NULL_STRING);
if strlen(server) < 1:
return ThrowNativeError(SP_ERROR_NATIVE, "Computed Invalid Servername '%s'", server)
/* inial line */
LogToOpenFile(logfile,"0x42,start");
LogToOpenFile(logfile, "0x42,start");
/* Hook Events */
HookEvent("round_end", Event_RoundEnd);
@@ -87,6 +87,6 @@ public OnPluginStart(){
}
public OnPluginEnd(){
LogToOpenFile(logfile,"0x42,plugin unloaded");
LogToOpenFile(logfile, "0x42,plugin unloaded");
CloseHandle(logfile);
}

View File

@@ -38,11 +38,11 @@ public Action Timer_QueryTeam(Handle timer, int client){
/* ---------------------- Plugin ---------------------- */
public Plugin:myinfo = {
name = "TrueSkill Query Plugin",
author = "sheppy",
description = "Queries to RatingDB",
version = "2.0",
url = "atlantishq.hq"
name = "skillbird-query",
author = "FAUSheppy",
description = "Module for interaction with the skillbird API",
version = "2.0",
url = "https://github.com/FAUSheppy/skillbird-sourcemod"
};
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max){

View File

@@ -11,14 +11,13 @@
public void ClientName(const client,char[] buf,buflen){
new String:name[DEFAULT_LEN];
if(IsClientConnected(client)){
GetClientName(client,name,DEFAULT_LEN);
GetClientName(client, name, DEFAULT_LEN);
/* get fucked if you use my seperators in your name */
ReplaceString(name,DEFAULT_LEN,",","$");
ReplaceString(name,DEFAULT_LEN,"|","&");
ReplaceString(name,DEFAULT_LEN,"0x42","0x21");
ReplaceString(name, DEFAULT_LEN,",","$");
ReplaceString(name, DEFAULT_LEN,"|","&");
ReplaceString(name, DEFAULT_LEN,"0x42","0x21");
}
//return name;
}
public void ClientID(int client, char[] buf, int buflen){
@@ -34,31 +33,31 @@ public void ActiveClients(char[] prefix, char[] buf, buflen){
new String:strCliName[DEFAULT_LEN];
ClientID(i, strCliID, DEFAULT_LEN);
ClientName(i, strCliName, DEFAULT_LEN);
Format(str_tmp, ACTIVE_CLIENTS_LENGTH,"%s|%s|%s|%d,", str_tmp, strCliID, strCliName, GetClientTeam(i));
Format(str_tmp, ACTIVE_CLIENTS_LENGTH,
"%s|%s|%s|%d,", str_tmp, strCliID, strCliName, GetClientTeam(i));
}
Format(str_tmp, ACTIVE_CLIENTS_LENGTH,"%s%s",prefix,str_tmp);
Format(str_tmp, ACTIVE_CLIENTS_LENGTH, "%s%s", prefix,str_tmp);
}
public void LogActiveClients(Handle:logfile, char[] prefix){
char strActiveClients[ACTIVE_CLIENTS_LENGTH];
ActiveClients(prefix, strActiveClients, ACTIVE_CLIENTS_LENGTH);
LogToOpenFile(logfile,strActiveClients);
LogToOpenFile(logfile, strActiveClients);
}
public void LogClientEventFormat(Handle:logfile, Handle:event, char[] prefix){
char strClientEvent[2*DEFAULT_LEN];
ClientEventFormat(event,prefix, strClientEvent, 2*DEFAULT_LEN);
LogToOpenFile(logfile,strClientEvent);
ClientEventFormat(event, prefix, strClientEvent, 2*DEFAULT_LEN);
LogToOpenFile(logfile, strClientEvent);
}
public void ClientEventFormat(Handle:event, char[] prefix, char[] buf, buflen){
new client = GetClientOfUserId(GetEventInt(event, "userid"));
char team[4];
Format(team,sizeof(team),"%d",GetClientTeam(client));
Format(team, sizeof(team), "%d", GetClientTeam(client));
char tmp[DEFAULT_LEN*2];
char strCliID[DEFAULT_LEN];
ClientID(client, strCliID, DEFAULT_LEN);
Format(tmp, 2*DEFAULT_LEN, "%s%s,%s", prefix, strCliID, team);
}

View File

@@ -50,13 +50,13 @@ public CaseSwitchReceive(Handle:socketl, String:receiveData[], const dataSize, a
SplitString(receiveData, INDEX_SEP, tag, TAG_LEN);
if(StrEqual(tag, "BALANCE_SINGLE")){
RebuildTeams(INDEX_SEP,"|",receiveData);
RebuildTeams(INDEX_SEP, "|",receiveData);
}else if(StrEqual(tag, "BALANCE_TEAMS")){
RebuildTeams(INDEX_SEP,"|",receiveData);
RebuildTeams(INDEX_SEP, "|",receiveData);
}else if(StrEqual(tag, "RATING_SINGLE")){
char ratingInfo[DEFAULT_LEN];
SplitString(receiveData, INDEX_SEP, ratingInfo, DEFAULT_LEN);
PrintToChatAll("%s",receiveData);
PrintToChatAll("%s", receiveData);
}
}
@@ -92,7 +92,7 @@ public OnSocketConnected(Handle:socketl,any:arg) {
}
public OnSocketDisconnected(Handle:socketl,any:arg) {
CreateTimer(10.0,AttemptReconnectSocket,socketl,TIMER_REPEAT);
CreateTimer(10.0, AttemptReconnectSocket, socketl, TIMER_REPEAT);
}
public OnSocketError(Handle:socketl, const errorType, const errorNum,any:arg) {

View File

@@ -4,7 +4,7 @@
public void EventWinnerTeam(Handle:event, char[] prefix, char[] buf, int buflen){
new team_id = GetEventInt(event, "winner");
Format(buf,buflen,"%s,%d",prefix,team_id);
Format(buf, buflen, "%s,%d", prefix, team_id);
}
public void MapName(char[] prefix, char[] buf, int buflen){
@@ -17,11 +17,11 @@ public void ServerName(char[] buf,int buflen){
new String:sname[SNAME_LEN];
ConVar servername = FindConVar("hostname");
servername.GetString(sname,SNAME_LEN);
ReplaceString(sname,SNAME_LEN," ","");
ReplaceString(sname,SNAME_LEN,"[","");
ReplaceString(sname,SNAME_LEN,"]","");
ReplaceString(sname,SNAME_LEN,"(","");
ReplaceString(sname,SNAME_LEN,")","");
ReplaceString(sname, SNAME_LEN," ","");
ReplaceString(sname, SNAME_LEN,"[","");
ReplaceString(sname, SNAME_LEN,"]","");
ReplaceString(sname, SNAME_LEN,"(","");
ReplaceString(sname, SNAME_LEN,")","");
}