This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Using BuildPath()


Post New Thread Reply   
 
Thread Tools Display Modes
ecca
Sexy Santa
Join Date: Jan 2011
Old 10-18-2012 , 18:08   Re: Using BuildPath()
Reply With Quote #11

You can name the cookie whatever you want. But developers mostly name it like mypluginname_cookie

A big guess where they are saved is sourcemod/data but i actually dont know.
__________________

Last edited by ecca; 10-18-2012 at 18:10.
ecca is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 10-18-2012 , 18:41   Re: Using BuildPath()
Reply With Quote #12

I dont know where went wrong but it not in there.

PHP Code:
new Handle:g_Health_cookie;
new 
Handle:g_Streangth_cookie;
new 
Handle:g_Endurance_cookie;
new 
Handle:g_Agility_cookie;

public 
OnPluginStart()
{
    
g_Health_cookie        RegClientCookie"luffy_health_cookie",        "L4D2 Luffy"CookieAccess_Protected );
    
g_Streangth_cookie    RegClientCookie"luffy_strength_cookie",        "L4D2 Luffy"CookieAccess_Protected );
    
g_Endurance_cookie    RegClientCookie"luffy_endurance_cookie",    "L4D2 Luffy"CookieAccess_Protected );
    
g_Agility_cookie    RegClientCookie"luffy_agility_cookie",        "L4D2 Luffy"CookieAccess_Protected );
}

public 
OnClientCookiesCachedclient )
{
    
decl String:rStorage[11];
    
    
GetClientCookieclientg_Health_cookierStoragesizeofrStorage ));
    
g_CleintHP[client][0] = StringToIntrStorage );
    
    
GetClientCookieclientg_Streangth_cookierStoragesizeofrStorage ));
    
g_ClientSTR[client] = StringToIntrStorage );
    
    
GetClientCookieclientg_Endurance_cookierStoragesizeofrStorage ));
    
g_ClientAGI[client] = StringToIntrStorage );
    
    
GetClientCookieclientg_Agility_cookierStoragesizeofrStorage ));
    
g_ClientEDN[client] = StringToIntrStorage );
}

public 
OnClientDisconnect_Postclient )
{
    
decl String:sStorage[11];
    
    
IntToStringg_CleintHP[client][0], sStoragesizeofsStorage ));
    
SetClientCookieclientg_Health_cookiesStorage );
    
g_CleintHP[client][0] = 0;
    
    
IntToStringg_ClientSTR[client], sStoragesizeofsStorage ));
    
SetClientCookieclientg_Streangth_cookiesStorage );
    
g_ClientSTR[client] = 0;
    
    
IntToStringg_ClientAGI[client], sStoragesizeofsStorage ));
    
SetClientCookieclientg_Endurance_cookiesStorage );
    
g_ClientAGI[client] = 0;
    
    
IntToStringg_ClientEDN[client], sStoragesizeofsStorage ));
    
SetClientCookieclientg_Agility_cookiesStorage );
    
g_ClientEDN[client] = 0;

__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 10-18-2012 , 20:20   Re: Using BuildPath()
Reply With Quote #13

Check databases.cfg. You'd probably want clientprefs to use SQLite when testing.
__________________

Last edited by FaTony; 10-18-2012 at 20:24.
FaTony is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 10-18-2012 , 20:31   Re: Using BuildPath()
Reply With Quote #14

Quote:
Originally Posted by FaTony View Post
Check databases.cfg. You'd probably want clientprefs to use SQLite when testing.
How m i do that?

EDIT: ahh.. you talking about the content of the databases.cfg.. what i saw there is empty?

Quote:
"clientprefs"
{
"driver" "sqlite"
"host" "localhost"
"database" "clientprefs-sqlite"
"user" "root"
"pass" ""
//"timeout" "0"
//"port" "0"
}
EDIT2: Do i need sever.. and must be server in order to do that? Because i m testing it via map <mapname>.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 10-18-2012 at 20:46.
GsiX is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 10-18-2012 , 20:44   Re: Using BuildPath()
Reply With Quote #15

Example:

