Skip to content

Commit

Permalink
Merge pull request #50 from ShadowsAdi/general-improvements
Browse files Browse the repository at this point in the history
General code improvements and fixes
  • Loading branch information
ShadowsAdi authored Sep 6, 2024
2 parents 5de6fc7 + 86ed549 commit f7b9e4c
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 63 deletions.
26 changes: 26 additions & 0 deletions addons/amxmodx/data/lang/csgor_language.txt
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,19 @@ CSGOR_GIVEAWAY_CLOSED = Giveaway-ul este ^4inchis ^1pentru moment.
CSGOR_LOADING_DATA = Datele tale sunt in curs de ^4incarcare^1.
CSGOR_DATA_LOADED = Datele tale au fost ^4incarcate cu succes^1.

CSGOR_ADMIN_CHANGE_X_NICK = Adminul ^4%s^1 a schimbat numele lui ^4%s^1 in ^4%s^1.
CSGOR_CHANGED_NICK = Adminul ^4%s^1 ti-a schimbat numele in ^4%s^1.

CSGOR_T_PASSWORD_SHORT = Parola %s este prea scurta!

CSGOR_ERROR_QUERYING = Eroare in interogarea bazei de date!
CSGOR_INVALID_ARGUMENT = Argumentul %d este invalid: %s

CSGOR_ACCOUNT_RESET = Contul %s a fost resetat
CSGOR_ACCOUNT_REMOVED = Contul %s a fost sters
CSGOR_ACCOUNT_RESET_ITEM = Contului %s i-a fost resetat %s
CSOGR_ACCOUNT_NOT_FOUND = Contul %s nu a fost gasit!

[en]
CSGOR_NO_DROP_SKINS = There are no drop type skins!
CSGOR_NO_CRAFT_SKINS = There are no craft type skins!
Expand Down Expand Up @@ -614,3 +627,16 @@ CSGOR_GIVEAWAY_CLOSED = Giveaway is ^4closed ^1for now.

CSGOR_LOADING_DATA = Your account is being ^4loaded^1 please wait.
CSGOR_DATA_LOADED = Your data has been ^4successfully loaded^1.

CSGOR_ADMIN_CHANGE_X_NICK = Admin ^4%s^1 has changed ^4%s^1's name in ^4%s^1.
CSGOR_CHANGED_NICK = Admin ^4%s^1 has changed your name in ^4%s^1.

CSGOR_T_PASSWORD_SHORT = The password %s is too short!

CSGOR_ERROR_QUERYING = Error querying the database!
CSGOR_INVALID_ARGUMENT = Invalid argument number %d: %s

CSGOR_ACCOUNT_RESET = Account %s has been reset
CSGOR_ACCOUNT_REMOVED = Account %s has been removed
CSGOR_ACCOUNT_RESET_ITEM = Account's %s got %s reset
CSOGR_ACCOUNT_NOT_FOUND = Account %s has not been found!
202 changes: 139 additions & 63 deletions addons/amxmodx/scripting/csgo_remake.sma
Original file line number Diff line number Diff line change
Expand Up @@ -10196,7 +10196,7 @@ public concmd_finddata(id, level, cid)
if(!SQL_Execute(iQuery))
{
SQL_QueryError(iQuery, g_szSqlError, charsmax(g_szSqlError))
log_to_file("csgo_remake_errors.log", "test %s", g_szSqlError)
log_to_file("csgo_remake_errors.log", "SQL Error: %s", g_szSqlError)
SQL_FreeHandle(iQuery)
}

Expand All @@ -10218,7 +10218,7 @@ public concmd_finddata(id, level, cid)
if(!SQL_Execute(iQuery))
{
SQL_QueryError(iQuery, g_szSqlError, charsmax(g_szSqlError))
log_to_file("csgo_remake_errors.log", "test2 %s", g_szSqlError)
log_to_file("csgo_remake_errors.log", "%s", g_szSqlError)
}

if(SQL_NumResults(iQuery) > 0)
Expand Down Expand Up @@ -10257,81 +10257,121 @@ public concmd_resetdata(id, level, cid)
log_to_file("csgor_debug_logs.log", "concmd_resetdata()")
#endif

if (!cmd_access(id, level, cid, 3, false) || !is_user_connected(id))
if (!cmd_access(id, level, cid, 3, false))
return PLUGIN_HANDLED

