Raised This Month: $ Target: $400
 0% 

Query, select from mysql help me...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Viera
Senior Member
Join Date: Sep 2008
Location: Poland
Old 02-27-2009 , 20:25   Query, select from mysql help me...
Reply With Quote #1

Hi all, I wanna do select in to this plugin.
in line 78 I write querry
PHP Code:
format(query_select,1000,"SELECT tmpNick FROM `%s`, table"
But it dosn't work..
Can you help me, please...

PHP Code:
public client_connect(id)
{
    new 
ip[16],ip1[16],ip2[16],ip3[16],ip4[16]
    new 
ipA[16],ipB[16],a1[16],a2[16],a3[16],a4[16],b1[16],b2[16],b3[16],b4[16]
    new 
czas[20],a,index,i,plik[100],len,nieban,c
    
new tmp[100],aq1,aq2,aq3,aq4,bq1,bq2,bq3,bq4,iq1,iq2,iq3,iq4
    
new CurrentTime[25],iplog[16],name[50]
    new 
ipLarge,aLarge,bLarge
    CurrentTime
=""
    
get_time("%Y.%d.%m - %H:%M:%S - ",CurrentTime,25)
    if(
file_exists("addons/amxmodx/ban.txt")!=0)
    
get_user_ip(id,ip,16,1)
    while( 
contain ip"." ) > -)
        
replaceip16"."" " )
    
ip1=""
    
ip2=""
    
ip3=""
    
ip4=""
    
parse(ip,ip1,5,ip2,5,ip3,5,ip4,5)
    
iq1=str_to_num(ip1)
    
iq2=str_to_num(ip2)
    
iq3=str_to_num(ip3)
    
iq4=str_to_num(ip4)
    
ipLarge=iq1*255*255*255+iq2*255*255+iq3*255+iq4
    index
=1
    a
=0
    
while (index!=0)
    {
        
index=read_file("addons/amxmodx/ban.txt",a,plik,100,len)
        if(
index!=0)
        {
                
parse(plik,ipA,16,ipB,16,czas,10)
                while( 
contain ipA"." ) > -)
                    
replaceipA16"."" " )
                
a1=""
                
a2=""
                
a3=""
                
a4=""
                
parse(ipA,a1,5,a2,5,a3,5,a4,5)
                
aq1=str_to_num(a1)
                
aq2=str_to_num(a2)
                
aq3=str_to_num(a3)
                
aq4=str_to_num(a4)
                while( 
contain ipB"." ) > -)
                    
replaceipB16"."" " )
                
b1=""
                
b2=""
                
b3=""
                
b4=""
                
parse(ipB,b1,5,b2,5,b3,5,b4,5)
                
bq1=str_to_num(b1)
                
bq2=str_to_num(b2)
                
bq3=str_to_num(b3)
                
bq4=str_to_num(b4)
                
aLarge=aq1*255*255*255+aq2*255*255+aq3*255+aq4
                bLarge
=bq1*255*255*255+bq2*255*255+bq3*255+bq4
                
if(aLarge<=ipLarge<=bLarge)
                {
                    
iplog=ip
                    
while( contain(iplog" " ) > -)
                        
replace(iplog16" ""." )
                    
tmp=""
                    
add(tmp,100,CurrentTime)
                    
add(tmp,100,iplog)
                    
get_user_name(id,name,50)
                    
add(tmp,100," <")
                    
add(tmp,100,name)
                    
add(tmp,100,">")
                    
nieban=0
                    i
=1
                    c
=0
                    
new tmpNick[50],tmpPass[50],tmpX[100];
                    while (
i!=0)
                    {
                        
tmpX="";
                        
tmpNick="";
                        
tmpPass="";
                        new 
query_select[1001]
                        
format(query_create,1000,"SELECT tmpNick FROM `%s`, table")
                        
parse(tmpX,tmpNick,50,tmpPass,50)
                        if(
equal(name,tmpNick))
                         {
                            
nieban=1
                        
}
                        
c++
                    }
                    if(
nieban==0)
                    {

                        
write_file("addons/amxmodx/ban.log",tmp);
                        new 
lReason[128]
                        
format(lReason127"%L"id"YOURE_BANNED")
                        
server_cmd("kick #%d Twoje miasto zostalo zbanowane. Wejdz na www.satellite.cba.pl i zloz podanie o konto."get_user_userid(id), lReason)
                        
index=0
                    
} else
                    {
                        
add(tmp,100," EXCL")
                        
write_file("addons/amxmodx/zaakceptowani.log",tmp);
                    }
                }
        }
        
