@@ -28,6 +28,7 @@ new Queue: g_queueLoad = Invalid_Queue,
2828 Queue: g_queueSave = Invalid_Queue
2929
3030new g_serverID = - 1
31+ new g_gamecmsAdminId[MAX_PLAYERS + 1 ]
3132
3233new ca_storage_host[64 ],
3334 ca_storage_user[128 ],
@@ -80,6 +81,14 @@ public plugin_cfg() {
8081 RegisterForwards ()
8182}
8283
84+ public client_putinserver (id) {
85+ GameCMS_GetAdminID (id)
86+ }
87+
88+ public client_disconnected (id) {
89+ g_gamecmsAdminId[id] = 0
90+ }
91+
8392Register_CVars () {
8493 bind_pcvar_string (create_cvar (" ca_storage_host" , " 127.0.0.1" , FCVAR_PROTECTED,
8594 .description = " GameCMS MySQL database host address"
@@ -167,7 +176,7 @@ Storage_Save(const name[], const authID[], const IP[],
167176 return
168177 }
169178
170- #pragma unused adminIP, adminAuthID, IP
179+ #pragma unused adminIP, IP
171180 new name_safe[MAX_NAME_LENGTH * 2 ];
172181 SQL_QuoteString (Empty_Handle, name_safe, charsmax (name_safe), name);
173182
@@ -177,6 +186,13 @@ Storage_Save(const name[], const authID[], const IP[],
177186 new adminName_safe[MAX_NAME_LENGTH * 2 ];
178187 SQL_QuoteString (Empty_Handle, adminName_safe, charsmax (adminName_safe), adminName);
179188
189+
190+ new admin_id = 0
191+ new admin = find_player_ex ((FindPlayer_MatchUserId | FindPlayer_ExcludeBots), adminAuthID)
192+ if (admin) {
193+ admin_id = g_gamecmsAdminId[admin]
194+ }
195+
180196 // TODO : Optimize this EPIC QUERY
181197 formatex (g_query, charsmax (g_query), " INSERT INTO %s " , SQL_TBL_GAGS); {
182198 strcat (g_query, " ( authid,name,created," , charsmax (g_query))
@@ -191,7 +207,7 @@ Storage_Save(const name[], const authID[], const IP[],
191207 strcat (g_query, fmt (" %i ," , expireAt), charsmax (g_query))
192208 strcat (g_query, fmt (" (%i - UNIX_TIMESTAMP(NOW())) / 60," , expireAt), charsmax (g_query))
193209 strcat (g_query, fmt (" '%s '," , reason_safe), charsmax (g_query))
194- strcat (g_query, fmt (" '%i '," , 1 /* JUST A 1 AND NOTHING ELSE!!! */ ), charsmax (g_query))
210+ strcat (g_query, fmt (" '%i '," , admin_id ), charsmax (g_query))
195211 strcat (g_query, fmt (" '%s '," , adminName_safe), charsmax (g_query))
196212 strcat (g_query, fmt (" '%i '," , g_serverID), charsmax (g_query))
197213 strcat (g_query, fmt (" '%s '," , adminName_safe), charsmax (g_query))
@@ -464,3 +480,32 @@ static stock CAGAGFlags_to_GCMS_Flags(const gag_flags_s: flags) {
464480
465481 return GCMS_FLAG_NONE;
466482}
483+
484+ GameCMS_GetAdminID (const id) {
485+ new authID[MAX_AUTHID_LENGTH], name[MAX_NAME_LENGTH]
486+ get_user_authid (id, authID, charsmax (authID))
487+ get_user_name (id, name, charsmax (name))
488+
489+ formatex (g_query, charsmax (g_query), " SELECT id FROM admins WHERE name = '%s ' or name = '%s ' LIMIT 1;" ,
490+ authID, name
491+ )
492+
493+ new data[1 ]; data[0 ] = id
494+ SQL_ThreadQuery (g_tuple, " handle_GetAdminID" , g_query, data, sizeof (data))
495+ }
496+
497+ public handle_GetAdminID (failstate, Handle: query, error[], errnum, data[], size, Float: queuetime) {
498+ enum { col_id }
499+
500+ if (IsSQLQueryFailed (failstate, query, error, errnum)) {
501+ return
502+ }
503+
504+ new bool: found = bool: (SQL_NumResults (query) != 0 )
505+ if (! found) {
506+ return
507+ }
508+
509+ g_gamecmsAdminId[data[0 ]] = SQL_ReadResult (query, col_id)
510+ CA_Log (logLevel_Debug, " Found admin `% N` in gameCMS DB. admins.id=%i " , data[0 ], g_gamecmsAdminId[data[0 ]])
511+ }
0 commit comments