new arg1[32]
new arg2[4]
new arg3[17]
read_argv(1, arg1, charsmax(arg1))
read_argv(2, arg2, charsmax(arg2))
// TODO: REWORK FOR SQL
/*

new type = str_to_num(arg2)
new szQuery[200]

if (g_Vault == INVALID_HANDLE)
new Handle:iQuery = SQL_PrepareQuery(g_iSqlConnection, "SELECT * FROM `csgor_data` WHERE `Name` = ^"%s^"", arg1)
if(!SQL_Execute(iQuery))
{
console_print(id, "%s Reading from vault has failed !", CSGO_TAG)
return PLUGIN_HANDLED
SQL_QueryError(iQuery, g_szSqlError, charsmax(g_szSqlError))
log_to_file("csgo_remake_errors.log", "SQL Error: %s", g_szSqlError)
}

new g_szData[MAX_SKINS * 3 + 94]
new g_iWeapszBuffer[MAX_SKINS * 2]
new Timestamp
if(!SQL_NumResults(iQuery))
{
console_print(id, "%s %L", CSGO_TAG, id, "CSOGR_ACCOUNT_NOT_FOUND", arg1)
return PLUGIN_HANDLED
}

if (nvault_lookup(g_Vault, arg1, g_szData, charsmax(g_szData), Timestamp))
switch(type)
{
new index = get_user_index(arg1)
if(index)
case 0:
{
g_bLogged[index] = false
formatex(szQuery, charsmax(szQuery), "DELETE FROM `csgor_skins` WHERE `Name` = ^"%s^";", arg1)
}
if (0 < type)
case 1:
{
nvault_remove(g_Vault, arg1)
nvault_remove(g_nVault, arg1)
nvault_remove(g_sVault, arg1)
nvault_remove(g_pVault, arg1)
ResetData(id, true)
console_print(id, "%s The account has been removed: %s", CSGO_TAG, arg1)
return PLUGIN_HANDLED
formatex(szQuery, charsmax(szQuery), "SET SQL_SAFE_UPDATES = 0; \
DELETE FROM `csgor_data` WHERE `Name` = ^"%s^"; \
DELETE FROM `csgor_skins` WHERE `Name` = ^"%s^"; \
SET SQL_SAFE_UPDATES = 1;", arg1, arg1)
}
case 2:
{
read_argv(3, arg3, charsmax(arg3))

new infoBuffer[MAX_SKIN_NAME]
new skinBuffer[MAX_SKINS]
new password[16]
if(strlen(arg3) < 4)
{
console_print(id, "%L", id, "CSGOR_INVALID_ARGUMENT", 3, arg3)
return PLUGIN_HANDLED
}

strtok(g_szData, password, charsmax(password), g_szData, charsmax(g_szData), '=', 0)
formatex(szQuery, charsmax(szQuery), "UPDATE `csgor_data` SET `%s`= 0 WHERE `Name` = ^"%s^";", arg3, arg1)
}
}

formatex(infoBuffer, charsmax(infoBuffer), "%s=,;%d,%d,%d,%d,%d,%d", password, 0, 0, 0, 0, 0, 0)
formatex(g_iWeapszBuffer, charsmax(g_iWeapszBuffer), "%d", 0)
new index = get_user_index(arg1)
if(index)
g_bLogged[index] = false

for (new i = 1; i < MAX_SKINS; i++)
{
format(g_iWeapszBuffer, charsmax(g_iWeapszBuffer), "%s,0", g_iWeapszBuffer)
}
new szData[MAX_NAME_LENGTH + 5 + 6 + 18]
formatex(szData, charsmax(szData), "%s;%s#%s=%d", arg1, arg2, arg3, id)

formatex(skinBuffer, charsmax(skinBuffer), "%d", 0)
SQL_ThreadQuery(g_hSqlTuple, "QueryResetData", szQuery, szData, charsmax(szData))

for (new i = 2; i <= 30; i++)
return PLUGIN_HANDLED
}

public QueryResetData(iFailState, Handle:iQuery, Error[], Errcode, szData[], iSize, Float:flQueueTime)
{
switch(iFailState)
{
case TQUERY_CONNECT_FAILED:
{
format(skinBuffer, charsmax(skinBuffer), "%s,0", skinBuffer)
log_to_file("csgo_remake_errors.log", "[SQL Error] Connection failed (%i): %s", Errcode, Error)
}
case TQUERY_QUERY_FAILED:
{
log_to_file("csgo_remake_errors.log", "[SQL Error] Query failed (%i): %s", Errcode, Error)
}
}

formatex(g_szData, charsmax(g_szData), "%s*%s#%s", infoBuffer, g_iWeapszBuffer, skinBuffer)
nvault_set(g_Vault, arg1, g_szData)
new arg1[MAX_NAME_LENGTH], arg2[4], arg3[17], index[3], id

console_print(id, "%s The account has been reseted: %s", CSGO_TAG, arg1)
strtok(szData, arg1, charsmax(arg1), szData, iSize, ';')

ResetData(id, true)
_Save(index)
strtok(szData, arg2, charsmax(arg2), szData, iSize, '#')

strtok(szData, arg3, charsmax(arg3), szData, iSize, '=')

strtok(szData, index, charsmax(index), szData, iSize)

id = str_to_num(index)

if(iFailState)
{
console_print(id, "%s %L", CSGO_TAG, LANG_SERVER, "CSGOR_ERROR_QUERYING")
return
}
else

switch(arg2[0])
{
console_print(id, "%s The account was not found: %s", CSGO_TAG, arg1)
}*/
case '0':
{
console_print(id, "%s %L", CSGO_TAG, id, "CSGOR_ACCOUNT_RESET", arg1)
}
case '1':
{
console_print(id, "%s %L", CSGO_TAG, id, "CSGOR_ACCOUNT_REMOVED", arg1)
}
case '2':
{
console_print(id, "%s %L", CSGO_TAG, id, "CSGOR_ACCOUNT_RESET_ITEM", arg1, arg3)
}
}

