Tksave - Easy SQLite saving for players -
[HiC]TheKiller - 22.07.2011
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
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
.
Re: Tksave - Easy SQLite saving for players -
willsuckformoney - 22.07.2011
Nice, I could use it when I start to learn SQlite * MySQL.
Re: Tksave - Easy SQLite saving for players -
The_$ - 22.07.2011
Again very nice work TheKiller...
I love your scripts
. It very usefull for SQL beginner's like me.
// Edit - Can someone make a example i get to many error's
Re: Tksave - Easy SQLite saving for players -
[HiC]TheKiller - 22.07.2011
Quote:
Originally Posted by The_$
Again very nice work TheKiller...
I love your scripts . It very usefull for SQL beginner's like me.
// Edit - Can someone make a example i get to many error's
|
Updated with a example!
EDIT: Found a little typo, fixed it though.
Re: Tksave - Easy SQLite saving for players -
Scenario - 22.07.2011
I just noticed this. It looks pretty good man! I'm glad to see you active again.
Re: Tksave - Easy SQLite saving for players -
PCheriyan007 - 22.07.2011
I'm not sure but is there something like this for MySQL? I'm thinking about doing a dynamic player stats signature and AFAIK, SQLite only works if the server and the website are on the same box.
Re: Tksave - Easy SQLite saving for players -
Scenario - 22.07.2011
Quote:
Originally Posted by PCheriyan007
I'm not sure but is there something like this for MySQL? I'm thinking about doing a dynamic player stats signature and AFAIK, SQLite only works if the server and the website are on the same box.
|
You can always set up an FTP connection to update the SQLite database whenever changes are made.
Re: Tksave - Easy SQLite saving for players -
[HiC]TheKiller - 22.07.2011
Quote:
Originally Posted by PCheriyan007
I'm not sure but is there something like this for MySQL? I'm thinking about doing a dynamic player stats signature and AFAIK, SQLite only works if the server and the website are on the same box.
|
It's really easy to just change it. All you really need to do is add a few params + the function name. I'll make that later :P.
Re: Tksave - Easy SQLite saving for players -
Igorek - 22.07.2011
good work...
Thanks.
Re: Tksave - Easy SQLite saving for players -
Kaperstone - 22.07.2011
like it
i will use it 100%
thanks!
Re: Tksave - Easy SQLite saving for players -
Zh3r0 - 22.07.2011
Slice made something like this, but more advanced. The BUD(Blazing User Database) system.
Gratz on it!
Re: Tksave - Easy SQLite saving for players -
MoroDan - 22.07.2011
Well done. I'm sure I'll use this.
Re: Tksave - Easy SQLite saving for players -
Lorenc_ - 22.07.2011
JIZZZZ
Nice job, looks really hot after I saw the functions <3
Re: Tksave - Easy SQLite saving for players -
PCheriyan007 - 22.07.2011
Quote:
Originally Posted by [HiC]TheKiller
It's really easy to just change it. All you really need to do is add a few params + the function name. I'll make that later :P.
|
Well I'll be definitely waiting for that release
Re: Tksave - Easy SQLite saving for players -
Mrki_Drakula - 22.07.2011
Well done!!!!
Re: Tksave - Easy SQLite saving for players -
Steven82 - 24.07.2011
This is pretty cool. I think i'll be using this for the community project, since it's pretty straight forward and simple to use.
Re: Tksave - Easy SQLite saving for players -
boelie - 01.04.2012
This realy helps me out thanks!
one question;
if i try creating a vehicle from the database this way;
pawn Код:
CreateVehicle(sql_getplayerfloat(playerid,"model"),sql_getplayerfloat(playerid,"X"),sql_getplayerfloat(playerid,"Y"),sql_getplayerfloat(playerid,"Z"),sql_getplayerfloat(playerid,"A"),5, 5,500);
I get a warning: tag mismatch...however, if i replace de model with a vehicle number it does work so its just this part sql_getplayerfloat(playerid,"model") ..any ideas how to fix ?
Re: Tksave - Easy SQLite saving for players -
Adi007 - 23.04.2015
Dead link...i want it please...
Re: Tksave - Easy SQLite saving for players -
Extremo - 23.04.2015
Quote:
Originally Posted by Adi007
Dead link...i want it please...
|
This thread is from 2012!! How would you even find it. There are better systems these days. Not to mention this completely ignores normalisation. Why does everyone just use mysql/sql as a storage system without realizing it is a modular system with it's own language and should be considered just if not equally as important than the gamemode itself!
https://sampforum.blast.hk/showthread.php?tid=303682
https://sampforum.blast.hk/showthread.php?tid=187720
There, use those two systems. Remember it also ignores normalisation.. but I doubt most of you even care about proper usage anyway.
Re: Tksave - Easy SQLite saving for players -
JokeyL - 25.11.2016
Download link?