I have a small problem. I have 4939 servers that i am updating. they all show up on the index page. Do you think to can make an option to show "10" "25" "50" servers and multiple pages? That would be very cool.
Anonymous
Sat Mar 22 2008, 07:07AM
Guest
Also. If you could make a separate "update.php" that would update all the servers in the database that would be cool "or tell me how to do it ". I know you are a busy man and i like what you are doing for us. Keep up the GREAT work!
The paging I can look into but is not a trivial, and will take a bit of re-design to do.
The seperate update is the "lgsl_cron.php" which you can run by a cron job to update the list. Details of the commands to run in the readme. ( LGSL v4.6 )
Take note of the part about increasing the "cache_time".
Anonymous
Sat Mar 22 2008, 05:54PM
Guest
OK THANKS ALOT! i didn't read the readme yet. probably should have done that first. but thanks for the info.
Michael
Sun Mar 23 2008, 02:15AM
Guest
Also "yet again", i am working on a search feature. hopefully i get it done soon.
Michael
Sun Mar 23 2008, 04:21AM
Guest
I have a script here that searches the mysql database for the ip you entered "or partial ip". what i want to do is get the server name from the cache that was returned from the mysql query.
The cache is all jumbled and i have no idea how to get just the server name out of it. Can you help me out a little?
$query = "SELECT * FROM `server` WHERE `ip` LIKE '%".mysql_real_escape_string($ip)."%'";
while($row = @mysql_fetch_array($result)) {
$online = $row['status'];
"need some code here to get the NAME of the server"
Please remember I do this in my spare time for free.
99.9% of people use LGSL for 1 to 10 servers, so I have designed it around that usage.
For large ammounts of servers, you are better off making your own database structure, geared towards searching and sorting, and just using the "lgsl_protocol.php" to do the querying.
Anonymous
Mon Mar 24 2008, 12:37AM
Guest
yet again - i have asked a bunch of questions.
i have an idea on exactly what i want to do. i just can decipher the cache lol.
something to do with unserialize($cache);
i cant for the life of me, figure it out.
i just want to echo the name of the server in a table
echo "<tr style='".lgsl_bg()."'><td>"Name of Server"<td>".$row['ip']."</td><td>".$row['c_port']."</td><td><img alt='' src='lgsl_files/other/icon_online.gif' title='ONLINE' /></td></tr>\n";
Michael
Mon Mar 24 2008, 08:30PM
Guest
I got my ip search script to work "will explain when i release it". now im going to add some more functionality "name search, number of players search, map search, online-offline search sorting etc.".
Michael
Tue Mar 25 2008, 10:51PM
Guest
I have a LIVE version of my search "i replaced the index with it because i need to figure out how to get multiple pages"
http://battlefield2gamer.info/server/index.php
In order for me to search for the Server Name i had to make a separate field in my mysql table called "name".
every time somebody makes a search it puts all the outputted servers' names into the mysql database. ----------- Do you think it would be hard to implement flags in the player list. what i mean is in the game battlefield 2, players are either on the USMC side "u.s" MEC side "middle-eastern coalition" or china side. there are flags that designate what side you are on. instead of having it say what side the player is on, it would be cool if it showed the flag too.
Posts: 59 Joined: Tue Mar 25 2008, 11:18PM Registered Member #3872
Thanks for the info! that was pretty much exactly how i was going to do it. I got the table fixed, it was just an error in the code.
if ($server['b']['type'] == "bf2") //Changes the text for the players team to an image
{
foreach ($server['p'] as $player_key => $player)
{
if ($player['team'] == "US")
{
$server['p'][$player_key]['team'] = "<a class='thumbnail' href='#thumb'><img src='lgsl_files\icons\bf2\US.png' width='32px' height='24px' border='0'/><span><img src='lgsl_files\icons\bf2\US.png' /><br />This player is on the USMC side.</span></a>";
} else if ($player['team'] == "MEC")
{
$server['p'][$player_key]['team'] = "<a class='thumbnail' href='#thumb'><img src='lgsl_files\icons\bf2\MEC.jpg' width='32px' height='24px' border='0'/><span><img src='lgsl_files\icons\bf2\MEC.jpg' /><br />This player is on the MEC side.</span></a>";
} else if ($player['team'] == "CH")
{
$server['p'][$player_key]['team'] = "<a class='thumbnail' href='#thumb'><img src='lgsl_files\icons\bf2\CHINA.png' width='32px' height='24px' border='0'/><span><img src='lgsl_files\icons\bf2\CHINA.png' /><br />This player is on the Chinese side.</span></a>";
}
}
}
ALSO. i added another sort function to lgsl_class.php
It is to sort by team.
if (!function_exists('lgsl_sort_players')) {
function lgsl_sort_players($server)
{
global $lgsl_config;
if (!is_array($server['p'])) { return $server; }
if ($lgsl_config['sort']['players'] == "score")
{
usort($server['p'], "lgsl_sort_players_by_score");
}
else if ($lgsl_config['sort']['players'] == "name")
{
usort($server['p'], "lgsl_sort_players_by_name");
}
else if ($lgsl_config['sort']['players'] == "team")
{
usort($server['p'], "lgsl_sort_players_by_team");
}
return $server;
}}
if (!function_exists('lgsl_sort_players_by_team')) {
function lgsl_sort_players_by_team($player_a, $player_b)
{
if ($player_a['team'] == $player_b['team']) { return 0; }
Just checked, and see you have added the team flags, but you have used backslashes ( \ ) for the paths which IE corrects, but does not work in other browsers.
Players are an array, so they must be converted to a string before insertion. I just used serialize, but you may only want to store the names for example.
Always run mysql_real_escape_string before insertion, for security, and to prevent any server data being mistaken for SQL.
If your doing a 'WHERE' and its only going to effect one server, add LIMIT 1 to the end for speed.
( as for the server not in database, check that the lookup_id function is returning data )
another quick question. what is skill? i havent been able to figure that out.
update - i got it working by adding $server = $mysql_row['id']; before the lgsl_query_cached hopefully it doesnt stop working
update - stopped working AGAIN. WTF? changed WHERE `id`='{$mysql_row['id']}' to {$server['o']['id']} and it works again.
update - i got it fully working. added the server name to the $lgsl_cron so that my search script wont take so long "it has to query the server name then update mysql, very inefficient in my opinion".
update - Added battlefield 2 special forces map pictures
update - Added bf2 special forces team flags and bf2 high-quality flags. ill try to add bf2 sf support and a separate folder "or you can for the lgsl 4.7 release". go here for teamflags and map pics http://home.rochester.rr.com/mybf2page/maps.html
update - I made a script to change servers that play Special forces maps to `type`='bf2sf' and i changed the lgsl_protocol to go with bf2sf. hopefully it works
Posts: 59 Joined: Tue Mar 25 2008, 11:18PM Registered Member #3872
My Community has a couple servers and about 90 admins on each 1 "we are ranked 20 'used to be 1 but we switch servers'" and they want me to add an icon next to the names that says if a player is an admin.
i tried
foreach ($server['p'] as $player_key => $player)
{
if ($player['name'] == "=Iowa= Elite_Marines")
{
$admin = "This player is an admin";
} else {
$admin = "";
}
Which works to a point. if i change "=Iowa= Elite_Marines" to a variable it doesnt work.
do you have an idea?
i have the names in a database. it worked then but it would echo 5 rows for each person in my database so it would say
This player is not an admin - Test This player is not an admin - Test This player is not an admin - Test This player IS an admin - Test This player is not an admin - Test
test being the player. it would do that to all the players on the server.