fixed errors
How to use dbi:
http://forums.alliedmods.net/showthread.php?p=24962
You can also use sqlx isntead of dbi:
http://forums.alliedmods.net/showthread.php?t=46779
Next time when you get error on some function, check it in
http://www.amxmodx.org/funcwiki.php
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <dbi>
#define PLUGIN "Plugin"
#define VERSION "1.0"
#define AUTHOR "CipryXXX"
new Sql:connect
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
set_task(0.1,"conexiune")
set_task(1.0,"punish")
register_concmd("amx_insert_nick","insert",ADMIN_LEVEL_C,"Inserts a players nickname in the punish user database")
}
public insert(id)
{
new name[100]
new charname
charname = get_user_name(id,name,99)
if (connect == SQL_FAILED)
{
return PLUGIN_HANDLED;
}
else
{
new Result:result = dbi_query(connect, "INSERT INTO user (nume) VALUES ('%s')",charname)
if(result == RESULT_FAILED)
{
log_amx("[MySQL] Coud not insert username in data base!!")
}
else
{
return PLUGIN_HANDLED;
}
}
return PLUGIN_HANDLED;
}
public conexiune()
{
new error[255]
connect = dbi_connect("localhost","root","","ban",error,254)
if(connect==SQL_FAILED)
{
log_amx("[MySQL] SQL Connection Failed = %s", error)
}
}
public punish(id)
{
if (connect == SQL_FAILED)
{
return PLUGIN_HANDLED;
}
else
{
new name[100]
new charname
charname = get_user_name(id,name,99)
new Result:result = dbi_query(connect, "SELECT nume FROM user WHERE nume = '%s'",charname)
if(result == RESULT_FAILED)
{
log_amx("[MySQL] Select username failed!!")
}
else
{
set_user_health(id,1) //not finished.
}
}
return PLUGIN_HANDLED;
}
__________________