Altitude Game: Forums  

Go Back   Altitude Game: Forums > Altitude Support > Suggestions

Suggestions Post ideas and suggestions here.

Reply
 
Thread Tools Display Modes
  #1  
Old 08-27-2011, 05:55 PM
idk idk is offline
Senior Member
 
Join Date: Feb 2010
Location: Sweden
Posts: 120
Default Dump "listPlayers" to log.txt

Hello!

When i start my script, it needs to know which players are already connected to the server. So the script requests a list of all players by executing the command "listPlayers", but the only output I can see is the in-game console and the server console.

Here is how the JSON-item looks like now:
Code:
{"port":27276,"time":73931,"arguments":[],"source":"00000000-0000-0000-0000-000000000000","command":"listPlayers","group":"server","type":"consoleCommandExecute"}
It would have been very nice to write this list to the "log.txt" It would have been ever better if it gave me the same data as "clientAdd" does. If it only gave me playerId, I could loop thru those with some kind of player information command.

Last edited by idk; 08-27-2011 at 05:58 PM.
Reply With Quote
  #2  
Old 08-27-2011, 08:31 PM
mikesol mikesol is offline
Super Moderator
 
Join Date: Jul 2009
Location: Portland, OR
Posts: 2,183
Default

Quote:
Originally Posted by idk View Post
Hello!

When i start my script, it needs to know which players are already connected to the server. So the script requests a list of all players by executing the command "listPlayers", but the only output I can see is the in-game console and the server console.

Here is how the JSON-item looks like now:
Code:
{"port":27276,"time":73931,"arguments":[],"source":"00000000-0000-0000-0000-000000000000","command":"listPlayers","group":"server","type":"consoleCommandExecute"}
It would have been very nice to write this list to the "log.txt" It would have been ever better if it gave me the same data as "clientAdd" does. If it only gave me playerId, I could loop thru those with some kind of player information command.
Why do you need to have list players in the log? Every time a player joins or leaves the server you should be updating your log with the respective information.

For instance in java you might do something like:
Code:
private Map<UUID, Integer> playerIdByVaporId = new HashMap<UUID, Integer>();
private Map<Integer, UUID> vaporIdByPlayerId = new HashMap<Integer, UUID>();
private Map<UUID, String> nicknameByVaporId = new HashMap<UUID, String>();

if (CompareHelper.equals(type,"clientAdd")) {

UUID vaporID = UUID.fromString(jsonObject.getString("vaporId"));
String nickname = jsonObject.getString("nickname");
int playerId = jsonObject.getInt("player");
String ip = jsonObject.getString("ip");

String[] parsedIp = ip.split(":");

playerIdByVaporId.put(vaporId, playerId);
vaporIdByPlayerId.put(playerId, vaporId);
nicknameByVaporId.put(vaporId, nickname);

<insert sql code to add player to database here>

...
}

Then when they leave you'd remove them from the respective hashmaps.
__________________
We can has sigs?
Reply With Quote
  #3  
Old 08-28-2011, 12:53 AM
nobodyhome nobodyhome is offline
Senior Member
 
Join Date: Apr 2009
Posts: 1,088
Default

Mikesol, you can do it the way you are describing (and it is the way ladder does it), but having a way to get the players currently present in the game is useful if you want to be able to start the script after the server is already up. If the server is already up then you don't know at the moment which players' vaporids are mapped to which JSON log playerId.
Reply With Quote
  #4  
Old 08-28-2011, 07:42 AM
Juin Juin is offline
Member
 
Join Date: Feb 2011
Location: Pyongyang, North Korea
Posts: 81
Default

Agreed - it makes real-time debugging a royal pain where the sun don't shine, but it's the only way now.

I made a little bash script to check my PHP script's syntax, kill the server, restart it and start my script. Don't mind my crappy bash scripting - I just googled my way into producing what I needed. This works for my mac setup, but you can get the idea and adapt it to your system if you'd like to save some time while debugging and testing.

PHP Code:
#!/bin/bash

