[Include] Tksave - Easy SQLite saving for players
#1

TKsave

Introduction
This is a really basic include just to show you how useful SQLite can be. Information saves into a database and can be used easier for web files . I'm not going to make one of those "This is very efficient topic" because it's probably not as fast as most file saving systems.

How do I install this?
1. Put the include in your server directory -> Pawno -> includes
2. Add this to the top of your script
pawn Код:
#include <tksave>
Functions

pawn Код:
/*
native sql_setplayerdata(playerid, field[], data[]); -  Sets a player's data (string)
native sql_isplayerindb(playerid); - Checks if a player is in the database
native sql_getplayerdata(playerid, field[]); - Gets a player's data (string)
native sql_getplayerint(playerid, field[]); - Gets a player int from the database
native sql_getplayerfloat(playerid, field[]); // Gets a player's float from the database
native sql_setplayerfloat(playerid, field[], Float:data); - Set's a players float (could be used for a position)
native sql_setplayerint(playerid, field[], data); // Sets a players int (Could be used for money or admin lvl)
native sql_addfield(field[], type, MAXSIZE); - Add a table field such as password (Type 0 = Number, Type 1 = String, Type 2 = Float)
native sql_getusercount(); // Get the amount of users registered
native sql_inittable(); // Set's up the database / table (Only need to use this once but it won't make a difference if you leave it there)
native sql_open(sql[]); //Opens a SQL database (Chose a name for your database). This must be above everything on OnGameModeInit or OnFilterScriptInit. You must add .db on the end!
native sql_close(sql[]); //Closes the database, this is to be used on OnGameModeInit or OnFilterScriptInit. You must add .db on the end!
*/
Example

Saving a players position on Disconnect then loading it on OnPlayerSpawn.
pawn Код:
public OnFilterScriptInit()
{
    sql_open("database.db");
    sql_inittable();
    sql_addfield("X", 2, 50);
    sql_addfield("Y", 2, 50);
    sql_addfield("Z", 2, 50);
    return 1;
}

public OnFilterScriptExit()
{
    sql_close("database.db");
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new Float:X, Float:Y, Float:Z;
    sql_setplayerfloat(playerid, "X", X);
    sql_setplayerfloat(playerid, "Y", Y);
    sql_setplayerfloat(playerid, "Z", Z);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(sql_isplayerindb(playerid))
    {
        SetPlayerPos(playerid, sql_getplayerfloat(playerid, "X"), sql_getplayerfloat(playerid, "Y"), sql_getplayerfloat(playerid, "Z"));
    }
    return 1;
}
Download
HERE

Any bugs, post them here .
Reply


Messages In This Thread
Tksave - Easy SQLite saving for players - by [HiC]TheKiller - 22.07.2011, 00:17
Re: Tksave - Easy SQLite saving for players - by willsuckformoney - 22.07.2011, 00:21
Re: Tksave - Easy SQLite saving for players - by The_$ - 22.07.2011, 00:25
Re: Tksave - Easy SQLite saving for players - by [HiC]TheKiller - 22.07.2011, 00:36
Re: Tksave - Easy SQLite saving for players - by Scenario - 22.07.2011, 03:17
Re: Tksave - Easy SQLite saving for players - by PCheriyan007 - 22.07.2011, 03:44
Re: Tksave - Easy SQLite saving for players - by Scenario - 22.07.2011, 03:49
Re: Tksave - Easy SQLite saving for players - by [HiC]TheKiller - 22.07.2011, 04:20
Re: Tksave - Easy SQLite saving for players - by Igorek - 22.07.2011, 04:20
Re: Tksave - Easy SQLite saving for players - by Kaperstone - 22.07.2011, 10:55
Re: Tksave - Easy SQLite saving for players - by Zh3r0 - 22.07.2011, 11:07
Re: Tksave - Easy SQLite saving for players - by MoroDan - 22.07.2011, 11:07
Re: Tksave - Easy SQLite saving for players - by Lorenc_ - 22.07.2011, 12:03
Re: Tksave - Easy SQLite saving for players - by PCheriyan007 - 22.07.2011, 15:37
Re: Tksave - Easy SQLite saving for players - by Mrki_Drakula - 22.07.2011, 17:03
Re: Tksave - Easy SQLite saving for players - by Steven82 - 24.07.2011, 01:29
Re: Tksave - Easy SQLite saving for players - by boelie - 01.04.2012, 15:36
Re: Tksave - Easy SQLite saving for players - by Adi007 - 23.04.2015, 09:31
Re: Tksave - Easy SQLite saving for players - by Extremo - 23.04.2015, 10:57
Re: Tksave - Easy SQLite saving for players - by JokeyL - 25.11.2016, 08:10

Forum Jump:


Users browsing this thread: 1 Guest(s)