Raised This Month: $ Target: $400
 0% 

Slot by IP frome mysql


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Zky
Member
Join Date: Nov 2005
Old 01-07-2006 , 14:51   Slot by IP frome mysql
Reply With Quote #1

This plug-in good comp. but doesnt work (( why ? who can tell ?
Sorry for my english

Code:
#include <amxmodx> #include <string> #include <dbi> ip_to_number(userip[16]) { new ipb1[12] new ipb2[12] new ipb3[12] new ipb4[12] new ip new nipb1 new nipb2 new nipb3 new 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 * 256) + nipb2) * 256) + nipb3) + ((((((nipb1 * 256) + nipb2) * 256) + nipb3) * 255) + nipb4) return ip } net_hi_num(addr, mask) { return addr+4294967296-mask } net_belongs(ipaddr, ipmask, ipaddrin, ipmaskin) { if (ipaddr >= ipaddrin && net_hi_num(ipaddr, ipmask) <= net_hi_num(ipaddrin, ipmaskin)) { return 1 } return 0 } public client_connect(id){ new sipaddr[16] new sipmask[16] new userip[16] new Sql:sql, Result:result, cnt new merror[257] new mhost[65] new muser[33] new mpass[33] new mdb[33] get_user_ip(id,userip,16,1) get_cvar_string("amx_sql_host",mhost,64) get_cvar_string("amx_sql_user",muser,32) get_cvar_string("amx_sql_pass",mpass,32) get_cvar_string("amx_sql_db",mdb,32) sql = dbi_connect(mhost,muser,mpass,mdb,merror,256) if(sql > SQL_FAILED) { if( (result = dbi_query(sql,"SELECT * FROM amx_reserveip") ) > RESULT_FAILED ) { cnt = 0 while(dbi_nextrow(result)>0) { dbi_field(result,1,sipmask,16) dbi_field(result,2,sipaddr,16) cnt++ if (net_belongs(ip_to_number(userip), ip_to_number("255.255.255.255"), ip_to_number(sipaddr), ip_to_number(sipmask)) == 1) { set_user_flags(id,read_flags("b")) } } server_print("[AMX] Loaded %d IP(s) from database",cnt) } else { dbi_error(sql,merror,32) server_print("MySQL error : could not load ips from db : '%s'",merror) } dbi_close(sql) } else { server_print("MySQL error : could not connect : '%s'",merror) } return PLUGIN_CONTINUE } public plugin_init() { register_plugin("Slots reservation by IP","0.2","SYZo & Rouven") register_cvar("amx_sql_host","") register_cvar("amx_sql_user","") register_cvar("amx_sql_pass","") register_cvar("amx_sql_db","") return PLUGIN_CONTINUE }

Zky is offline
 



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 16:11.


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