I Use This Stats System ===> http://liberty-unleashed.co.uk/vicewiki/index.php?title=Scripting/Squirrel/Examples/SQLite&oldid=1046
but is not work i type /stats ali its send me ali stats: :/ I Type /kill and open stats database its Don't add kills or deaths.
Stats Cmd
else if ( cmd == "stats" )
{
if ( text )
{
local plr = FindPlayer( text );
if ( !plr ) MessagePlayer( "Player " + text + " is not online." );
else
{
local plrStats = stats[ plr.ID ];
MessagePlayer( plr.Name + "'s stats:", player );
MessagePlayer( "Kills: " + plrStats.Kills + ", Deaths: " + plrStats.Deaths, player ); <====== Error On This Line
MessagePlayer( "Joins: " + plrStats.Joins, player );
}
}
else MessagePlayer( "Usage: /c stats <player>", player );
}
Onplayepart
// Load the player stats from the array + lowercase name
local
id = player.ID,
name = player.Name.tolower();
// If player had any data in the database, update the old stats
if ( stats[ id ].PreviousData )
{
// Format the query string using 'format'
local query = format( "UPDATE Stats SET Kills=%i, Deaths=%i, Joins=%i WHERE Name='%s'",
stats[ id ].Kills, stats[ id ].Deaths, stats[ id ].Joins, name );
// Then execute the query
QuerySQL( statDB, query )
}
else
{
local query = format( "INSERT INTO Stats (Name, Kills, Deaths, Joins) VALUES ('%s', %i, %i, %i)", <====== Error On This Line
name, stats[ id ].Kills, stats[ id ].Deaths, stats[ id ].Joins );
QuerySQL( statDB, query );
}
stats[ id ] = null;
Cmd Error MessagePlayer( "Kills: " + plrStats.Kills + ", Deaths: " + plrStats.Deaths, player );
Onplayerpart Error local query = format( "INSERT INTO Stats (Name, Kills, Deaths, Joins) VALUES ('%s', %i, %i, %i)",
Would it kill someone if you people learned to place the code snippets into the proper BB tags? DA FUQ IS WRONG WITH YOU? Any specific error message or you just let that at our discretion? Oh, wait. You think we're some advanced beings that read minds and predict the future. Right? I'm gonna ignore this thread and let someone else waste 5-10 posts just to get an error message from you.
I will try: What error you get in server's console ? You can add an image with it. ;)
Do you have the player class created and defined in onplayerjoin?
Do you have stats <- array( GetMaxPlayers(), null ); in onscriptload?
and what happened with the onplayerkill and onplayerdeath.
in the page, down (in the end) there is a full example with all functions of how you have to do it.
http://postimg.org/gallery/2rcn32hcy/ Pictures Link Fjose I Add Stats array and pplayercass u can see in this pictures :-(
In your PlayerStats class you have "kills" (NOTICE: it's all lowercase) and you're asking for "Kills" (NOTICE: "K" is uppercase). If I'm not mistaken Squirrel is case-sensitive. Therefore "kills" and "Kills" are two different things.
Thanks S.L.C its show me death and kills ;-) But ITs Can't Add stats in Database :/ Pls Help me :-(
Are you sure that you have those tables in the database? You might be getting this error due to lower or upper case issues.
QuerySQL( statDB, "CREATE TABLE Stats ( Name VARCHAR(32), Kills INT, Deaths INT, Joins INT )" ); yes i have table
If you have the table then why do you attempt to create it again.
QuerySQL(statDB, @"CREATE TABLE IF NOT EXISTS [Stats] (
[Name] VARCHAR(32) NOT NULL,
[Kills] INT DEFAULT '0' NULL,
[Deaths] INT DEFAULT '0' NULL,
[Joins] INT DEFAULT '0' NULL
)");
not work :/
now database add My account but server cant add Kills And Deaths Pls Help me :(
I just tested the script (http://liberty-unleashed.co.uk/vicewiki/index.php?title=Scripting/Squirrel/Examples/SQLite&oldid=1046) from wiki, and it works properly. The serverstats.sqlite database was created when I started the server.
Make sure you did:- copy every line in the correct event
- load sqlite04rel32/64.dll module in server.cfg
dude my problem is ====> http://postimg.org/image/vpqdru4sh/ server create my account 1 time 2 time bla bla bla 100 time :/ You Can see This Pictures
Have you specified somewhere this:-
stats[player.ID].PreviousData = true;
If you haven't, then that's why the record is inserting again & again.
Create the new record in table when the player registers. If something unusual happened then their records will not be created. On Player leave, save the player stats.[ No need to insert at that event ]. In login cmd & in register cmd too , set the above condition.
That's because your query inserts a new row every time instead of updating the old one.
Topic Locked My Problem Solved :D Thanks YouAll Thanks s.L.C And Seeby