Raised This Month: $ Target: $400
 0% 

Needed help in converting plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
un1ucky
Junior Member
Join Date: Aug 2005
Old 08-01-2005 , 12:26   Needed help in converting plugin
Reply With Quote #1

Needed help in converting plugin from amx to amxx. This plugin is used for baning players by IP and add them to mysql base.
Or advise me a plugin of same type. (Amxbans isn't working with my web-registration interface, so this is not an option)
Here is this plugin.
Attached Files
File Type: sma Get Plugin or Get Source (admin_ban_sql.sma - 692 views - 10.4 KB)
un1ucky is offline
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 08-01-2005 , 17:41  
Reply With Quote #2

Enjoy! I'll post the .sma and you can use the "Get Plugin" Link to get it.


Code:
/* AMX Mod script. * * MySQL Ban Management *  by JustinHoMi * Ported to amxx by slmclarengt */ /* db schema  CREATE TABLE amx_bans (   player_id varchar(30) NOT NULL default '',   player_name varchar(40) NOT NULL default '',   reason varchar(128) NOT NULL default '',   admin_id varchar(40) NOT NULL default '',   admin_name varchar(30) NOT NULL default '',   length int(10) unsigned NOT NULL default '0',   time_created timestamp(14) NOT NULL,   server varchar(25) NOT NULL default '',   ip varchar(25) NOT NULL default '',   PRIMARY KEY  (player_id)  ) TYPE=MyISAM;  CREATE TABLE amx_unbans (    player_id varchar(17) NOT NULL default '',    player_name varchar(33) NOT NULL default '',    admin_id varchar(17) default NULL,    admin_name varchar(33) default NULL,    time_unbanned timestamp(14) NOT NULL,    server varchar(25) NOT NULL default '',    ip varchar(25) NOT NULL default ''    admin_ban varchar(33) default NULL,    length int(10) unsigned NOT NULL default '0'  ) TYPE=MyISAM; */ #include <amxmodx> #include <amxmisc> #include <mysql> new merror[32] new mhost[64] new muser[32] new mpass[32] new mdb[32] new mysql = 0 new server_ip[16], server_port[6], server[32] public sql_init(){     get_cvar_string("ip",server_ip,15)     get_cvar_string("port",server_port,5)     add(server,31,server_ip)     add(server,31,":")     add(server,31,server_port)     get_cvar_string("amx_mysql_host",mhost,63)     get_cvar_string("amx_mysql_user",muser,31)     get_cvar_string("amx_mysql_pass",mpass,31)     get_cvar_string("amx_mysql_db",mdb,31)     mysql = mysql_connect("localhost","name","pass","table",merror,32)     if(mysql < 1)         server_print("[AMX] MySQL error : could not connect : '%s'",merror)     else         server_print("[AMX] MySQL Ban successfully connected.")     return PLUGIN_CONTINUE } public sql_ban(id,level,cid){     if (!cmd_access(id,level,cid,4))         return PLUGIN_HANDLED     new arg[33]     read_argv(2,arg,32)     new player = cmd_target(id,arg)     if (player) {         if (get_user_flags(player)&ADMIN_IMMUNITY){             console_print(id,"[AMX] The player has immunity")             return PLUGIN_HANDLED         }         else if (is_user_bot(player))   {             console_print(id,"[AMX] Bot can't be banned")             return PLUGIN_HANDLED         }                 // get ban length and convert to seconds         new ban_length_s[10],ban_length_s2[10]         read_argv(1,ban_length_s,9)         new multiplier = 60         new carg         if(contain(ban_length_s,"h") != -1){             multiplier = 60 * 60             carg = 'h'         }         else if(contain(ban_length_s,"d") != -1){             multiplier = 60 * 60 * 24             carg = 'd'         }         else if(contain(ban_length_s,"w") != -1){             multiplier = 60 * 60 * 24 * 7             carg = 'w'         }         copyc(ban_length_s2,9,ban_length_s,carg)         new ban_length = str_to_num(ban_length_s2) * multiplier         // get reason and get ready to format it         new text[64],temp[10],temp2[33],ip[20]         read_args(text,63)         parse(text,temp,9,temp2,32)         new length1 = strlen(temp)         new length2 = strlen(temp2)         new length = length1 + length2         length+=2         new reason[64]         read_args(reason,63)         // get user info to put in table         new authid[17],name2[33],authid2[17],name[33]         get_user_authid(player,authid2,16)         get_user_authid(id,authid,16)         get_user_name(player,name2,32)         get_user_name(id,name,32)         get_user_ip(player,ip,20,1)         // format the query         new query[256]         format(query,255,"SELECT player_name FROM amx_bans WHERE ip='%s'",ip)         mysql_query(mysql,query)         mysql_error(mysql,merror,31)         if(merror[0]) server_print("[AMX] MYSQL error: %s",merror)         if(mysql_nextrow(mysql)<=0){             format(query,255,"INSERT into amx_bans (player_id,player_name,reason,admin_id,admin_name,length,server,ip) values('%s','%s','%s','%s','%s','%i','%s','%s')",authid2,name2,reason[length],authid,name,ban_length,server,ip) //          console_print(id, query)             // connect to database and insert data             //new sql = mysql_connect(mhost,muser,mpass,mdb,merror,32)             mysql_query(mysql,query)             mysql_error(mysql,merror,31)             if (merror[0]){                 server_print("[AMX] MYSQL error: %s",merror)                 return PLUGIN_HANDLED             }         }         // convert ban length back to minutes for display         ban_length = ban_length / 60         console_print(id,"[AMX] Banning %s for %i",name2,ban_length)             client_print(0,print_chat,"ADMIN: %s risuet banan %s na %i minut(%s).",name,name2,ban_length,reason[length])         // format time message         new time_msg[32]         if (ban_length == 0)             time_msg = "Permanent"         else             format(time_msg,31,"%i minutes",ban_length)         // format ban window         new buffer[256]         format(buffer,255,"<html><body bgcolor='#ffffff'>You have been banned from this server by %s^nReason: %s^nLength: %s.^n^nYou will be disconnected in 10 seconds.</body></html>",name,reason[length],time_msg)         show_motd(player,buffer,"You have been banned");         //new idx[2]         //idx[0] = player         //delay the kick and display console message         //set_task(10.0,"delayed_kick",1,idx,2)         //client_cmd(player, "echo ^"[AMX] You have been banned from this server.^"")         //client_cmd(player, "echo ^"[AMX] Reason: %s.^"",reason[length])         //client_cmd(player, "echo ^"[AMX] Length: %s.^"",time_msg)         new idx[3]         num_to_str(player,idx,2)         new params[192]         copy(params,3,idx)         new tmp[128]         format(tmp,127," ^"%s^"",reason[length])         add(params,127,tmp)         format(tmp,31," ^"%s^"",time_msg)         add(params,31,tmp)         set_task(10.0,"delayed_kick",1,params,192)     }     else {         console_print(id,"[AMX] Client with that part of nick not found")     }     return PLUGIN_HANDLED } public sql_unban(id,level,cid){     if (!cmd_access(id,level,cid,2)) return PLUGIN_HANDLED     new ip[20]     new admin_ban[31], reason[129], length[11];     read_argv(1,ip,20)     new player_name[33],admin_authid[17],admin_name[33],query[256]     get_user_authid(id,admin_authid,16)     get_user_name(id,admin_name,32)     // see if player has actually been banned     format(query,255,"SELECT player_name,reason,length,admin_name FROM amx_bans WHERE ip='%s'",ip)     mysql_query(mysql,query)     mysql_error(mysql,merror,31)     if(merror[0]) server_print("[AMX] MYSQL error: %s",merror)     if(mysql_nextrow(mysql)>0){         mysql_getfield(mysql,1,player_name,32)         mysql_getfield(mysql,2,reason,128)         mysql_getfield(mysql,3,length,10)         mysql_getfield(mysql,4,admin_ban,30)         mysql_error(mysql,merror,31)     } else {         console_print(id,"[AMX] IP %s not found.",ip)         return PLUGIN_HANDLED     }     // log the ban into amx_unbans     if (player_name[0] && !merror[0]){         format(query,255,"INSERT into amx_unbans (player_id,player_name,admin_id,admin_name,server,ip,reason,admin_ban,length) values ('%s','%s','%s','%s','%s','%s','%s','%s','%s')","",player_name,admin_authid,admin_name,server,ip,reason,admin_ban,length)         mysql_query(mysql,query)         mysql_error(mysql,merror,31)     }     // if any of the above didn't work then show the error     if (merror[0]){         console_print(id,"[AMX] MYSQL error: %s",merror)         return PLUGIN_HANDLED     }     // delete the ban from the amx_bans     format(query,255,"DELETE from amx_bans where ip='%s'",ip)     mysql_query(mysql,query)     mysql_error(mysql,merror,32)     if (merror[0]){         server_print("[AMX] MYSQL error: %s",merror)         return PLUGIN_HANDLED     } else {         console_print(id,"[AMX] Ban on %s removed.",ip)     }     return PLUGIN_HANDLED } public client_connect(id){   new authid[17]   get_user_authid(id,authid,16)   new username[32]   get_user_name(id,username,31 )   new query[256],ip[20]   get_user_ip(id,ip,20,1)   server_print("User connected with IP: %s.",ip)   format(query,255,"SELECT reason,length,now()-time_created FROM amx_bans WHERE ip='%s'",ip)   mysql_query(mysql,query)   mysql_error(mysql,merror,31)   if (merror[0]){     server_print("[AMX] MYSQL error: %s",merror)     return PLUGIN_CONTINUE   }   if(mysql_nextrow(mysql)>0){     new reason[128],ban_length_s[10],ban_time_s[32]     mysql_getfield(mysql,1,reason,127)     mysql_getfield(mysql,2,ban_length_s,9)     mysql_getfield(mysql,3,ban_time_s,31)     format(query,255,"SELECT access FROM admins WHERE auth='%s'",username)     mysql_query(mysql,query)     if(mysql_nextrow(mysql)>0){     new access_u[33]     mysql_getfield(mysql,1,access_u,32)     if (contain(access_u,"q") != -1){           client_cmd(id, "echo ^"This IP was banned, but you are allowed to play from it.^"")       return PLUGIN_CONTINUE     }     }     //new ban_length,ban_time     new ban_length = str_to_num(ban_length_s)     new ban_time = str_to_num(ban_time_s)     server_print("[AMX] Bantime %i, Banlength %i",ban_time,ban_length)     if ((ban_time < ban_length) || (ban_length == 0)){ // if temp ban not up or perm       new time_msg[32]       if (ban_length == 0){         time_msg = "Permanent"       }       else{         new ban_left = (ban_length - ban_time) / 60         format(time_msg,31,"%i minutes",ban_left)       }       client_cmd(id, "echo ^"[AMX] You have been banned from this server.^"")       client_cmd(id, "echo ^"[AMX] Reason: %s.^"",reason)       client_cmd(id, "echo ^"[AMX] Time left: %s.^"",time_msg)               //new idx[2]       //idx[0] = id       //set_task(1.0,"delayed_kick",0,idx,2)       new idx[3]       num_to_str(id,idx,2)       new params[192]       copy(params,192,idx)       new tmp[128]       format(tmp,128," ^"%s^"",reason)       add(params,192,tmp)       format(tmp,32," ^"%s^"",time_msg)       add(params,192,tmp)       set_task(10.0,"delayed_kick",0,params,192)     }     else{ // if temp ban has expired       server_print("[AMX] SQL Ban: Removing temporary ban on %s.",authid)       console_cmd(0,"amx_unban %s",ip)     }   }   return PLUGIN_CONTINUE } public delayed_kick(args[]){     new id[3],reason[128],time_msg[32]     parse(args,id,2,reason,127,time_msg,31)     server_print("[debug] %s, %s, %s",id,reason,time_msg)     new idx = str_to_num(id)     client_cmd(idx, "echo ^"[AMX] You have been banned from this server.^"")     client_cmd(idx, "echo ^"[AMX] Reason: %s.^"",reason)     client_cmd(idx, "echo ^"[AMX] Time left: %s.^"",time_msg)     new userid = get_user_userid(idx)     server_cmd("kick #%d",userid)     return PLUGIN_CONTINUE } public plugin_end() {     if (mysql > 0)         mysql_close(mysql)     return PLUGIN_CONTINUE } public plugin_init(){     register_plugin("MySQL Ban Management","0.5","JustinHoMi")     register_concmd("amx_ban","sql_ban",ADMIN_BAN,"< length > < authid or nick > < reason >")     register_concmd("amx_unban","sql_unban",ADMIN_RCON,"< authid >")     sql_init()     return PLUGIN_CONTINUE }
Attached Files
File Type: sma Get Plugin or Get Source (admin_ban_sql.sma - 738 views - 10.4 KB)
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:33.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode