Raised This Month: $51 Target: $400
 12% 

Need help with sql and amxx.


Post New Thread Reply   
 
Thread Tools Display Modes
JocAnis
Veteran Member
Join Date: Jun 2010
Old 08-27-2019 , 12:18   Re: Need help with sql and amxx.
Reply With Quote #21

is it totally empty or it has your table in there? https://inloop.github.io/sqlite-viewer/ for example
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
xd346
Junior Member
Join Date: Aug 2019
Old 08-27-2019 , 12:26   Re: Need help with sql and amxx.
Reply With Quote #22

Quote:
Originally Posted by JocAnis View Post
is it totally empty or it has your table in there? https://inloop.github.io/sqlite-viewer/ for example
It has an empty table called test.
xd346 is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 08-27-2019 , 12:56   Re: Need help with sql and amxx.
Reply With Quote #23

Set sql connection on 0.1 sec, not 1.0 (plugin init) and load data from player by some task, 1.0sec for example..could be if u are testing on the lan, load_mysql is being called before mysql_init
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 08-27-2019 at 12:57.
JocAnis is offline
xd346
Junior Member
Join Date: Aug 2019
Old 08-27-2019 , 13:19   Re: Need help with sql and amxx.
Reply With Quote #24

Quote:
Originally Posted by JocAnis View Post
Set sql connection on 0.1 sec, not 1.0 (plugin init) and load data from player by some task, 1.0sec for example..could be if u are testing on the lan, load_mysql is being called before mysql_init
PHP Code:
public plugin_init()  

  
register_plugin("Database Data","1.0",""
  
register_clcmd("say steamid","plugintriggertest"); 
  
RegisterHam(Ham_Killed"player""fwdPlayerDeath"0);
  
  
set_task(0.1"MySql_Init")


public 
MySql_Init()
{
    
g_SqlTuple SQL_MakeDbTuple(Host,User,Pass,Db)
    new 
ErrorCode,Handle:SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,512)
    if(
SqlConnection == Empty_Handle)
        
set_fail_state(g_Error)
       
    new 
Handle:Queries
    Queries 
SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS test (steamid varchar(32),pl INT(12))")

    if(!
SQL_Execute(Queries))
    {
        
SQL_QueryError(Queries,g_Error,512)
        
set_fail_state(g_Error)
    }
    
    
SQL_FreeHandle(Queries)

    
SQL_FreeHandle(SqlConnection)   
}

public 
Load_MySql(id)
{
    new 
szSteamId[32], szTemp[512]
    
get_user_authid(idszSteamId32)
    
server_print("%s"szSteamId)
    new 
Data[1]
    
Data[0] = id

    format
(szTemp,512,"SELECT * FROM test WHERE (steamid = '%s')"szSteamId)
    
SQL_ThreadQuery(g_SqlTuple,"register_client",szTemp,Data,1)
}


public 
register_client(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(
FailState == TQUERY_CONNECT_FAILED)
    {
        
log_amx("Load - Could not connect to SQL database.  [%d] %s"ErrcodeError)
    }
    else if(
FailState == TQUERY_QUERY_FAILED)
    {
        
log_amx("Load Query failed. [%d] %s"ErrcodeError)
    }

    new 
id
    id 
Data[0]
    
    if(
SQL_NumResults(Query) < 1
    {
        new 
szSteamId[32]
        
get_user_authid(idszSteamId32)
        if (
equal(szSteamId,"ID_PENDING"))
            return 
PLUGIN_HANDLED

        set_task
(1.0,"runquerytest",123,szSteamId)
    } 
    else 
    {
        
// if there are results found
        
iExp[id]         = SQL_ReadResult(Query1)
    }
    
    return 
PLUGIN_HANDLED
}
public 
runquerytest(stmid)
{
        new 
szTemp[512]

        
format(szTemp,512,"INSERT INTO test ( steamid , pl) VALUES ('%s','0');",stmid)
        
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
        

Same error
xd346 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-27-2019 , 13:38   Re: Need help with sql and amxx.
Reply With Quote #25

This has nothing to do with the pawn plugin seems like you are unable to connect to the database for the following reasons:-
1. Wrong information passed into the tuple
2. MySQL server is not running
3. network connections not enabled
4. network port you specified is wrong one configured on the server or you didnt open the port.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 08-27-2019 at 13:38.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
xd346
Junior Member
Join Date: Aug 2019
Old 08-27-2019 , 13:57   Re: Need help with sql and amxx.
Reply With Quote #26

Quote:
Originally Posted by Natsheh View Post
This has nothing to do with the pawn plugin seems like you are unable to connect to the database for the following reasons:-
1. Wrong information passed into the tuple
2. MySQL server is not running
3. network connections not enabled
4. network port you specified is wrong one configured on the server or you didnt open the port.
Can you explain how to fix these issues please. Everything is hosted localy.
xd346 is offline
xd346
Junior Member
Join Date: Aug 2019
Old 09-08-2019 , 13:37   Re: Need help with sql and amxx.
Reply With Quote #27

Quote:
Originally Posted by xd346 View Post
Can you explain how to fix these issues please. Everything is hosted localy.
Guess not...
xd346 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 06:40.


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