Skip to content

Commit 340638e

Browse files
committed
Release 1.0, bug fixes
1 parent 0d50db3 commit 340638e

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

plugins/WarnSystem.smx

54 Bytes
Binary file not shown.

scripting/WarnSystem/commands.sp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public Action Command_WarnPlayer(int iClient, int iArgs)
2121
Format(sReason, sizeof(sReason), "%s %s", sReason, sBuffer);
2222
}
2323
int iTarget = FindTarget(iClient, sArgument, true, true);
24-
WarnPlayer(iClient, iTarget, sReason);
24+
if (iTarget)
25+
WarnPlayer(iClient, iTarget, sReason);
2526
return Plugin_Handled;
2627
}
2728

@@ -40,7 +41,8 @@ public Action Command_UnWarnPlayer(int iClient, int iArgs)
4041
Format(sReason, sizeof(sReason), "%s %s", sReason, sBuffer);
4142
}
4243
int iTarget = FindTarget(iClient, sArgument, true, true);
43-
UnWarnPlayer(iClient, iTarget, sReason);
44+
if (iTarget)
45+
UnWarnPlayer(iClient, iTarget, sReason);
4446
return Plugin_Handled;
4547
}
4648

@@ -64,7 +66,8 @@ public Action Command_WarnReset(int iClient, int iArgs)
6466
Format(sReason, sizeof(sReason), "%s %s", sReason, sBuffer);
6567
}
6668
int iTarget = FindTarget(iClient, sArgument, true, true);
67-
ResetPlayerWarns(iClient, iTarget, sReason);
69+
if (iTarget)
70+
ResetPlayerWarns(iClient, iTarget, sReason);
6871
return Plugin_Handled;
6972
}
7073

@@ -83,6 +86,7 @@ public Action Command_CheckWarnPlayer(int iClient, int iArgs)
8386
char sArgument[32];
8487
GetCmdArg(1, sArgument, sizeof(sArgument));
8588
int iTarget = FindTarget(iClient, sArgument, true, true);
86-
CheckPlayerWarns(iClient, iTarget);
89+
if (iTarget)
90+
CheckPlayerWarns(iClient, iTarget);
8791
return Plugin_Handled;
8892
}

scripting/WarnSystem/database.sp

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
int g_iServerID = 0;
22