lint_output=`php -l myscript.php`

if [ `
echo $lint_output | wc -l` =  ]; then # no errors = one line
    
echo "27276,console,serverMessage Restarting server! Please rejoin!" >> ../servers/command.txt
    sleep 1
    
echo "tell application \"server_launcher\" to quit" osascript # kill the server if it's running
    
open ../altitude.app
    open 
../server_launcher.app
    php myscript
.php
else # display the errors
    
echo $lint_output
fi 
Reply With Quote
  #5  
Old 08-28-2011, 12:38 PM
idk idk is offline
Senior Member
 
Join Date: Feb 2010
Location: Sweden
Posts: 120
Default

Just like Nobodyhome said, I dont want to restart the server everytime i got a new version of my script. Since I am using Python, it does compile at run so it's very easy to debug: I just have to execute an in-game command "/script.rs" and then I have the new version up and running in a second.

I think that it would be best if the "listPlayers" only give all "player"-IDs. Otherwise that line will be huge, so I rather grabbing each player's data via another command that needs to be added, it should be giving you the same data as "clientAdd". It would have been also good with another information command that gives you the same data as "spawn". If you would like to add a command to see if tournament is on or off, I would appreciate it

My API is almost finished. Most parts are working but the player manager, which are demanded by some other parts too. I've decied to release it opensourced and I'll post more about that when it has been tested on the ladder servers. There will be some examples provided so it helps you to start your own system, but nothing close to what the ladder servers will use

Thaaanks!
Reply With Quote
  #6  
Old 08-30-2011, 06:35 PM
lamster lamster is offline
Administrator
 
Join Date: May 2008
Posts: 1,655
Default

I think the best solution is to start the script before you launch the server (restarting the server if necessary), as this is by far the most elegant and consistent way to track state (otherwise every log entry needs a corresponding chain of commands that can be used to query its current state for hot restart purposes, and that results in twice as much code to maintain both on the generation and parsing side). For testing and hot restarts, the best (though imperfect) solution is usually to parse the existing (old data) in log.txt. That said, I will consider a "logServerStatus" command that prints out a limited snapshot of the current state (maybe connected players and tournament status) so if you have specific requests post them here.
Reply With Quote
  #7  
Old 08-30-2011, 07:44 PM
idk idk is offline
Senior Member
 
Join Date: Feb 2010
Location: Sweden
Posts: 120
Default

If I understood correctly, I should use the "logServerStatus" that gives me a list of player IDs that are currently connected to the server. With those IDs I could get data (same as "clientAdd" gives) of each player by reading thru old data (log.txt). That sounds like a very good idea, thanks!

So, what more could be good to know by using the "logServerStatus"-command? Like we've already mentioned, the status of tournament, is a good candidate.
Could anyone else come up with something good, before Lamster releases an update! I'll think about this over night.

Have a great day!
Reply With Quote
  #8  
Old 08-31-2011, 06:16 AM
Juin Juin is offline
Member
 
Join Date: Feb 2011
Location: Pyongyang, North Korea
Posts: 81
Default

Including my log-entry suggestions thread here so lamster doesn't forget.
Reply With Quote
  #9  
Old 08-31-2011, 09:16 AM
idk idk is offline
Senior Member
 
Join Date: Feb 2010
Location: Sweden
Posts: 120
Default

Yes, I agree with #3 in your thread, Juin. I got some new statistics that I would like to save, like distance from goal when a player scored and same with TBD mode. I'll positions of all map's goals.
Reply With Quote
  #10  
Old 08-31-2011, 07:13 PM
phong phong is offline
Senior Member
 
Join Date: Jul 2009
Location: Chicago
Posts: 372
Default

If you use a database backend that has tables for servers/current players then you'd be able to restart your script live. The problem of course is if someone joins in the small window the script is being restarted but most scripts are pretty quick.

Just add logic to the script to boot any player that isn't in the table if it comes across a rogue player log entry (say someone joined while the script was restarting).

