Results 1 to 3 of 3
Thread: A debate, save us!
-
01-21-2011, 02:03 AM #1Junior Guru Wannabe
- Join Date
- Dec 2005
- Posts
- 51
A debate, save us!
This is based on a small game server.
Okay, let's assume there are 8 players online. ID 0, ID 1, ID 2, ID 3, ID 4, ID 6, ID 9 and ID 14.
PHP Code:new gPlayersOnline;
PHP Code:stock GetPIndex()//<--Player Index
{
gPlayersOnline = 0;//Reset to 0!
for(new i=0;i<GetMaxPlayers();i++)
{
if(!IsPlayerConnected(i)) continue;
gPlayersOnline++;
}
}
PHP Code:for(new i=0;i<gPlayersOnline;i++)
{
SendClientMessage(i, 0xFFFFFF00, "Hello online player!");
}
AKA
SendClientMessage(0, 0xFFFFFF00, "Hello online player!");
SendClientMessage(1, 0xFFFFFF00, "Hello online player!");
SendClientMessage(2, 0xFFFFFF00, "Hello online player!");
SendClientMessage(3, 0xFFFFFF00, "Hello online player!");
SendClientMessage(4, 0xFFFFFF00, "Hello online player!");
SendClientMessage(5, 0xFFFFFF00, "Hello online player!");
SendClientMessage(6, 0xFFFFFF00, "Hello online player!");
SendClientMessage(7, 0xFFFFFF00, "Hello online player!");
The basic question is, without storing their playerID and utilising it, would it send the message to list A:
0
1
2
3
4
5
6
7
or list B like I want it to:
0
1
2
3
4
6
9
14
This is a general coding issue, not directly related to the game. Thanks!
-
01-21-2011, 09:16 AM #2Web Hosting Master
- Join Date
- Apr 2009
- Location
- Pittsburgh, Pennsylvania
- Posts
- 583
I'm not 100% sure how you're coding it... but this is extremely simple if its done properly using UDP.
info.port
info.address
info.port would be the clients port (can be used to "manage" a client uniquely along with their ip address), info.address would be the clients ip address.
game servers SHOULD be done in UDP as the latency is MUCH lower than than TCP. But if its managed properly, and you have a decent "grasp" you should be fine.
I suggest doing a little research on how to manage clients using udp and tcp (which ever you plan on using, but i highly suggest udp because of low latency)
I've personally been coding a game on the side using node.js UDP. Nothing "major" but it does work.
To answer your question:
Code:0 1 2 3 4 5 6 7
-
01-21-2011, 10:32 AM #3WHT Addict
- Join Date
- Jun 2002
- Posts
- 125
One solution would just be to iterate through all possible slots again. If you do not want to store the IDs & also are thinking of applying the concept to a wider range of applications.
Code:for(new i=0;i<GetMaxPlayers();i++) { if(!IsPlayerConnected(i)) continue; SendClientMessage(i, 0xFFFFFF00, "Hello online player!"); }
Similar Threads
-
Hot Summer Specials at Sago Networks SAVE SAVE SAVE
By Sago-Sean in forum Dedicated Hosting OffersReplies: 0Last Post: 06-08-2010, 09:55 AM -
Toronto CLEARANCE - Carat Networks - 10% OFF for life - Save Save Save!
By vpncast in forum Dedicated Hosting OffersReplies: 0Last Post: 11-11-2009, 08:52 AM -
Core2Quad 2.83Ghz Save $45 / P4 3.2Ghz Save $35 / Atoms Save %15 / Core2Duos and More
By krypttim in forum Dedicated Hosting OffersReplies: 12Last Post: 09-16-2009, 02:16 AM -
Debate Poll 4500 Unique Per debate
By Lightsky in forum Advertising OffersReplies: 0Last Post: 06-12-2007, 09:36 PM