Hi, i took this from admin.sma and edited for work in amxbans.
PHP Code:
AddVIP(id)
{
new error[128], errno
new Handle:info = SQL_MakeStdTuple()
new Handle:sql = SQL_Connect(info, errno, error, 127)
if (sql == Empty_Handle)
{
server_print("[AMXX] %L", LANG_SERVER, "SQL_CANT_CON", error)
}
new table[32]
get_cvar_string("amx_sql_table", table, 31)
new Handle:query = SQL_PrepareQuery(sql, "SELECT * FROM `%s` WHERE (`auth` = '%s')", table, auth)
if (!SQL_Execute(query))
{
SQL_QueryError(query, error, 127)
server_print("[AMXX] %L", LANG_SERVER, "SQL_CANT_LOAD_ADMINS", error)
console_print(id, "[AMXX] %L", LANG_SERVER, "SQL_CANT_LOAD_ADMINS", error)
}
else if (SQL_NumResults(query))
{
// up amount of days, need work on it later
console_print(id, "[%s] %s already exists!", PLUGINNAME, auth)
}
else
{
//adding
console_print(id, "Adding to database:^n^"%s^" ^"%s^" ^"%s^"", auth, flags)
new id_what_value, created_what_value, expired_what_value, 10days_seconds
id_what_value = ?
created_what_value = ?
10days_seconds = (10 * 24 * 60 * 60)
expired_what_value = created_what_value + 10days_seconds
SQL_QueryAndIgnore(sql, "REPLACE INTO `%s` (`id`, `username`, `password`, `access, `flags`, `steamid`, `nickname`, `ashow`, `created`, `expired`, `days`) VALUES ('%s', '%s', '', 't', 'ce', '%s', '%s', '1', '%s', '%s', '10')", table, id_what_value, name, auth, name, created_what_value, expired_what_value)
}
SQL_FreeHandle(query)
SQL_FreeHandle(sql)
SQL_FreeHandle(info)
}
But there is 2 things that i dont know.
How to set the correct id?
What value i put in created date?
About created date, the value is all seconds from 1 January 1970 till the moment of being created.
Bah i have no idea how to find that value.
Also, in the case of steam id already in database, how to edit time of admin?
Last: Is this a good method for connect into database or should i use dbi instead?
__________________