Code:
"clientprefs"
    {
        "driver"            "sqlite"
        "database"            "clientprefs"
    }
__________________
FaTony is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 10-18-2012 , 20:55   Re: Using BuildPath()
Reply With Quote #16

What i m saying that i don't have a sever. Mostly i m making plugin on.. how to say this.. single player (lan game) or what ever the name is.

EDIT: m i still possible to do the test with this method?

PHP Code:
new Handle:g_hDataBase;

public 
OnPluginStart()
{
    
CreateDataBase();
}

public 
CreateDataBase()
{
    
ServerCommand"clear" );
    
PrintToServer"[LUFFY]: Creating Data Base" );
    new 
String:error[255];
    
g_hDataBase SQLite_UseDatabase"l4d2_luffy_database"errorsizeoferror ));
    
    if ( 
g_hDataBase == INVALID_HANDLE)
    {
        
SetFailState"[LUFFY]; SQL error: %s"error );
    }
    
    
SQL_LockDatabaseg_hDataBase );
    
SQL_FastQueryg_hDataBase"VACUUM" );
    
SQL_FastQueryg_hDataBase"CREATE TABLE IF NOT EXISTS savepoint_health (steamid TEXT PRIMARY KEY, timestamp INTEGER);");
    
SQL_UnlockDatabaseg_hDataBase );

__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 10-18-2012 at 21:00.
GsiX is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 10-18-2012 , 21:13   Re: Using BuildPath()
Reply With Quote #17

SQLite doesn't need a separate server and works completely inside Sourcemod. Set clientprefs to SQLite and have fun.

If you want full power of MySQL I suggest you XAMPP.
__________________

Last edited by FaTony; 10-18-2012 at 21:14.
FaTony is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 10-18-2012 , 21:43   Re: Using BuildPath()
Reply With Quote #18

Thanks for the suggestion but my net connection is 6k - 36k/s.. so no way i gonna own a sever..
GsiX is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 10-18-2012 , 22:18   Re: Using BuildPath()
Reply With Quote #19

Where i go wrong? I use player_hurt to save data and it does print to sever but the data never saved.

PHP Code:
new Handle:g_hDataBase;

public 
OnPluginStart()
{
    
CreateDataBase();
}

public 
CreateDataBase()
{
    
ServerCommand"clear" );
    
PrintToServer"[LUFFY]: Creating Data Base" );
    new 
String:error[255];
    
g_hDataBase SQLite_UseDatabase"clientprefs"errorsizeoferror ));
    
    if ( 
g_hDataBase == INVALID_HANDLE)
    {
        
SetFailState"[LUFFY]; SQL error: %s"error );
    }
    
    
SQL_LockDatabaseg_hDataBase );
    
SQL_FastQueryg_hDataBase"VACUUM" );
    
SQL_FastQueryg_hDataBase"CREATE TABLE IF NOT EXISTS savepoint_health (steamid TEXT PRIMARY KEY, test1 SMALLINT, test2 SMALLINT, test3 SMALLINT, timestamp INTEGER);");
    
SQL_UnlockDatabaseg_hDataBase );
}

public 
SaveToDataBase()
{
    for ( new 
1<= MaxClientsi++)
    {
        if ( 
IsClientInGame) && !IsFakeClient) && IsClientAuthorized))
        {
            
decl String:steamId[30];
            
decl String:query[200];
            
            
GetClientAuthStringisteamIdsizeof(steamId));
            new 
test1 100;
            new 
test2 200;
            new 
test3 300;
            
            
Formatquerysizeofquery ), "INSERT OR REPLACE INTO savepoint_health VALUES ('%s', %d, %d, %d, %d);"steamIdtest1test2test3GetTime());
            
SQL_FastQueryg_hDataBasequery );
            
PrintToServer"[LUFFY]: Syncronize data base for %N");
        }
    }
}

public 
Action:EVENT_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    
SaveToDataBase();

__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 10-19-2012 , 10:15   Re: Using BuildPath()
Reply With Quote #20

So why don't you use clientprefs?
__________________
FaTony 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 23:03.


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