return PLUGIN_HANDLED
new pid = get_user_index(arg1)
if(pid)
_Load(pid)
}

public concmd_changepass(id, level, cid)
Expand All @@ -10348,30 +10388,65 @@ public concmd_changepass(id, level, cid)
read_argv(1, arg1, charsmax(arg1))
read_argv(2, arg2, charsmax(arg2))

new target = cmd_target(id, arg1, CMDTARGET_ALLOW_SELF)

if (!target)
if (strlen(arg2) < 6)
{
console_print(id, "%s %L", CSGO_TAG, LANG_SERVER, "CSGOR_T_NOT_FOUND", arg1)
console_print(id, "%s %L", CSGO_TAG, LANG_SERVER, "CSGOR_T_PASSWORD_SHORT", arg2)
return PLUGIN_HANDLED
}

new len = strlen(g_szUser_SavedPass[target])

if (len > 6)
new szQuery[95]
formatex(szQuery, charsmax(szQuery), "SELECT `Password` FROM `csgor_data` WHERE `Name` = ^"%s^";", arg1)

new szData[35 + MAX_NAME_LENGTH]
formatex(szData, charsmax(szData), "%d;%s=%s", id, arg1, arg2)

SQL_ThreadQuery(g_hSqlTuple, "QueryPlayerChangePW", szQuery, szData, charsmax(szData))

return PLUGIN_HANDLED
}

public QueryPlayerChangePW(iFailState, Handle:iQuery, Error[], Errcode, szData[], iSize, Float:flQueueTime)
{
switch(iFailState)
{
copy(g_szUser_SavedPass[target], charsmax(g_szUser_SavedPass[]), arg2)
console_print(id, "%s %L", CSGO_TAG, LANG_SERVER, "CSGOR_PASSWORD_CHANGED", target, arg2)
client_print_color(target, print_chat, "^4%s ^1%L", CSGO_TAG, LANG_SERVER, "CSGOR_ADMIN_CHANGED_PASSWORD", g_szName[id], arg2)
case TQUERY_CONNECT_FAILED:
{
log_to_file("csgo_remake_errors.log", "[SQL Error] Connection failed (%i): %s", Errcode, Error)
}
case TQUERY_QUERY_FAILED:
{
log_to_file("csgo_remake_errors.log", "[SQL Error] Query failed (%i): %s", Errcode, Error)
}
}
else

new arg1[MAX_NAME_LENGTH], arg2[32], index[3], id

strtok(szData, index, charsmax(index), szData, iSize, ';')

id = str_to_num(index)

strtok(szData, arg1, charsmax(arg1), szData, iSize, '=')

strtok(szData, arg2, charsmax(arg2), szData, iSize)

if(iFailState)
{
console_print(id, "%s %L", CSGO_TAG, LANG_SERVER, "CSGOR_T_NOT_FOUND_IN_DBASE", target)
console_print(id, "%s %L", CSGO_TAG, LANG_SERVER, "CSGOR_ERROR_QUERYING")
return
}

_Save(target)
console_print(id, "%s %L", CSGO_TAG, LANG_SERVER, "CSGOR_PASSWORD_CHANGED", arg1, arg2)

return PLUGIN_HANDLED
new target = get_user_index(arg1)
if(is_user_connected(target))
{
client_print_color(target, print_chat, "^4%s ^1%L", CSGO_TAG, LANG_SERVER, "CSGOR_ADMIN_CHANGED_PASSWORD", id ? g_szName[id] : "Administrator", arg2)
}

new szQuery[95]
formatex(szQuery, charsmax(szQuery), "UPDATE `csgor_data` SET `Password` = ^"%s%^" WHERE `Name` = ^"%s^";", arg2, arg1)

SQL_ThreadQuery(g_hSqlTuple, "QueryHandler", szQuery)
}

public concmd_getinfo(id, level, cid)
Expand Down Expand Up @@ -10469,14 +10544,15 @@ public concmd_nick(id, level, cid)
}

g_eEnumBooleans[player][IsChangeNotAllowed] = true
set_user_info(player, "name", arg2)

client_print_color(0, print_chat, "^4%s^1 %L", CSGO_TAG, LANG_SERVER, "CSGOR_ADMIN_CHANGE_X_NICK", g_szName[id], g_szName[player], arg2)

set_task(0.5, "task_Reset_Name", id + TASK_RESET_NAME)

console_print(id, "%s %L", CSGO_TAG, LANG_SERVER, "CSGOR_CHANGED_NICK", g_szName[player], arg2)

copy(g_szName[player], charsmax(g_szName[]), arg2)

set_task(0.5, "task_Reset_Name", id + TASK_RESET_NAME)

return PLUGIN_HANDLED
}

Expand Down

0 comments on commit f7b9e4c

Please sign in to comment.