mirror of
https://github.com/FAUSheppy/skillbird-sourcemod
synced 2025-12-07 07:31:37 +01:00
more code cleanup
This commit is contained in:
@@ -20,7 +20,7 @@ public Action:Timer_MapStart(Handle:timer){
|
|||||||
public Action:Timer_RoundStart(Handle:timer){
|
public Action:Timer_RoundStart(Handle:timer){
|
||||||
LogActiveClients(logfile, "0x42,round_start_active,");
|
LogActiveClients(logfile, "0x42,round_start_active,");
|
||||||
char map[SNAME_LEN];
|
char map[SNAME_LEN];
|
||||||
MapName("0x42,mapname,",map, sizeof(map));
|
MapName("0x42,mapname,", map, sizeof(map));
|
||||||
LogToOpenFile(logfile, map);
|
LogToOpenFile(logfile, map);
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
@@ -47,19 +47,19 @@ public Action:Event_PlayerDisconnect(Handle:event, const String:name[], bool:don
|
|||||||
|
|
||||||
public Action:Event_PlayerChangedTeam(Handle:event, const String:name[], bool:dontBroadcast){
|
public Action:Event_PlayerChangedTeam(Handle:event, const String:name[], bool:dontBroadcast){
|
||||||
LogActiveClients(logfile, "0x42,tc,");
|
LogActiveClients(logfile, "0x42,tc,");
|
||||||
LogClientEventFormat(logfile, event,"0x42,teamchange,");
|
LogClientEventFormat(logfile, event, "0x42,teamchange,");
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OnMapStart(){
|
public OnMapStart(){
|
||||||
CreateTimer(5.0,Timer_MapStart);
|
CreateTimer(5.0, Timer_MapStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------- Plugin ---------------------- */
|
/* ---------------------- Plugin ---------------------- */
|
||||||
public Plugin:myinfo = {
|
public Plugin:myinfo = {
|
||||||
name = "skillbird-query",
|
name = "skillbird-data-collection,
|
||||||
author = "FAUSheppy",
|
author = "FAUSheppy",
|
||||||
description = "Backend for trueskill rating system",
|
description = "Module to collect data for the skillbird framework",
|
||||||
version = "2.0",
|
version = "2.0",
|
||||||
url = "https://github.com/FAUSheppy/skillbird-sourcemod"
|
url = "https://github.com/FAUSheppy/skillbird-sourcemod"
|
||||||
};
|
};
|
||||||
@@ -73,12 +73,12 @@ public OnPluginStart(){
|
|||||||
/* get and verify server name for output file */
|
/* get and verify server name for output file */
|
||||||
char server[SNAME_LEN];
|
char server[SNAME_LEN];
|
||||||
ServerName(server, sizeof(server));
|
ServerName(server, sizeof(server));
|
||||||
logfile = OpenFile(server,"at",false,NULL_STRING);
|
logfile = OpenFile(server, "at", false, NULL_STRING);
|
||||||
if strlen(server) < 1:
|
if strlen(server) < 1:
|
||||||
return ThrowNativeError(SP_ERROR_NATIVE, "Computed Invalid Servername '%s'", server)
|
return ThrowNativeError(SP_ERROR_NATIVE, "Computed Invalid Servername '%s'", server)
|
||||||
|
|
||||||
/* inial line */
|
/* inial line */
|
||||||
LogToOpenFile(logfile,"0x42,start");
|
LogToOpenFile(logfile, "0x42,start");
|
||||||
|
|
||||||
/* Hook Events */
|
/* Hook Events */
|
||||||
HookEvent("round_end", Event_RoundEnd);
|
HookEvent("round_end", Event_RoundEnd);
|
||||||
@@ -87,6 +87,6 @@ public OnPluginStart(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
public OnPluginEnd(){
|
public OnPluginEnd(){
|
||||||
LogToOpenFile(logfile,"0x42,plugin unloaded");
|
LogToOpenFile(logfile, "0x42,plugin unloaded");
|
||||||
CloseHandle(logfile);
|
CloseHandle(logfile);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,11 +38,11 @@ public Action Timer_QueryTeam(Handle timer, int client){
|
|||||||
|
|
||||||
/* ---------------------- Plugin ---------------------- */
|
/* ---------------------- Plugin ---------------------- */
|
||||||
public Plugin:myinfo = {
|
public Plugin:myinfo = {
|
||||||
name = "TrueSkill Query Plugin",
|
name = "skillbird-query",
|
||||||
author = "sheppy",
|
author = "FAUSheppy",
|
||||||
description = "Queries to RatingDB",
|
description = "Module for interaction with the skillbird API",
|
||||||
version = "2.0",
|
version = "2.0",
|
||||||
url = "atlantishq.hq"
|
url = "https://github.com/FAUSheppy/skillbird-sourcemod"
|
||||||
};
|
};
|
||||||
|
|
||||||
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max){
|
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max){
|
||||||
|
|||||||
@@ -11,14 +11,13 @@
|
|||||||
public void ClientName(const client,char[] buf,buflen){
|
public void ClientName(const client,char[] buf,buflen){
|
||||||
new String:name[DEFAULT_LEN];
|
new String:name[DEFAULT_LEN];
|
||||||
if(IsClientConnected(client)){
|
if(IsClientConnected(client)){
|
||||||
GetClientName(client,name,DEFAULT_LEN);
|
GetClientName(client, name, DEFAULT_LEN);
|
||||||
|
|
||||||
/* get fucked if you use my seperators in your name */
|
/* get fucked if you use my seperators in your name */
|
||||||
ReplaceString(name,DEFAULT_LEN,",","$");
|
ReplaceString(name, DEFAULT_LEN,",","$");
|
||||||
ReplaceString(name,DEFAULT_LEN,"|","&");
|
ReplaceString(name, DEFAULT_LEN,"|","&");
|
||||||
ReplaceString(name,DEFAULT_LEN,"0x42","0x21");
|
ReplaceString(name, DEFAULT_LEN,"0x42","0x21");
|
||||||
}
|
}
|
||||||
//return name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClientID(int client, char[] buf, int buflen){
|
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];
|
new String:strCliName[DEFAULT_LEN];
|
||||||
ClientID(i, strCliID, DEFAULT_LEN);
|
ClientID(i, strCliID, DEFAULT_LEN);
|
||||||
ClientName(i, strCliName, 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){
|
public void LogActiveClients(Handle:logfile, char[] prefix){
|
||||||
char strActiveClients[ACTIVE_CLIENTS_LENGTH];
|
char strActiveClients[ACTIVE_CLIENTS_LENGTH];
|
||||||
ActiveClients(prefix, 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){
|
public void LogClientEventFormat(Handle:logfile, Handle:event, char[] prefix){
|
||||||
char strClientEvent[2*DEFAULT_LEN];
|
char strClientEvent[2*DEFAULT_LEN];
|
||||||
ClientEventFormat(event,prefix, strClientEvent, 2*DEFAULT_LEN);
|
ClientEventFormat(event, prefix, strClientEvent, 2*DEFAULT_LEN);
|
||||||
LogToOpenFile(logfile,strClientEvent);
|
LogToOpenFile(logfile, strClientEvent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClientEventFormat(Handle:event, char[] prefix, char[] buf, buflen){
|
public void ClientEventFormat(Handle:event, char[] prefix, char[] buf, buflen){
|
||||||
new client = GetClientOfUserId(GetEventInt(event, "userid"));
|
new client = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||||
char team[4];
|
char team[4];
|
||||||
Format(team,sizeof(team),"%d",GetClientTeam(client));
|
Format(team, sizeof(team), "%d", GetClientTeam(client));
|
||||||
char tmp[DEFAULT_LEN*2];
|
char tmp[DEFAULT_LEN*2];
|
||||||
char strCliID[DEFAULT_LEN];
|
char strCliID[DEFAULT_LEN];
|
||||||
ClientID(client, strCliID, DEFAULT_LEN);
|
ClientID(client, strCliID, DEFAULT_LEN);
|
||||||
Format(tmp, 2*DEFAULT_LEN, "%s%s,%s", prefix, strCliID, team);
|
Format(tmp, 2*DEFAULT_LEN, "%s%s,%s", prefix, strCliID, team);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,13 +50,13 @@ public CaseSwitchReceive(Handle:socketl, String:receiveData[], const dataSize, a
|
|||||||
SplitString(receiveData, INDEX_SEP, tag, TAG_LEN);
|
SplitString(receiveData, INDEX_SEP, tag, TAG_LEN);
|
||||||
|
|
||||||
if(StrEqual(tag, "BALANCE_SINGLE")){
|
if(StrEqual(tag, "BALANCE_SINGLE")){
|
||||||
RebuildTeams(INDEX_SEP,"|",receiveData);
|
RebuildTeams(INDEX_SEP, "|",receiveData);
|
||||||
}else if(StrEqual(tag, "BALANCE_TEAMS")){
|
}else if(StrEqual(tag, "BALANCE_TEAMS")){
|
||||||
RebuildTeams(INDEX_SEP,"|",receiveData);
|
RebuildTeams(INDEX_SEP, "|",receiveData);
|
||||||
}else if(StrEqual(tag, "RATING_SINGLE")){
|
}else if(StrEqual(tag, "RATING_SINGLE")){
|
||||||
char ratingInfo[DEFAULT_LEN];
|
char ratingInfo[DEFAULT_LEN];
|
||||||
SplitString(receiveData, INDEX_SEP, 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) {
|
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) {
|
public OnSocketError(Handle:socketl, const errorType, const errorNum,any:arg) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
public void EventWinnerTeam(Handle:event, char[] prefix, char[] buf, int buflen){
|
public void EventWinnerTeam(Handle:event, char[] prefix, char[] buf, int buflen){
|
||||||
new team_id = GetEventInt(event, "winner");
|
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){
|
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];
|
new String:sname[SNAME_LEN];
|
||||||
ConVar servername = FindConVar("hostname");
|
ConVar servername = FindConVar("hostname");
|
||||||
servername.GetString(sname,SNAME_LEN);
|
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,")","");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user