I need help to get my script to sort out the admins with ADMIN_RESRVATION access.
The script checks with a database if he/she is an admin and if they are, it will change their names to the registerd name in the database, but I have guest admins that I dont want to be involved with this... only our clanmembers with ADMIN_RESRVATION access have to change their names.
This script allows members to change name during the played round, but changes names back on respawn or map change. That allows our members to change namn to say sorry or something like that during the round.
It is the part that checks the admin access that doesn't work as it should...
Code:
if (!equal(oldname, amxadminsname) && !access(id,ADMIN_RESERVATION))
Code:
#include <amxmodx>
#include <dbi>
#include <amxmisc>
new Sql:mysql
//------------------------- Author -------------------------------------------------------------
public plugin_init() {
register_plugin("admin namecheck", "1.00", "preppen, ProTeuS")
set_task(1.0, "mysql_init")
register_event("ResetHUD", "round_start", "b")
register_clcmd("access","user_access",ADMIN_RESERVATION,"Description of the command")
}
//------------------------- Database connection ------------------------------------------------
public mysql_init()
{
mysql = dbi_connect("localhost", "root", "******", "amx")
if (mysql < SQL_OK) {
new err[255]
new errNum = dbi_error(mysql, err, 254)
server_print("error1: %s|%d", err, errNum)
return 1
}
server_print("Connection handle: %d", mysql)
return PLUGIN_CONTINUE
}
//------------------------- On connect ---------------------------------------------------------
public client_putinserver(id)
{
// Run check nick
check_nick(id)
return PLUGIN_CONTINUE
}
//------------------------- On round start -----------------------------------------------------
public round_start(id)
{
// Run check nick
check_nick(id)
return PLUGIN_CONTINUE
}
//------------------------- Check user access --------------------------------------------------
public user_access(id)
{
// Run check access
check_nick(id)
return PLUGIN_CONTINUE
}
//------------------------- Check user nick ----------------------------------------------------
public check_nick(userid)
{
// Get user steamid
new steamuserid[32]
get_user_authid(userid, steamuserid, 31)
// Get nick from amx_amxadmins where steamid is the same as steamuserid
new Result:res = dbi_query(mysql, "SELECT * FROM amx_amxadmins WHERE steamid='%s'", steamuserid)
// If the database has rows
if (dbi_num_rows(res) > 0) {
// Set amxadminsname from database
new amxadminsname[32]
dbi_nextrow(res)
dbi_result(res, "nickname", amxadminsname, 31)
// Get current nick
new oldname[32]
get_user_name(userid, oldname, 31)
// If not oldname and amxadminsname are the same
if (!equal(oldname, amxadminsname) && !access(id,ADMIN_RESERVATION))
{
// Set user name to amxadminsname
set_user_info(userid, "name", amxadminsname)
}
}
dbi_free_result(res)
return PLUGIN_CONTINUE
}