Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions addons/amxmodx/configs/plugins/csgor/csgo_remake.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ csgor_author "Shadows Adi"
// Minimum: "0.000000"
csgor_prunedays "60"

//Database Affinity
// "mysql" - Use MySQL Database || "sqlite" - Use SQLite Database
// -
// Default: "sqlite"
csgor_dbase_affinity "sqlite"

//Database Host
// -
// Default: "localhost"
Expand Down
20 changes: 17 additions & 3 deletions addons/amxmodx/scripting/csgo_remake.sma
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ enum _:EnumCvars
iHMaxChance,
iKMinChance,
iKMaxChance,
szSqlAffinity[10],
szSqlHost[32],
szSqlUsername[32],
szSqlPassword[32],
Expand Down Expand Up @@ -457,6 +458,9 @@ public plugin_init()

new pcvar = create_cvar("csgor_author", "Shadows Adi", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY, "DO NOT MODIFY!" )

pcvar = create_cvar("csgor_dbase_affinity", "sqlite", FCVAR_SPONLY | FCVAR_PROTECTED, "Database Affinity^n^"mysql^" - Use MySQL Database || ^"sqlite^" - Use SQLite Database")
bind_pcvar_string(pcvar, g_iCvars[szSqlAffinity], charsmax(g_iCvars[szSqlAffinity]))

pcvar = create_cvar("csgor_dbase_host", "localhost", FCVAR_SPONLY | FCVAR_PROTECTED, "Database Host")
bind_pcvar_string(pcvar, g_iCvars[szSqlHost], charsmax(g_iCvars[szSqlHost]))

Expand Down Expand Up @@ -738,6 +742,7 @@ public plugin_cfg()

public DatabaseConnect()
{
SQL_SetAffinity(g_iCvars[szSqlAffinity])
g_hSqlTuple = SQL_MakeDbTuple(g_iCvars[szSqlHost], g_iCvars[szSqlUsername], g_iCvars[szSqlPassword], g_iCvars[szSqlDatabase])

new iError
Expand All @@ -755,7 +760,7 @@ public DatabaseConnect()

new szQueryData[600]
formatex(szQueryData, charsmax(szQueryData),"CREATE TABLE IF NOT EXISTS `csgor_data` \
(`ID` INT NOT NULL AUTO_INCREMENT,\
(`ID` INTEGER PRIMARY KEY %s,\
`Name` VARCHAR(32) NOT NULL,\
`SteamID` VARCHAR(32) NOT NULL,\
`Last IP` VARCHAR(19) NOT NULL,\
Expand All @@ -768,8 +773,7 @@ public DatabaseConnect()
`Cases` INT(12) NOT NULL,\
`Kills` INT(12) NOT NULL,\
`Rank` INT(2) NOT NULL,\
`Bonus Timestamp` INT NOT NULL,\
PRIMARY KEY(ID, Name));")
`Bonus Timestamp` INT NOT NULL);", g_iCvars[szSqlAffinity][0] == 's' ? "": "AUTO_INCREMENT")

new Handle:iQueries = SQL_PrepareQuery(g_iSqlConnection, szQueryData)

Expand All @@ -779,6 +783,16 @@ public DatabaseConnect()
log_amx(g_szSqlError)
}

formatex(szQueryData, charsmax(szQueryData), "CREATE UNIQUE INDEX IF NOT EXISTS idx_csgor_name ON csgor_data (Name);")

iQueries = SQL_PrepareQuery(g_iSqlConnection, szQueryData)

if(!SQL_Execute(iQueries))
{
SQL_QueryError(iQueries, g_szSqlError, charsmax(g_szSqlError))
log_amx(g_szSqlError)
}

formatex(szQueryData, charsmax(szQueryData), "SELECT `SteamID` FROM `csgor_data`")

iQueries = SQL_PrepareQuery(g_iSqlConnection, szQueryData)
Expand Down
9 changes: 5 additions & 4 deletions addons/amxmodx/scripting/csgor_games.sma
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,14 @@ public QueryPromocodeUses(iFailState, Handle:iQuery, Error[], Errcode, szData[],

InsertTable()
{
new szQueryData[256]
new szQueryData[256], szSqlAffinity[10]
get_cvar_string("csgor_dbase_affinity", szSqlAffinity, charsmax(szSqlAffinity))
SQL_SetAffinity(szSqlAffinity)
formatex(szQueryData, charsmax(szQueryData), "CREATE TABLE IF NOT EXISTS `csgor_promocodes` \
(`ID` INT NOT NULL AUTO_INCREMENT,\
(`ID` INTEGER PRIMARY KEY %s,\
`Name` VARCHAR(32) NOT NULL,\
`Auth` VARCHAR(32) NOT NULL,\
`Promocode` TEXT NOT NULL,\
PRIMARY KEY(ID));")
`Promocode` TEXT NOT NULL);", szSqlAffinity[0] == 's' ? "": "AUTO_INCREMENT")

new Handle:iQuery = SQL_PrepareQuery(g_iSqlConnection, szQueryData)

Expand Down
5 changes: 5 additions & 0 deletions addons/amxmodx/scripting/csgor_mvp.sma
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,11 @@ DetectSaveType()
}
}

new szAffinity[10]
get_cvar_string("csgor_dbase_affinity", szAffinity, charsmax(szAffinity))

SQL_SetAffinity(szAffinity)

g_hSqlTuple = SQL_MakeDbTuple(g_eDBConfig[MYSQL_HOST], g_eDBConfig[MYSQL_USER], g_eDBConfig[MYSQL_PASS], g_eDBConfig[MYSQL_DB])

new iError
Expand Down
2 changes: 1 addition & 1 deletion addons/amxmodx/scripting/include/csgo_remake.inc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define SetPlayerBit(%0,%1,%2) ( IsPlayer(%1,%2) && ( %0 |= ( 1 << ( %1 & 31 ) ) ) )
#define ClearPlayerBit(%0,%1) %0 &= ~( 1 << ( %1 & 31 ) )

#define VERSION "3.0.2"
#define VERSION "3.0.3"

enum
{
Expand Down
Loading