3-
char g_sSQL_CreateTable_SQLite[] = "CREATE TABLE IF NOT EXISTS WarnSystem (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, serverid INTEGER(12) NOT NULL default 0, client VARCHAR(128) NOT NULL default '', clientid INTEGER(32) NOT NULL default '0', admin VARCHAR(128) NOT NULL default '', adminid INTEGER(32) NOT NULL default '0', reason VARCHAR(64) NOT NULL default '', time INTEGER(32) NOT NULL default 0, expired INTEGER(1) NOT NULL default 0);",
4-
g_sSQL_CreateTable_MySQL[] = "CREATE TABLE IF NOT EXISTS WarnSystem (id int(12) NOT NULL AUTO_INCREMENT, serverid int(12) NOT NULL default 0, client VARCHAR(128) NOT NULL default '', clientid int(64) NOT NULL default '0', admin VARCHAR(128) NOT NULL default '', adminid int(64) NOT NULL default '0', reason VARCHAR(64) NOT NULL default '', time int(12) NOT NULL default 0, expired int(1) NOT NULL default 0, PRIMARY KEY (id)) CHARSET=utf8 COLLATE utf8_general_ci;",
5-
g_sSQL_CreateTableServers[] = "CREATE TABLE IF NOT EXISTS WarnSystem_Servers (sid int(12) NOT NULL AUTO_INCREMENT, address VARCHAR(64) NOT NULL default '', PRIMARY KEY (id)) CHARSET=utf8 COLLATE utf8_general_ci;",
6-
g_sSQL_GetServerID[] = "SELECT sid FROM WarnSystem_Servers WHERE address = '%s';",
7-
g_sSQL_SetServerID[] = "INSERT INTO WarnSystem_Servers (address) VALUES ('%s');",
8-
g_sSQL_WarnPlayer[] = "INSERT INTO WarnSystem (serverid, client, clientid, admin, adminid, reason, time) VALUES ('%i', '%s', '%i', '%s', '%i', '%s', '%i');",
9-
g_sSQL_DeleteWarns[] = "DELETE FROM WarnSystem WHERE clientid = '%i' AND serverid='%i';",
10-
g_sSQL_SetExpired[] = "UPDATE WarnSystem SET expired = '1' WHERE clientid = '%i' AND serverid='%i';",
11-
g_sSQL_SelectWarns[] = "SELECT id FROM WarnSystem WHERE clientid='%i' AND serverid='%i' AND expired = '0' ORDER BY id DESC LIMIT 1;",
12-
g_sSQL_UnwarnPlayer[] = "DELETE FROM WarnSystem WHERE id = '%i' AND serverid='%i';",
13-
g_sSQL_CheckPlayerWarns[] = "SELECT client,admin,reason,time,expired FROM WarnSystem WHERE clientid='%i' AND serverid='%i';",
3+
char g_sSQL_CreateTable_SQLite[] = "CREATE TABLE IF NOT EXISTS `WarnSystem` (`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `serverid` INTEGER(12) NOT NULL default 0, `client` VARCHAR(128) NOT NULL default '', `clientid` INTEGER(32) NOT NULL default '0', `admin` VARCHAR(128) NOT NULL default '', `adminid` INTEGER(32) NOT NULL default '0', `reason` VARCHAR(64) NOT NULL default '', `time` INTEGER(32) NOT NULL default 0, `expired` INTEGER(1) NOT NULL default 0);",
4+
g_sSQL_CreateTable_MySQL[] = "CREATE TABLE IF NOT EXISTS `WarnSystem` (`id` int(12) NOT NULL AUTO_INCREMENT, `serverid` int(12) NOT NULL default 0, `client` VARCHAR(128) NOT NULL default '', `clientid` int(64) NOT NULL default '0', `admin` VARCHAR(128) NOT NULL default '', `adminid` int(64) NOT NULL default '0', `reason` VARCHAR(64) NOT NULL default '', `time` int(12) NOT NULL default 0, `expired` int(1) NOT NULL default 0, PRIMARY KEY (id)) CHARSET=utf8 COLLATE utf8_general_ci;",
5+
g_sSQL_CreateTableServers[] = "CREATE TABLE IF NOT EXISTS `WarnSystem_Servers` (`sid` int(12) NOT NULL AUTO_INCREMENT, `address` VARCHAR(64) NOT NULL default '', PRIMARY KEY (id)) CHARSET=utf8 COLLATE utf8_general_ci;",
6+
g_sSQL_GetServerID[] = "SELECT `sid` FROM `WarnSystem_Servers` WHERE `address` = '%s';",
7+
g_sSQL_SetServerID[] = "INSERT INTO `WarnSystem_Servers` (`address`) VALUES ('%s');",
8+
g_sSQL_WarnPlayer[] = "INSERT INTO `WarnSystem` (`serverid`, `client`, `clientid`, `admin`, `adminid`, `reason`, `time`) VALUES ('%i', '%s', '%i', '%s', '%i', '%s', '%i');",
9+
g_sSQL_DeleteWarns[] = "DELETE FROM `WarnSystem` WHERE `clientid` = '%i' AND `serverid` = '%i';",
10+
g_sSQL_SetExpired[] = "UPDATE `WarnSystem` SET `expired` = '1' WHERE `clientid` = '%i' AND `serverid` = '%i';",
11+
g_sSQL_SelectWarns[] = "SELECT `id` FROM `WarnSystem` WHERE `clientid` = '%i' AND `serverid` = '%i' AND `expired` = '0' ORDER BY `id` DESC LIMIT 1;",
12+
g_sSQL_UnwarnPlayer[] = "DELETE FROM `WarnSystem` WHERE `id` = '%i' AND `serverid` = '%i';",
13+
g_sSQL_CheckPlayerWarns[] = "SELECT `client`,`admin`,`reason`,`time`,`expired` FROM `WarnSystem` WHERE `clientid` = '%i' AND `serverid` = '%i';",
1414
g_sClientIP[MAXPLAYERS+1][32],
1515
g_sAddress[24];
1616