a++
    }


Last edited by Viera; 02-27-2009 at 20:28.
Viera is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 02-27-2009 , 20:30   Re: Query, select from mysql help me...
Reply With Quote #2

dbi or sqlx? You are using?
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
Viera
Senior Member
Join Date: Sep 2008
Location: Poland
Old 02-27-2009 , 20:51   Re: Query, select from mysql help me...
Reply With Quote #3

sqlx
Viera is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 02-27-2009 , 20:54   Re: Query, select from mysql help me...
Reply With Quote #4

Show more code. And explain the plugin..

Read this to use SQL_Readresult

http://forums.alliedmods.net/showthread.php?t=46779
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
Viera
Senior Member
Join Date: Sep 2008
Location: Poland
Old 02-27-2009 , 20:59   Re: Query, select from mysql help me...
Reply With Quote #5

If I have same range IP in ban.txt then all players who have this same IP was banned and if this player have account in table amx_zneo can get in server... it's seens like filtr

PHP Code:
#include <amxmodx>
#include <file>
#include <string>
#include <sqlx>

///SQL
#define table "amx_zneo"
#define MAXLEN 511
#define MAX_WORDS 150
// SQL
new Handle:g_SqlX
new Handle:g_SqlConnection
new g_error[512]

public 
plugin_init()
{
    
register_plugin("HugeBan""0.1""kbr_Kobra")
    
//set_task(30.0, "checkIp",1222)


    
new host[64], user[64], pass[64], db[64],errorcode
    get_cvar_string
("amx_sql_host"host63)
    
get_cvar_string("amx_sql_user"user63)
    
get_cvar_string("amx_sql_pass"pass63)
    
get_cvar_string("amx_sql_db"db63)


    
g_SqlX SQL_MakeDbTuple(hostuserpassdb)
    
g_SqlConnection SQL_Connect(g_SqlX,errorcode,g_error,511)

    if (!
g_SqlConnection)
    {
    
console_print(0,"Logowanie zdjec: Nie moge polaczyc sie z baza danych.!")
    return 
log_amx("Logowanie zdjec: Nie moge polaczyc sie z baza danych.")
    }

    new 
query_create[1001]
    
format(query_create,1000,"CREATE TABLE IF NOT EXISTS `%s`(`tmpX` varchar(100) NOT NULL default '',`tmpNick` varchar(100) NOT NULL default '',`tmpPass` varchar(100) NOT NULL default '',PRIMARY KEY (`tmpNick`));",table)
     
SQL_ThreadQuery(g_SqlX,"QueryHandle",query_create)

    
console_print(0,"[AMXX SQL] Polaczono!")
    return 
PLUGIN_CONTINUE
}

public 
client_connect(id)
{
    new 
ip[16],ip1[16],ip2[16],ip3[16],ip4[16]
    new 
ipA[16],ipB[16],a1[16],a2[16],a3[16],a4[16],b1[16],b2[16],b3[16],b4[16]
    new 
czas[20],a,index,i,plik[100],len,nieban,c
    
new tmp[100],aq1,aq2,aq3,aq4,bq1,bq2,bq3,bq4,iq1,iq2,iq3,iq4
    
new CurrentTime[25],iplog[16],name[50]
    new 
ipLarge,aLarge,bLarge
    CurrentTime
=""
    
get_time("%Y.%d.%m - %H:%M:%S - ",CurrentTime,25)
    if(
file_exists("addons/amxmodx/ban.txt")!=0)
    
get_user_ip(id,ip,16,1)
    while( 
contain ip"." ) > -)
        
replaceip16"."" " )
    
ip1=""
    
ip2=""
    
ip3=""
    
ip4=""
    
parse(ip,ip1,5,ip2,5,ip3,5,ip4,5)
    
iq1=str_to_num(ip1)
    
iq2=str_to_num(ip2)
    
iq3=str_to_num(ip3)
    
iq4=str_to_num(ip4)
    
ipLarge=iq1*255*255*255+iq2*255*255+iq3*255+iq4
    index
=1
    a
=0
    
while (index!=0)
    {
        
index=read_file("addons/amxmodx/ban.txt",a,plik,100,len)
        if(
index!=0)
        {
                
parse(plik,ipA,16,ipB,16,czas,10)
                while( 
contain ipA"." ) > -)
                    
replaceipA16"."" " )
                
a1=""
                
a2=""
                
