Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <dbi>
#define PLUGIN "New Plug-In"
#define VERSION "beta1"
#define AUTHOR "Wonsae"
new has_clothes[33] // Does the player have the clothes item on?
new new_clothes[33][32] // New Model specified
new cur_clothes[33][32] // Clothes Model Stored Here By Items
new old_clothes[33][32] // Old model they had
new default_model[32] = "collector-civilian"
new Sql:dbc
new Result:result
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_srvcmd("item_clothes","item_clothes")
register_concmd("amx_changemodel","changemodel",ADMIN_KICK,"amx_changemodel <name> <model>")
register_concmd("amx_addclothes","admin_addclothes")
}
public plugin_precache()
{
precache_model("models/player/collector-civilian/collector-civilian.mdl")
}
public sql_init()
{
new host[64], username[33], password[32], dbname[32], error[32]
get_cvar_string("economy_mysql_host",host,64)
get_cvar_string("economy_mysql_user",username,32)
get_cvar_string("economy_mysql_pass",password,32)
get_cvar_string("economy_mysql_db",dbname,32)
dbc = dbi_connect(host,username,password,dbname,error,32)
if (dbc == SQL_FAILED)
{
server_print("[ClothesMod] Could Not Connect To SQL Database^n")
}
else
{
server_print("[ClothesMod] Connected To SQL, Have A Nice Day!^n")
}
}
public client_connect(id)
{
client_cmd(id,"model %s",default_model)
}
public client_infochanged(id){
get_user_info(id,"model",new_clothes[id],31)
if(has_clothes[id] == 0){
set_user_info(id,"model",default_model)
client_print(id,print_chat,"[ClothesMod] You may not change your clothes that way")
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public item_clothes(){
new arg[33], arg2[33], id, model
read_argv(1,arg,32)
read_argv(2,arg2,32)
id = str_to_num(arg)
model = str_to_num(arg2)
if(has_clothes[id] == 0){
get_user_info(id,"model",old_clothes[id],31)
set_user_info(id,"model",arg2)
format(cur_clothes[id],31,arg2)
client_print(id,print_chat,"[ClothesMod] You have changed your clothes.")
new name[32]
get_user_name(id,name,31)
client_print(0,print_chat,"[ClothesMod] %s has changed his clothes",name)
has_clothes[id] = 1
}
else
{
set_user_info(id,"model",default_model)
client_print(id,print_chat,"[ClothesMod] You put back on your old clothes")
has_clothes[id] = 0
}
return PLUGIN_HANDLED
}
public changemodel(id, level, cid){
if (cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED
new szArg1[32], szArg2[32]
read_argv(1, szArg1, 31)
read_argv(2, szArg2,31)
new Target = cmd_target(id, szArg1, 14)
if (!Target)
return PLUGIN_HANDLED
new szName[32]
get_user_name(Target, szName, 31)
set_user_info(id,"model",szArg2)
client_print(id,print_chat,"[ClothesMod] You have changed your clothes")
return PLUGIN_HANDLED
}
public admin_addclothes(id)
{
if(!(get_user_flags(id) & ADMIN_IMMUNITY))
{
client_print(id, print_console, "[AMXX] You do not have access to this command!^n")
return PLUGIN_HANDLED
}
new itemid[32], modelname[32], model[32], desp[32], query[256]
read_argv(1,itemid,31)
read_argv(2,modelname,31)
read_argv(3,model,31)
read_argv(4,desp,31)
if(equali(itemid,"") || equali(modelname,"") || equali(model,""))
{
client_print(id,print_console,"Usage: amx_addclothes <itemid> <modelname> <model>^n")
return PLUGIN_HANDLED
}
format(query,255,"SELECT ItemID FROM Title WHERE ItemID=%i",itemid,modelname)
result = dbi_query(dbc,"%s",query)
if(result >= RESULT_OK)
{
dbi_nextrow(result)
client_print(id,print_console,"[AMXX] This itemid is already in use by another item^n")
dbi_free_result(result)
return PLUGIN_HANDLED
}
format(query,255,"INSERT INTO jobs (ItemID,Title,Command,Description) VALUES('%i','%s','item_clothes <id> %i','%s','1','1','0','0')",itemid,modelname,model,desp)
dbi_query(dbc,"%s",query)
client_print(id,print_console,"[AMXX] Clothes was added to the database^n")
return PLUGIN_HANDLED
}