Posts: 426
Threads: 128
Joined: Aug 2013
Reputation:
0
Hi.
How can i make virtualworld-chat?
That, if player is in world 0, can tell with players in world 0 and if he is in 1, can tell with there's players and see messages from he's world only. How?
Posts: 3,004
Threads: 12
Joined: May 2011
when a player send a message loop through all players (recommending
foreach for this) and check if the player is in the same virtualworld, if he is then send him a client message with the text he wrote, if he is not, then don't do anything
P.S. don't forget to return 0; at the end so only your custom message will be sent.
Posts: 3,004
Threads: 12
Joined: May 2011
Quote:
Originally Posted by 'Pawno.
Use GetPlayerVirtualWorld and make a for-loop.
Like:
pawn Code:
stock SendVirtualMessage(virtualworld, color, string[]) { new i=0; for(i<GetMaxPlayers();i++) { if(IsPlayerConnected(i)) { // You can do this, if u want: //if(IsLoggedIn[i] == 1) or what ever. if(GetPlayerVirtualWorld(i) == virtualworld) { SendClientMessage(i, color, string); } } } return 1; }
That's it.
|
the array creation should be in the for()
pawn Code:
SendVirtualMessage(virtualworld, color, string[]) {
for(new i=0;i<GetMaxPlayers();i++) {
if(IsPlayerConnected(i)) {
if(GetPlayerVirtualWorld(i) == virtualworld) {
SendClientMessage(i, color, string);
}
}
}
}