Raised This Month: $ Target: $400
 0% 

database


Post New Thread Reply   
 
Thread Tools Display Modes
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 01-24-2011 , 16:33   Re: database
Reply With Quote #31

INSERT OR REPLACE no longer seems to be valid, but just using REPLACE will INSERT if the entry is not found. So "REPLACE INTO ... blah blah ..." should suffice.
__________________
thetwistedpanda is offline
maza51
Senior Member
Join Date: Mar 2010
Old 01-24-2011 , 18:11   Re: database
Reply With Quote #32

My code:

PHP Code:
#include <sourcemod>
#include <sdktools>

new Handle:DB INVALID_HANDLE;


public 
OnPluginStart()
{
    
I_DB();
    
RegConsoleCmd("sm_sss"Command);
    
RegConsoleCmd("sm_ssss"Command2);
}

public 
I_DB()
{
    new 
String:error[255];
    
DB SQLite_UseDatabase("timer"errorsizeof(error));
    new 
String:query[512];
    
    if (
DB == INVALID_HANDLE)
    {
        
PrintToServer("Could not connect to skillrank: %s"error);
    }
    else
    {
        
SQL_FastQuery(DB"CREATE TABLE IF NOT EXISTS 'Players' ( 'steamId' VARCHAR(32) NOT NULL PRIMARY KEY)");
        if (!
SQL_Query(DBquery))
        {
            
SQL_GetError(DBerrorsizeof(error));
            
PrintToServer("Failed to query (error: %s)"error);
        }
        else
        {
            
PrintToServer("table Players created if it didn't already exist");
        }
    }
}



public 
Action:Command(clientargs)
{

    if (
IsClientInGame(client))
    {
        
        
decl String:query[200];
        
        
decl String:steamId[30];
        
GetClientAuthString(clientsteamIdsizeof(steamId));
        
        
Format(querysizeof(query), "INSERT INTO 'Players' ( 'steamId') VALUES ( '%s')"steamId);
        
PrintToChatAll("123");
        
SQL_FastQuery(DBquery);
    }
}

Command3(client)
{

    new 
String:error[255], String:steamId[32];
    
DB SQL_Connect("timer"trueerrorsizeof(error));
    new 
String:query[512];
    new 
Handle:results;
    
GetClientAuthString(clientsteamIdsizeof(steamId));
    if (
DB == INVALID_HANDLE)
    {
        
PrintToServer("Could not connect to timer: %s"error);
    } 
    
CloseHandle(DB);
}

public 
Action:Command2(clientargs)
{
    
Command3(client);

Me an error: Configuration "timer" not found
Why?
maza51 is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 01-24-2011 , 19:55   Re: database
Reply With Quote #33

Bad databases.cfg.
__________________
FaTony is offline
maza51
Senior Member
Join Date: Mar 2010
Old 01-25-2011 , 02:00   Re: database
Reply With Quote #34

Why database.cfg If the database is created locally?
maza51 is offline
maza51
Senior Member
Join Date: Mar 2010
Old 01-25-2011 , 02:39   Re: database
Reply With Quote #35

Solved this problem.

Now when I try to write SteamId from the database into the chat, he wrote my SteamId and not from the database. Why?

PHP Code:
    new String:error[255], String:steamId[32];
    
DB SQL_Connect("timer"trueerrorsizeof(error));
    
GetClientAuthString(clientsteamIdsizeof(steamId));
    
    
decl String:query[200];
    
    
    if (
DB == INVALID_HANDLE)
    {
        
PrintToServer("Could not connect to timer: %s"error);
    } 
    else
    {
        
PrintToServer("TIMERRRRR LOAD BASE"error);
        
Format(querysizeof(query), "SELECT * FROM    'Players' WHERE steamId = '%s';"steamId);
        
PrintToChatAll("\x05lol %s"steamId);
    }
    
CloseHandle(DB); 
maza51 is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 01-25-2011 , 08:26   Re: database
Reply With Quote #36

Learn how to process your results.
__________________
FaTony is offline
maza51
Senior Member
Join Date: Mar 2010
Old 01-25-2011 , 08:50   Re: database
Reply With Quote #37

I've done =)
maza51 is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 01-25-2011 , 08:52   Re: database
Reply With Quote #38

I see...
__________________
Leonardo is offline
maza51
Senior Member
Join Date: Mar 2010
Old 01-25-2011 , 09:43   Re: database
Reply With Quote #39

I can barely keep one card and one player for some reason ..
maza51 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 21:13.


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