I have this error in console when a player leaves the server, and i cant figure out why.
Here is the console error:
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2F217.120.23.210%2Fimages%2F02.png&hash=6e1ff13394e96d9a612278ade1c14a00709d1b51)
here is line 239:
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2F217.120.23.210%2Fimages%2F01.png&hash=ea273f0a2dec03f5f4886837407d03231c559da9)
And here is my OnplayerPart:
function onPlayerPart( player, reason, )
{
if( stats[ player.ID ].Level != 0 )
{
if ( stats[ player.ID ].Team )
{
local plr = GetPlayer( stats[ player.ID ].Teamp );
EMessage( ">>" + player.Name + " left the Team." );
stats[ plr.ID ].Teamp = null;
stats[ player.ID ] = null;
}
stats[ player.ID ].Update( player, sqliteDB );
print( ">> " + player.Name + "'s data saved." );
// Remember to save regularly
SunshineAutos.SaveDatabase("scripts/sunshine.db");
print( ">> " + player.Name + "'s carsdata saved." );
if ( stats[ player.ID ].LMS )
{
EMessage( ">> " + player.Name + " is out of the LMS round." );
LMSCount--;
if ( LMSCount == 1 ) CheckEnd2();
}
}
stats[ player.ID ] = null;
playerson.remove( player.ID );
EchoMessage( "** [" + player.ID + "] " + player.Name + " has left the server." );
}
Also i cant get stats to save to the db same for rulks sunshine, exept acc does get saved. Im using ADM script as the base.
Post your onPlayerJoin
Quote from: Thijn on May 08, 2016, 08:16 PMPost your onPlayerJoin
Here it is Thijn
function onPlayerJoin( player )
{
if ( CheckBan( player ) == 1 ) NewTimer( "Kick", 3000, 1, player.ID );
playerson.push( player.ID );
stats[ player.ID ] = PlayerClass( player.Name, sqliteDB );
stats[ player.ID ].Join( player );
EchoMessage( "** [" + player.ID + "] " + player.Name + " has joined the server." );
MessagePlayer( "[#FFFF00]Your LMS Stats: Played: " + stats[ player.ID ].Played + " Won: " + stats[ player.ID ].Wins + " Lost: " + stats[ player.ID ].Lost + " .", player);
C.ShowForPlayer( player );
AddAlias( player );
local country = geoip_country_name_by_addr(player.IP);
if (country != null) // the plugin returned a meaningful result
Message("[#FFFF00]* " + player.Name + " [#00ff00]Has connected from " + country + ". [" + geoip_country_code_by_addr(player.IP) + "]");
}
function Update( player, dbGlobal )
{
::QuerySQL( dbGlobal, "UPDATE Accounts SET Cash=" + Cash + ", Bank=" + Bank + ", Kills=" + Kills + ", Deaths=" + Deaths + ", Level=" + Level + ", LastUsedIP='" + LastUsedIP + "' WHERE Name='" + player.Name + "' AND NameLower='" + player.Name.tolower() + "'" );
}
@Ron, remove that line and add this:
local idx = playerson.find( player.ID );
if( idx != null ) playerson.remove( idx );
Quote from: KAKAN on May 09, 2016, 05:31 AM@Ron, remove that line and add this:
local idx = playerson.find( player.ID );
if( idx != null ) playerson.remove( idx );
Thanks KAKAN the error in console is solved. :)
Still stats and cars dont get saved into databases
Quote from: Ron on May 09, 2016, 07:35 AMThanks KAKAN the error in console is solved. :)
Still stats and cars dont get saved into databases
I can't do anything if you don't show me the required code.
What do you need? here is on player part
stats[ player.ID ].Update( player, sqliteDB );
print( ">> " + player.Name + "'s data saved." );
// Remember to save regularly
SunshineAutos.SaveDatabase("scripts/sunshine.db");
print( ">> " + player.Name + "'s carsdata saved." );
if ( stats[ player.ID ].LMS )
{
EMessage( ">> " + player.Name + " is out of the LMS round." );
LMSCount--;
if ( LMSCount == 1 ) CheckEnd2();
}
}
stats[ player.ID ] = null;
playerson.remove( player.ID );
EchoMessage( "** [" + player.ID + "] " + player.Name + " has left the server." );
}
and here savestats:
function SaveStats( player )
{
try{
local id = player.ID;
if ( status[ id ].IsReg == true )
{
QuerySQL( sqliteDB, "UPDATE Account SET Kills='" + status[ id ].Kills + "', Killed='" + status[ id ].Killed + "', Deaths='" + status[ player.ID ].Deaths + "', Cash='" + status[ id ].Cash + "', Bank='" + status[ id ].Bank + "', Joins='" + status[id].Joins + "' WHERE Name='" + player.Name + "'" );
print( "Saved Stats of Player " + player.Name + "[" + player.ID + "]" );
status[ id ] = null;
}
}
catch(e) print( "Save Stats Error: " + e );
}
Quote from: Ron on May 09, 2016, 02:05 PMstats[ player.ID ].Update( player, sqliteDB );
if ( status[ id ].IsReg == true )
Makes so damn sense.
Quote from: Doom_Kill3R on May 09, 2016, 02:25 PMQuote from: Ron on May 09, 2016, 02:05 PMstats[ player.ID ].Update( player, sqliteDB );
if ( status[ id ].IsReg == true )
Well sorry im kinda new to this. and try to learn
but if i get you right, it should be if ( stats[ player.id ].IsReg == true )
Makes so damn sense.
use this:
stats[ player.ID ].Update( player, sqliteDB );
print( ">> " + player.Name + "'s data saved." );
// Remember to save regularly
SunshineAutos.SaveDatabase("scripts/sunshine.db");
print( ">> " + player.Name + "'s carsdata saved." );
if ( stats[ player.ID ].LMS )
{
EMessage( ">> " + player.Name + " is out of the LMS round." );
LMSCount--;
if ( LMSCount == 1 ) CheckEnd2();
}
}
stats[ player.ID ] = null;
local idx = playerson.find( player.ID );
if( idx != null ) playerson.remove( idx );
EchoMessage( "** [" + player.ID + "] " + player.Name + " has left the server." );
}
when using
if ( status[ id ].IsReg == true )
It's good practice to use in this method
if (( status[ id ].IsReg) == true )
Quote from: Mötley on May 09, 2016, 05:08 PMwhen using
if ( status[ id ].IsReg == true )
It's good practice to use in this method
if (( status[ id ].IsReg) == true )
Why would it?
Really!?
That's the worst check I have ever seen.
You should always use this method as checking what you want from it.
You should get the class veritable then add the second check as follows. anything else with checking true or false
if ( status[ id ].IsReg == true )
or what ever could create errors as well as I have seen this happen for myself, the class gets basically a call for
status[ id ].IsReg
then the class needs to check true or false. Why would you do this way when its not as hard on the classes this way when it can get the class id then get/check the actual value in that class
if (( status[ id ].IsReg) == true )
*There is more in detail I could go into but I am busy..
Ah I just noticed the == true. That part is retarded.
if ( status.IsReg )
Works just fine.
Unless your code is totally fucked and IsReg doesn't actually return true/false...
I find It's best to run the class then get the value. instead of just checking the class in general..
example
local
Level = Account.[player.id].Level,
Stats = Account[player.id].Stats;
Then you could run checks off of the value its already getting on its own.
if (cmd == "kick") {
if (Level < 1) {
MessagePlayer("Invalid cmd type /cmds", player);
return true;
}
This will return the value in the class
if (( status[ id ].IsReg) == true )
Gets the class value without working the class improperly as you have already gotten the value, now what did the value return ? etc. instead on making a call on the class for does the value already == true
I prefer to not go into stronger detail as I will begin to get confusing ,,.
@KAKAN still it doesnt save anything yet
and Mötley thnx for the explanation
Show your register functions
Quote from: Hercules on May 10, 2016, 10:03 AMShow your register functions
No need of register function
I think the prb is he has added nos or maybe spectate and after player left trying to remove it can you tell for what is that players on used see onplauerentervehicle or search playerson in your entire script and tell where ever it is
Hey Dude !!
This Is Full Of Your OnPlayerPart ? If Yes Then You Didn't Added Savestats(player);
Quote from: Saiyan Attack on May 10, 2016, 10:52 AMHey Dude !!
This Is Full Of Your OnPlayerPart ? If Yes Then You Didn't Added Savestats(player);
Wtf why you need save stats here try to solve his prb not increase it there is mix need of savestats function here it is not related to this prb
Quote from: Ron on May 10, 2016, 07:32 AM@KAKAN still it doesnt save anything yet
and Mötley thnx for the explanation
What? What's the new error?
Quote from: Coolkid on May 10, 2016, 10:45 AMQuote from: Hercules on May 10, 2016, 10:03 AMShow your register functions
No need of register function
I think the prb is he has added nos or maybe spectate and after player left trying to remove it can you tell for what is that players on used see onplauerentervehicle or search playerson in your entire script and tell where ever it is
i have much experience about stats not saving :D
I dont get any error in console, only the stats dont get saved into database, same for cars (sunshine by rulk). but the registerinfo does get saved.
Oh and yes i have NoS in script i use ADM as the base wich also includes NoS
@KAKAN Could it be in this part?
function SaveStats( player )
{
try{
local id = player.ID;
if ( stats[ player.ID ].IsReg == true )
{
QuerySQL( sqliteDB, "UPDATE Account SET Kills='" + stats[ player.ID ].Kills + "', Killed='" + stats[ player.ID ].Killed + "', Deaths='" + stats[ player.ID ].Deaths + "', Cash='" + stats[ player.ID ].Cash + "', Bank='" + stats[ player.ID ].Bank + "', Joins='" + stats[player.ID].Joins + "' WHERE Name='" + player.Name + "'" );
print( "Saved Stats of Player " + player.Name + "[" + player.ID + "]" );
stats[ player.ID ] = null;
}
}
catch(e) print( "Save Stats Error: " + e );
}
As it doesnt print "Saved Stats of Player " and also no Save stat error msg.
I tried without {try{ then it gives an error in console line 94 M-echo.nut : Index GeTok does not exist.
wich is this line:
local FBS_PING = GetTok( line, " ", 1 ), FBS_EVENT = GetTok( line, " ", 2 ), FBS_CHANEVENT = GetTok( line, " ", 3 );
I feel sorry for you, as you can't even read English.
That error means that the function 'GetTok' doesn't exist.
Quote from: KAKAN on May 11, 2016, 05:38 PMI feel sorry for you, as you can't even read English.
That error means that the function 'GetTok' doesn't exist.
I can read english lol, the error is when i removed (try), anyway the function does exist.
i just cant seem to figure out why nothing saves to the db.
with sunshine script it saves untill server reboot, but db stays empty (it does read from it)
and stats nothing saves
and the function SaveStats( player )
doesnt return msg or error msg
Then probably IsReg is false.