Last edited by phong; 08-31-2011 at 07:16 PM.
Reply With Quote
  #11  
Old 09-06-2011, 07:03 PM
idk idk is offline
Senior Member
 
Join Date: Feb 2010
Location: Sweden
Posts: 120
Default

Lamster, could you please add "player" (player ID, not vapor) to the log entry "commandExecution"? Since most other entries do use the players id and so does my player manager. It will save me two loops which now goes thru all connected players after the correct vaporId (the only variable you get from commandExecution) each time someone sends a command.

Last edited by idk; 09-06-2011 at 07:12 PM.
Reply With Quote
  #12  
Old 09-06-2011, 08:37 PM
Karl Karl is offline
Administrator
 
Join Date: May 2008
Posts: 1,206
Default

Quote:
Originally Posted by idk View Post
Lamster, could you please add "player" (player ID, not vapor) to the log entry "commandExecution"? Since most other entries do use the players id and so does my player manager. It will save me two loops which now goes thru all connected players after the correct vaporId (the only variable you get from commandExecution) each time someone sends a command.
lams might add it but you really should be using a hashmap/hashtable instead of looping through a list (http://en.wikipedia.org/wiki/Hash_table).

It would make sense to be able to look up Player objects via playerId and vaporId. Something like:

HashMap<UUID, Player> playerByVaporId = new HashMap<UUID, Player>();
HashMap<Integer, Player> playerByPlayerId = new HashMap<Integer, Player>();
Reply With Quote
  #13  
Old 09-07-2011, 03:49 AM
Boko Boko is offline
Banned
 
Join Date: Feb 2010
Location: Cocation
Posts: 1,392
Default

Quote:
Originally Posted by Karl View Post
lams might add it but you really should be using a hashmap/hashtable instead of looping through a list (http://en.wikipedia.org/wiki/Hash_table).

It would make sense to be able to look up Player objects via playerId and vaporId. Something like:

HashMap<UUID, Player> playerByVaporId = new HashMap<UUID, Player>();
HashMap<Integer, Player> playerByPlayerId = new HashMap<Integer, Player>();
Since he's coding it in python

http://stackoverflow.com/questions/1...f-a-hash-table
Reply With Quote
  #14  
Old 09-07-2011, 09:20 AM
idk idk is offline
Senior Member
 
Join Date: Feb 2010
Location: Sweden
Posts: 120
Default

Quote:
Originally Posted by Karl View Post
lams might add it but you really should be using a hashmap/hashtable instead of looping through a list (http://en.wikipedia.org/wiki/Hash_table).

It would make sense to be able to look up Player objects via playerId and vaporId. Something like:

HashMap<UUID, Player> playerByVaporId = new HashMap<UUID, Player>();
HashMap<Integer, Player> playerByPlayerId = new HashMap<Integer, Player>();
Yes, Im using a dictionary, the key is playerId and the value is a playerobject. So ill have to loop thru all keys and check for vaporId inside each playerobject. I rather stick with one list, but thanks for the support, Karl!

Edit: Sorry if I put pressure on you, but could you please tell me when this next update is coming?

Last edited by idk; 09-07-2011 at 04:03 PM.
Reply With Quote
  #15  
Old 09-07-2011, 05:36 PM
nobodyhome nobodyhome is offline
Senior Member
 
Join Date: Apr 2009
Posts: 1,088
Default

If you want to not use a loop, simply use two dictionaries that both have values as playerObjects: one with key playerId and the other with key vaporId. You just have to make sure you insert the playerObject into both dictionaries upon player join.
Reply With Quote
  #16  
Old 09-10-2011, 08:09 PM
idk idk is offline
Senior Member
 
Join Date: Feb 2010
Location: Sweden
Posts: 120
Default

Is it possible to remove the banishment when you're kicking a player? Atleast a option to turn it off. I've also read about a suggestion to add a reason message instead of the current one ("Kicked by server admin"), I would like to support that suggestion too. Thanks
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:36 PM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
2008 Nimbly Games LLC