@@ -322,7 +322,6 @@ public void CheckPlayerWarns(int iAdmin, int iClient)
322322
WritePackCell(hCheckData, GetClientUserId(iClient));
323323
ResetPack(hCheckData);
324324

325-
LogWarnings("CheckPlayerWarns Query: %s", dbQuery);
326325
g_hDatabase.Query(SQL_CheckPlayerWarns, dbQuery, hCheckData);
327326
//mb print only count of warns?
328327
}
@@ -338,27 +337,27 @@ public void SQL_CheckPlayerWarns(Database hDatabase, DBResultSet hDatabaseResult
338337

339338
int iAdmin, iClient;
340339

341-
if (!hDatabaseResults.RowCount)
342-
{
343-
CPrintToChat(iAdmin, " %t %t", "WS_Prefix", "WS_NotWarned", iClient);
344-
return;
345-
}
346-
347340
if(hCheckData)
348341
{
349342
iAdmin = GetClientOfUserId(ReadPackCell(hCheckData));
350343
iClient = GetClientOfUserId(ReadPackCell(hCheckData));
351344
CloseHandle(hCheckData);
352345
} else return;
353346

347+
if (!hDatabaseResults.RowCount)
348+
{
349+
CPrintToChat(iAdmin, " %t %t", "WS_Prefix", "WS_NotWarned", iClient);
350+
return;
351+
}
352+
354353
CPrintToChat(iAdmin, " %t %t", "WS_Prefix", "WS_Console", iClient, g_iWarnings[iClient]);
355354
CPrintToChat(iAdmin, " %t %t", "WS_Prefix", "See console for output");
356355

357356
char sClient[64], sAdmin[64], sReason[64], sTimeFormat[32];
358357
int iDate, iExpired;
359358
PrintToConsole(iAdmin, "");
360359
PrintToConsole(iAdmin, "");
361-
PrintToConsole(iAdmin, "%-18s %-18s %-26s %-26s %-3s", "Player", "Admin", "Date", "Reason", "Expired");
360+
PrintToConsole(iAdmin, "%-18s %-18s %-20s %-26s %-1s", "Player", "Admin", "Date", "Reason", "Expired");
362361
PrintToConsole(iAdmin, "-----------------------------------------------------------------------------------------------------------");
363362
//Ya, nice output
364363

@@ -371,8 +370,11 @@ public void SQL_CheckPlayerWarns(Database hDatabase, DBResultSet hDatabaseResult
371370
iExpired = hDatabaseResults.FetchInt(4);
372371

373372
FormatTime(sTimeFormat, sizeof(sTimeFormat), "%Y-%m-%d %X", iDate);
374-
PrintToConsole(iAdmin, "%-18s %-18s %-26s %-26s %-3i", sClient, sAdmin, sTimeFormat, sReason, iExpired);
373+
PrintToConsole(iAdmin, "%-18s %-18s %-20s %-26s %-1i", sClient, sAdmin, sTimeFormat, sReason, iExpired);
375374
}
375+
PrintToConsole(iAdmin, "-----------------------------------------------------------------------------------------------------------");
376+
PrintToConsole(iAdmin, "");
377+
PrintToConsole(iAdmin, "");
376378
}
377379

378380
public void SQL_CheckError(Database hDatabase, DBResultSet hDatabaseResults, const char[] sError, any data)

0 commit comments

Comments
 (0)