Hello I'm having difficulties finding the problem with the script I'm using, I use Cora CP with the user counter script that must be plugged into the game to function however I have ran into an issue where the player count will never properly dispaly or go back down to zero. Players Peaked seems to work properly though.
- script user_counter -1,{
OnPCLoginEvent:
query_sql("SELECT value FROM mapreg WHERE varname='userOnline'",.@lastOnline);
if(getarraysize(.@lastOnline) == 0) {
query_sql("INSERT INTO mapreg(varname,value) VALUE('userOnline',1)");
set .@userOnline,1;
} else {
query_sql("UPDATE mapreg SET value=value+1 WHERE varname='userOnline'");
set .@userOnline,.@lastOnline[0]+1;
}
query_sql("SELECT value FROM mapreg WHERE varname='userPeak'",.@userPeak);
if((.@userOnline > .@userPeak[0]) || (getarraysize(.@userPeak) == 0)) {
if(getarraysize(.@userPeak) == 0)
.@newPeak$ = "INSERT INTO mapreg(varname,value) VALUE('userPeak',"+.@userOnline+")";
else
.@newPeak$ = "UPDATE mapreg SET value="+.@userOnline+" WHERE varname='userPeak'";
query_sql(.@newPeak$);
.@peak = .@userOnline;
} else {
.@peak = .@userPeak[0];
}
end;
OnPCLogoutEvent:
query_sql("SELECT value FROM mapreg WHERE varname='userOnline'",.@lastOnlineB);
if(.@lastOnlineB[0] > 1)
query_sql("UPDATE mapreg SET value=value-1 WHERE varname='userOnline'");
else
query_sql("DELETE FROM mapreg WHERE varname='userOnline'");
end;
}
I thought it was just having issues by a single count but later I noticed sometimes the count would not go back down, I have 2 players in the server while the count says 4 it seems to go down then I log out but sometimes it goes up by 1 for good. Sorry I'm having a hard time explaining my issue here, so my question is.
Does anything in this code look like it could be causing the potential problem I looked at it and it looks fine to me I thought of a temp solution is to have it reset on server startup. but something causes the counter to decide to not go down a digit.