Page 1 of 1

[ACS] Questions regarding Database features

Posted: Sat Dec 02, 2017 2:56 pm
by LordOZ_98
Hello (check spoiler for full story of what i'm trying to do)
Spoiler: (Open)
I'm trying to setup a system that changes level as soon as all players enter a specific sector (start sector), Here's how I set it up :

Code: Select all

bool PlayerAtSector[64];
int CurrentAmountAtSector;

script 107 ENTER //Player spawns at that sector
{
	 CurrentAmountAtSector = CurrentAmountAtSector+1;
         PlayerAtSector[playernumber()] = TRUE;
}
And I have the following script activated by player as soon as they leave the sector (ACS_ExecuteAlways), to subtract them from CurrentAmountAtSector

Code: Select all

script 109 (void) //Remove player from sector as soon as they leave it
{
	 PlayerAtSector[playernumber()] = FALSE;
	 CurrentAmountAtSector = CurrentAmountAtSector-1;
}
And the following script to ensure player is returned to that sector as soon as they die, because they will respawn at start location

Code: Select all

script 110 Death //Once player dies, return them to that sector
{
	 If(PlayerAtSector[playernumber()] == FALSE)
	 {
	 CurrentAmountAtSector = CurrentAmountAtSector+1;
         PlayerAtSector[playernumber()] = TRUE;
         }
}
It works fine, However i can't keep track of the player after they disconnect, I want to subtract them after they disconnect.

Code: Select all

script 108 (int gone) disconnect
{
If(PlayerAtSector[playernumber()] == TRUE)
	 CurrentAmountAtSector = CurrentAmountAtSector-1;
}
Is there anyway to store information of players to use them even after they disconnect ? I tried using arrays (check spoiler) But it didn't work, I'm I doing something wrong ?

[ACS] Re: Store player info via ACS ?

Posted: Sat Dec 02, 2017 3:04 pm
by Ivan
You need to use the database features of Zandronum for that.

Alternatively you can do something very ghetto and only let the same 64 people play in your servers. You can use variables for that but you can't shutdown your server at any point...

[ACS] Re: Store player info via ACS ?

Posted: Sat Dec 02, 2017 6:37 pm
by LordOZ_98
But is the incrementDBEntry going to work after player has already dsconnected ? will it work if I call it from a DISCONNECT script type ? the database tutorial mentioned in that article doesn't say anything about that.

[ACS] Re: Store player info via ACS ?

Posted: Sat Dec 02, 2017 8:32 pm
by Catastrophe
LordOZ_98 wrote:
Sat Dec 02, 2017 6:37 pm
But is the incrementDBEntry going to work after player has already dsconnected ? will it work if I call it from a DISCONNECT script type ? the database tutorial mentioned in that article doesn't say anything about that.
1. Yes if you saved his name already beforehand.
2. Same as above.

See here: https://zandronum.com/forum/viewtopic.php?t=6993

[ACS] Re: Questions regarding Database features

Posted: Mon Dec 04, 2017 9:53 am
by LordOZ_98
(Renamed thread to something related)
Thanks, one last questions, about SortDBEntries, how exactly do I use it, I've got bunch of results that i'd like to sort in order, What do I need to put for
"int limit, int offset, bool order"

limit and offset is confusing, they sound the same, sorry If I sound dumb lol.

EDIT : Nevermind, I just need to write a function to return a value.