Raised This Month: $ Target: $400
 0% 

how to get this csript to wok?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ol
Senior Member
Join Date: Jul 2004
Old 10-11-2004 , 04:58   how to get this csript to wok?
Reply With Quote #1

this is a plugin for show player info,and it use the module of mysql,but it is not work ,can you help me? this is for amxx0.2

Code:
#include <amxmodx> #include <csx> #include <dbi> new bool:g_specMode[33] new temp[256] public setSpecMode(id) {   new arg[12]   read_data( 2 , arg , 11 )   g_specMode[ id ] = ( arg[10] == '4' )   } public showipinfo(id){     if ( g_specMode[id] ){     new a = read_data(2)     if ( is_user_connected( a ) ){         new ipaddr,userip[16],buffer[512],name[32]         get_user_ip(a,userip,16,1)         ipaddr=ip_to_number(userip)         sql_code(ipaddr)         while(replace(temp, 255, "\n", "^n")){}         get_user_name( a ,name,31)         format(buffer,511,"%s^n%s",name,temp)         set_hudmessage(200, 100, 0, 0.85, 0.35, 0, 6.0, 6.0, 0.5, 0.15, 8)           show_hudmessage(id,buffer)         }      } } public client_putinserver(id){    new param[34], len    param[0] = id    len = get_user_name(id,param[1],31)    set_task(2.0, "enter_msg", 0, param,len + 2)    return PLUGIN_CONTINUE } public client_disconnect(id){    new param[34], len    param[0] = id    len = get_user_name(id, param[1], 31)    set_task(2.0, "leave_msg", 0, param, len + 2)    return PLUGIN_CONTINUE } public enter_msg(param[]) {    new message[512],hostname[64],userip[16],ipaddr    get_user_ip(param[0],userip,16,1)    ipaddr=ip_to_number(userip)    sql_code(ipaddr)    get_cvar_string("amx_enter_message", message, 511)    get_cvar_string("hostname", hostname, 63)    replace(message,511, "%hostname%", hostname)    if (cvar_exists("csstats_reset")){       new data[8], rankpos[8], pos       pos = get_user_stats(param[0],data,data)       num_to_str(pos,rankpos,7)       replace(message, 511, "%rankpos%", rankpos)    }    replace(message, 511, "%name%", param[1])    replace(message, 511, "%IP%", temp)    while(replace(message, 511, "\n", "^n")){}    set_hudmessage(0, 255, 0, 0.10, 0.55, 0, 6.0, 6.0, 0.5, 0.15, 3)    show_hudmessage(0, message)    return PLUGIN_CONTINUE } public leave_msg(param[]) {    new message[192],hostname[64]    get_cvar_string("amx_leave_message", message, 191)    get_cvar_string("hostname", hostname, 63)    replace(message, 191, "%hostname%", hostname)    replace(message, 191, "%name%", param[1])    while(replace(message, 191, "\n", "^n")){}    set_hudmessage(255, 0, 255, 0.10, 0.55, 0, 6.0, 6.0, 0.5, 0.15, 3)    show_hudmessage(0, message)    return PLUGIN_CONTINUE } sql_code(ipaddr){     new mquery[256]     new host[64],user[32],pass[32],db[32],error[128]     new country[32],address[64],prov[32],city[32]     if (ipaddr >=0){         format(mquery, 255, "SELECT * FROM ipdatau WHERE StartIP <=%d ORDER BY StartIP DESC  LIMIT 0 , 1", ipaddr)     }     else{         format(mquery, 255, "SELECT * FROM ipdatau WHERE StartIP <=%d + 4294967296 ORDER BY StartIP DESC  LIMIT 0 , 1", ipaddr)     }     get_cvar_string("amx_mysql_host",host,63)     get_cvar_string("amx_mysql_user",user,31)     get_cvar_string("amx_mysql_pass",pass,31)     get_cvar_string("amx_mysql_db",db,31)     new Sql:dbc = dbi_connect(host,user,pass,db,error,32)     if (dbc < SQL_OK ){         server_print("[AMXX] SQL Connection Failed, CODE[Z1]:'%s'",error)         dbi_close(dbc)         return PLUGIN_HANDLED     }     new Result:res = dbi_query(dbc, mquery)     if (res <= RESULT_NONE){         dbi_error(dbc,error,127)         server_print("[AMXX] MySQL error(CODE[Z2]): can't load address: '%s'",error)         dbi_free_result(res)         dbi_close(dbc)         return PLUGIN_HANDLED     }         while(dbi_nextrow(dbc) > 0 ){         dbi_field(dbc, 3,  country, 31)         dbi_field(dbc, 4,  prov, 31)         dbi_field(dbc, 5,  city, 31)         dbi_field(dbc, 6,  address, 63)     }     format(temp,255,"%s %s\n%s %s",country,prov,city,address)     return PLUGIN_CONTINUE } ip_to_number(userip[16]){     new ipb1[12],ipb2[12],ipb3[12],ipb4[12]     new ip     new nipb1,nipb2,nipb3,nipb4     new uip[16]     copy(uip, 16, userip)     while(replace(uip, 16, ".", " ")){}     parse(uip, ipb1, 12, ipb2, 12, ipb3, 12, ipb4, 12)     nipb1 = str_to_num(ipb1)     nipb2 = str_to_num(ipb2)     nipb3 = str_to_num(ipb3)     nipb4 = str_to_num(ipb4)     ip=nipb1*16777216 + nipb2*65536 + nipb3*256 + nipb4     return ip } public plugin_init() {   register_plugin("showinfo","0.1 beta","aaa")   register_event("TextMsg","setSpecMode","bd","2&ec_Mod")   register_event("StatusValue","showipinfo","bd","1=2")   register_cvar("amx_mysql_host","127.0.0.1")   register_cvar("amx_mysql_user","root")   register_cvar("amx_mysql_pass","")   register_cvar("amx_mysql_db","amxx")   register_cvar("amx_enter_message", "%name% has joined!\nEnjoy in this game!\n(Rank is %rankpos%)\n%IP%")   register_cvar("amx_leave_message", "%name% has left!\nI hope you will come back.")   return PLUGIN_CONTINUE   }
ol is offline
Reply


Thread Tools
Display Modes

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 17:23.


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