my save stats system not working when i kill someone then i type /stats it tell kills 1 then when i do /q it say in console save stats player and when i rejoin and type /stats 0 kills and 0 deaths what is this?
this is savestats function
function SaveStats( player )
{
try{
local id = player.ID;
if ( status[ id ].IsReg == true )
{
QuerySQL( db, "UPDATE Account SET Kills='" + status[ id ].Kills + "', Deaths='" + status[ player.ID ].Deaths + "', Cash='" + status[ id ].Cash + "', Bank='" + status[ id ].Bank + "' WHERE Name='" + player.Name.tolower() + "'" );
print( "Saved Stats of Player " + player.Name + "[" + player.ID + "]" );
status[ id ] = null;
}
}
catch(e) print( "Save Stats Error: " + e );
}
Are you Sure that Your Database is saving nicks in tolower()
try changing
WHERE Name='" + player.Name.tolower() + "'
to WHERE Name='" + player.Name + "'
database save nicks in lower case
still not working
Have you tried opening the database and see if there's actually data in there?
yes thijn their is data
The correct data? If there is, show the code where you load the stats.
thijn i register with nick Finch and go in database there is in small finch then i set my kills in game and do /q and rejoin kills was 0
Are you using Warchief?
Then probably the fault is in accinfo
Post your accinfo function here
THere its is
function AccInfo( player )
{
try{
qPrivMessage( "** [" + player.ID + "] " + player.Name + " Joined the Server.", player );
if ( CheckBan( player ) == 1 ) Kick( player, "Server", "Banned From Server" );
status[ player.ID ] = PlayerStats();
local id = player.ID;
local ip = player.IP;
if ( GetLevel( player ) > 0 )
{
if ( ip != GetIP( player ) )
{
qPrivMessage( "Welcome to the Server " + player.Name + "!", player );
wPrivMessage( "You're Not Logged-In. Please login by /login <password>", player );
status[ player.ID ].IsReg = true;
status[ player.ID ].IsLogged = false;
}
else if ( ip == GetIP( player ) )
{
local q = QuerySQL( db, "SELECT * FROM Account WHERE Name='" + player.Name.tolower() + "'" );
if ( GetSQLColumnData( q, 0 ) != null )
{
status[ player.ID ].Kills = GetSQLColumnData( q, 4 );
status[ player.ID ].Deaths = GetSQLColumnData( q, 5 );
status[ player.ID ].Cash = GetSQLColumnData( q, 6 );
status[ player.ID ].Bank = GetSQLColumnData( q, 7 );
status[ player.ID ].Level = GetSQLColumnData( q, 2 );
}
GetSQLNextRow( q );
rPrivMessage( "Welcome to the Server " + player.Name + "!", player );
wPrivMessage( "You've Auto-Logged in onto the Server!", player );
status[ player.ID ].IsReg = true;
status[ player.ID ].IsLogged = true;
tPrivMessage( ">> " + player.Name + " Auto-Logged In.", player );
}
}
else
{
yPrivMessage( "Welcome to the Server " + player.Name + "!", player );
qPrivMessage( "You're Not Registered with us. Register by /register <password>", player );
}
}
catch(e) print( "AccInfo Error: " + e );
}
Click here (http://forum.vc-mp.org/?topic=336.msg1991#msg1991)
so ur mean that kills and deaths etc not save in server?
Man, if I were you I'd just stop. I'd clearly see that all this scripting and databases n sh!t isn't made for me and I'd just stop. And you wanna know why?
Because you're too dumb to understand what's going on, to properly explain to these people what you need. Actually, you don't even know what you're doing to begin with. All you can say is something like "Not work!" and give some sh!tty code, copied from god knows where.
Can't you see that most of your questions either remain unanswered or require 10 posts just to get an idea of what you're trying to do and another 20 just to give you pieces of code because you can't even fix a variable name or something when the author simply forgot about it.
I know that the word "persistence" in a CV is important but not here. Go and read that god damn Squirrel documentation to have an idea of the language it self. Then go read the SQLite documentation to make sure you actually know what a database is and whether your queries are correct.
And then you can come here and ask some proper questions which we can gladly answer. Seriously, take a break, go learn some basics and then come back to ask.
Few advices:
- Use the format() function for queries and stop concatenating those values. Squirrel is a dynamically typed language, which means that those variables can literally contain any value that the language supports. And when you concatenate them, there's no one to tell you that you have the incorrect data type when you expect a number and you get a string.
- Stop posting code that uses other private functions. Other people can't test that code or get any idea of what's happening. Because you also failed to describe the situation properly. Like my above post clearly insists on.
- Stop placing an entire function in a try/catch block. Learn what that is for, and then start using it. Again, read the Squirrel manual like my previous post suggests.
- Don't send your queries directly to the database. Form them in a string so that you can have a chance later to print them and see whether you have the correct query. Also, test them in other places where query errors are reported so you can pinpoint the source of the error.
One more question: Do you even debug your code? Or you just come here and every time something doesn't work.
Quote from: S.L.C on Mar 23, 2015, 10:16 AMOne more question: Do you even debug your code? Or you just come here and every time something doesn't work.
I don't think you need to ask that. The answer is No.
Edit: Finch kia tum urdu read kar saktay ho?
Reply me if you understood that finch.
Quote from: Finch on Mar 21, 2015, 01:47 PMmy save stats system not working when i kill someone then i type /stats it tell kills 1 then when i do /q it say in console save stats player and when i rejoin and type /stats 0 kills and 0 deaths what is this?
this is savestats function
function SaveStats( player )
{
try{
local id = player.ID;
if ( status[ id ].IsReg == true )
{
QuerySQL( db, "UPDATE Account SET Kills='" + status[ id ].Kills + "', Deaths='" + status[ player.ID ].Deaths + "', Cash='" + status[ id ].Cash + "', Bank='" + status[ id ].Bank + "' WHERE Name='" + player.Name.tolower() + "'" );
print( "Saved Stats of Player " + player.Name + "[" + player.ID + "]" );
status[ id ] = null;
}
}
catch(e) print( "Save Stats Error: " + e );
}
QuoteQuerySQL( db, "UPDATE Account SET Kills='" + status[ id ].Kills + "', Deaths='" + status[ player.ID ].Deaths + "', Cash='" + status[ id ].Cash + "', Bank='" + status[ id ].Bank + "' WHERE Name='" + player.Name.tolower() + "'" );
Are you sure these guys are stored as a string? Try changing to
QuerySQL( db, "UPDATE Account SET Kills=" + status[ id ].Kills + ", Deaths=" + status[ player.ID ].Deaths + ", Cash=" + status[ id ].Cash + ", Bank=" + status[ id ].Bank + " WHERE Name='" + player.Name.tolower() + "'" );
Not working crystal
function SaveStats( player )
{
try{
local id = player.ID;
if ( ( status[ player.ID ].IsReg == true ) && ( status[ player.ID ].IsLogged == true ) )
{
QuerySQL( db, "UPDATE Account SET Kills='" + status[ id ].Kills + "', Deaths='" + status[ player.ID ].Deaths + "', Cash='" + status[ id ].Cash + "', Bank='" + status[ id ].Bank + "' WHERE Name='" + player.Name.tolower() + "'" );
print( "Saved Stats of Player " + player.Name + "[" + player.ID + "]" );
status[ id ] = null;
}
}
catch(e) print( "Save Stats Error: " + e );
}
Try this.
Yeah i Can Understand Doom_Killer <.>
Again not working
Quote from: Finch on Mar 23, 2015, 03:10 PMYeah i Can Understand Doom_Killer <.>
Are you sure?
Quote from: Finch on Mar 23, 2015, 03:10 PMAgain not working
You're just dying to prove me right with every post you make ;D
Quote from: S.L.C on Mar 23, 2015, 10:07 AMAll you can say is something like "Not work!" and give some sh!tty code, copied from god knows where.
Quote from: Finch on Mar 23, 2015, 03:10 PMYeah i Can Understand Doom_Killer <.>
Again not working
Sorry if this is against rules but maybe this will reduce this disaster.
Finch Khuda kay leye agr ap scripting nahi kar saktay to na karein kyun kay ap ko samajh nahi aati aur aap theke.tara say error bhi nahi post kartay, Behtar ho ga agar aap dosroon kay server mein khelein ya phir jald jab mera server host ho jai ga jo kay mein apnay aik bro kay sath bana raha hun to ap wahan bhi khelna. Laiken agar aap kisi tareeqay say bhi scripting karna nahi chorna chahte to theke hai magar kam as kam error to theke post kia karein, console aur script notepad mein khol kar os error line ki bhi screen lia karo aur post karo aur jitna ho sakay detail dia karo error ki, aur agar aap sahi tareeqay say post karo gey i bet koi aap ki insult nahi karay ga.
:)
Hope you will act upon my advice.
me janta hu doom magr is me post karne me he hi kya phr bhi yeh lo screen shot sari cheezo ke phele set kills in server ke stats cmd ke sath
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi60.tinypic.com%2Fszx650.png&hash=02c0dc911c9ce11a5b1cb5ef606e31873988a039)
or ab console ki screen shot
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi60.tinypic.com%2Fw7k2v7.png&hash=a151b257050f3107a04949aba8868ad609682763)
or yeh ab rejoin server ki stats cmd ke sath
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi62.tinypic.com%2F161hjio.png&hash=398764d49f1a3fb771041207d3bcf973a3ca891e)
Quote from: Finch on Mar 24, 2015, 08:27 AMor ab console ki screen shot
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi60.tinypic.com%2Fw7k2v7.png&hash=a151b257050f3107a04949aba8868ad609682763)
Yeh tumhe kahan se console ka screenshot lagta he?
English: From where does it look like a screenshot of console?
Database is fucked up.
Try deleting the db and then try.
Quote from: NE.CrystalBlue on Mar 24, 2015, 08:58 AMQuote from: Finch on Mar 24, 2015, 08:27 AMor ab console ki screen shot
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi60.tinypic.com%2Fw7k2v7.png&hash=a151b257050f3107a04949aba8868ad609682763)
Yeh tumhe kahan se console ka screenshot lagta he?
English: From where does it look like a screenshot of console?
Guzara karta hai, atleast samajh to a rahi hai.
try what robinx said.
I know that it will not help you, but:
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi62.tinypic.com%2Feukdi9.png&hash=84d249092ebb0bf57045ddada83b67e098317628)
2x the same module
Quote from: rwwpl on Mar 24, 2015, 12:26 PMI know that it will not help you, but:
2x the same module
The functions will simply be overwritten by the second loaded module. If the functions weren't available then you'd get a message like "
index doesn't exist". I'm sure the bug is really simple. I'll look later into the SQLite module of stormeus and see if I can add proper error reporting. That way you will know there's something wrong with the query if it fails.
Off: Guys maybe you didnt noticed but in his top 5 killers have 900 kills so it is clear that none of his function have problem, maybe his stats cmd is bugged
I tried to make some attempts to conclude something from the codes he posted , here they are :-
-> On console , it prints that his stats saved
This points that the value that array holds is actually transferred to the database because his Savestats function do not have any issue . Thus , it is actually called .
-> When he sets his kills to 900 then this change appear in stats on that particular Join
This points that he is making change to the array variables & so stats gets modified as well .
-> On Next Join, his name appear on Top 5 Killers
This points that arrays were successful in transferring the changed value of Kills on previous Join & that Top 5 list will be made by getting Kills directly from the database .
-> But , on next Join, his kills doesn't gets modified in Stats
This points that arrays aren't syncing anything from the database during login . The arrays are just exploited as one-way . They just transfer the value to the database but aren't designed to get anything from the database when a player does login .
So , After having a glance at all the possibilities , Its the arrays which aren't getting anything from the database while they are supposed to .
Then why the kills & deaths are showing as 0 when player types stats command ?
Answer : Because they're initialized as 0 in class PlayerStats . This way :-
class PlayerStats
{
Kills = 0;
Deaths = 0;
}
Without getting the values from the database , how can u expect that this will appear on your stats ? You need to make a request to the database so that it will give you its contents .
What should you do ?
-> You should take the Kills value from the database so that they can be stored in array & thus making up your stats .
OffTopic :- I tried to tell you this fact here (http://forum.vc-mp.org/?topic=408.msg2664#msg2664) but you haven't responded . Anyway , make those changes to your login function I described & make them sync Kills , Deaths etc otherwise it will do the same for the remaining values as well .
Quote from: Kratos_ on Mar 24, 2015, 03:25 PMWithout getting the values from the database , how can u expect that this will appear on your stats ? You need to make a request to the database so that it will give you its contents .
LOL it's not the first time he did
this (http://forum.vc-mp.org/?topic=336.msg1962#msg1962). Same thing happened with his previous account. That's why I've told you so simply ignore the question because he doesn't know what he's doing.
so what is method to correct savestats?
Quote from: Finch on Mar 27, 2015, 05:24 AMso what is method to correct savestats?
Do it yourself. We are not helping you. You really need to know a very basic things. Thats why if you dont know them you shouldnt scripting.