a3=""
                
a4=""
                
parse(ipA,a1,5,a2,5,a3,5,a4,5)
                
aq1=str_to_num(a1)
                
aq2=str_to_num(a2)
                
aq3=str_to_num(a3)
                
aq4=str_to_num(a4)
                while( 
contain ipB"." ) > -)
                    
replaceipB16"."" " )
                
b1=""
                
b2=""
                
b3=""
                
b4=""
                
parse(ipB,b1,5,b2,5,b3,5,b4,5)
                
bq1=str_to_num(b1)
                
bq2=str_to_num(b2)
                
bq3=str_to_num(b3)
                
bq4=str_to_num(b4)
                
aLarge=aq1*255*255*255+aq2*255*255+aq3*255+aq4
                bLarge
=bq1*255*255*255+bq2*255*255+bq3*255+bq4
                
if(aLarge<=ipLarge<=bLarge)
                {
                    
iplog=ip
                    
while( contain(iplog" " ) > -)
                        
replace(iplog16" ""." )
                    
tmp=""
                    
add(tmp,100,CurrentTime)
                    
add(tmp,100,iplog)
                    
get_user_name(id,name,50)
                    
add(tmp,100," <")
                    
add(tmp,100,name)
                    
add(tmp,100,">")
                    
nieban=0
                    i
=1
                    c
=0
                    
new tmpNick[50],tmpPass[50],tmpX[100];
                    while (
i!=0)
                    {
                        
tmpX="";
                        
tmpNick="";
                        
tmpPass="";
                        new 
query_select[1001]
                        
format(query_create,1000,"SELECT tmpNick FROM `%s`, table")
                        
parse(tmpX,tmpNick,50,tmpPass,50)
                        if(
equal(name,tmpNick))
                         {
                            
nieban=1
                        
}
                        
c++
                    }
                    if(
nieban==0)
                    {

                        
write_file("addons/amxmodx/ban.log",tmp);
                        new 
lReason[128]
                        
format(lReason127"%L"id"YOURE_BANNED")
                        
server_cmd("kick #%d Twoje miasto zostalo zbanowane. Wejdz na www.satellite.cba.pl i zloz podanie o konto."get_user_userid(id), lReason)
                        
index=0
                    
} else
                    {
                        
add(tmp,100," EXCL")
                        
write_file("addons/amxmodx/zaakceptowani.log",tmp);
                    }
                }
        }
        
a++
    }
}
public 
QueryHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
if(
FailState == TQUERY_CONNECT_FAILED)
return 
log_amx("Logowanie zdjec: Nie moge polaczyc sie z SQL.")

else if(
FailState == TQUERY_QUERY_FAILED)
return 
log_amx("Logowanie zdjec: Zapytanie nieprawidlowe")

if(
Errcode)
return 
log_amx("Logowanie zdjec: Blad w zapytaniu: %s",Error)

new 
DataNum
while(SQL_MoreResults(Query))
{
DataNum SQL_ReadResult(Query,0)
server_print("zomg, some data: %s",DataNum)
SQL_NextRow(Query)
}
return 
PLUGIN_CONTINUE

Viera is offline
Viera
Senior Member
Join Date: Sep 2008
Location: Poland
Old 02-27-2009 , 21:10   Re: Query, select from mysql help me...
Reply With Quote #6

I don't know what I must to add in this line to filtr account
PHP Code:
format(query_select,1000,"SELECT tmpNick FROM `%s`, table"
maybe it must be
PHP Code:
format(query_select,1000,"SELECT * FROM `%s` WHERE name='tmpNick' && haslo='tmpPass', table"
Viera is offline
Viera
Senior Member
Join Date: Sep 2008
Location: Poland
Old 02-27-2009 , 21:18   Re: Query, select from mysql help me...
Reply With Quote #7

before this code like
PHP Code:
                        tmpX="";
                        
tmpNick="";
                        
tmpPass="";
                        
i=read_file("addons/amxmodx/nicks.txt",c,tmpX,100,len)
                        
parse(tmpX,tmpNick,50,tmpPass,50)
                        if(
equal(name,tmpNick)) 
Viera is offline
Old 02-27-2009, 21:40
AntiBots
This message has been deleted by AntiBots. Reason: ...
Viera
Senior Member
Join Date: Sep 2008
Location: Poland
Old 02-28-2009 , 05:55   Re: Query, select from mysql help me...
Reply With Quote #8

enybody can help me ?
Viera 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 16:56.


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