AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Slot by IP frome mysql (https://forums.alliedmods.net/showthread.php?t=22950)

Zky 01-07-2006 14:51

Slot by IP frome mysql
 
This plug-in good comp. but doesnt work :((( why ? who can tell ?
Sorry for my english :oops:

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 }

:oops: :oops:

Twilight Suzuka 01-07-2006 17:40

Why did you turn their IP into a number?

Zky 01-07-2006 18:31

This plug-in was written not by me. I only have tried to alter it under AMX MOD X. If you can, please correct this plug-in.
Thanks.

Zky 04-02-2006 12:31

Please, somebody help me


All times are GMT -4. The time now is 16:11.

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