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;
}
new string[128]; format(string, sizeof(string), "%s: %s", GetPlayerName(playerid), text); new worldid = GetPlayerVirtualWorld(playerid); SendVirtualMessage(worldid, 0x000000FF, string);
Use GetPlayerVirtualWorld and make a for-loop.
Like: pawn Code:
|
SendVirtualMessage(virtualworld, color, string[]) {
for(new i=0;i<GetMaxPlayers();i++) {
if(IsPlayerConnected(i)) {
if(GetPlayerVirtualWorld(i) == virtualworld) {
SendClientMessage(i, color, string);
}
}
}
}
new pName[24];
GetPlayerName(playerid, pName, sizeof (pName));
public OnPlayerText(playerid, text[])
{
// You put the virtual world you want to send the message; in this case the virtual world is "1"; you can use other virtual world.
if(GetPlayerVirtualWorld(playerid) == 1)
{
new String[128];
GetPlayerName(playerid, String, sizeof(String));
format(String, sizeof(String), "%s [%d]: {FFFFFF}%s", String, playerid, text);
Message(String);
return 0;
}
// Here you put other functions.
return 0;
}
forward Message(const string[]);
public Message(const string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) == 1) if(GetPlayerVirtualWorld(i) == 1) SendClientMessage(i, GetPlayerColor(i), string);
// We put the same virtual world for the player who is in the same virtual world. In this case is "1"; you can use other virtual world.
}
return 1;
}
public OnPlayerText(playerid, text[])
{
new var = GetPlayerVirtualWorld(playerid), fstr[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(fstr, sizeof(fstr), "%s(%d): %s", name, playerid, text);
for(new i = 0; i < MAX_PLAYERS; i++) //Foreach is a recommended alternative
{
if(!IsPlayerConnected(i)) continue;
if(GetPlayerVirtualWorld(i) != var) continue;
SendClientMessage(playerid, -1, fstr);
}
return 0;
}
if(loggedadminC == false) return 0;