Chat in Virutal Worlds
#1

How can I make it so that you can't see any /me's or chat from another player if they are in a different virtual world?
Reply
#2

Use a loop:

pawn Код:
public OnPlayerText(playerid, text[])
{
  new vw = GetPlayerVirtualWorld(playerid);
  for(new i; i < MAX_PLAYERS; i++)
  {
    if(GetPlayerVirtualWorld(i)) == vw) SendPlayerMessageToPlayer(i, playerid, text);
  }
Example code.
Reply
#3

Here something i made easy.
pawn Код:
stock SendWorldMessage( playerid, color, string[], wid )
{
    for ( new i = 0; i < MAX_PLAYERS; i ++ )
    {
         if ( GetPlayerVirtualWorld( i ) ) == wid ) SendClientMessage( i, color, string );
    }
}
or
pawn Код:
stock SendWorldPlayerMessage( playerid, senderid , string[], wid )
{
    for ( new i = 0; i < MAX_PLAYERS; i ++ )
    {
         if ( GetPlayerVirtualWorld( i ) ) == wid ) SendPlayerMessageToPlayer(i, playerid, string);
    }
}
Reply
#4

One that put player names in too,
pawn Код:
public OnPlayerText(playerid, text[])
{
    new
        vw,
        name[MAX_PLAYER_NAME];
       
    vw = GetPlayerVirtualWorld(playerid);
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(text, 128, "%s: %s", name, text);
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i))continue;
        if(GetPlayerVirtualWorld(i) == vw)
        SendClientMessage(i, GetPlayerColor(playerid), text);//NOTE: getplayercolor will only work if you have used setplayercolor in your script
    }
    return 0;
}
Also note this will only work for sending text not /me commands ect. For that just try do something simalar to whats done here.
Reply
#5

Quote:
Originally Posted by iggy1
Посмотреть сообщение
One that put player names in too,
pawn Код:
public OnPlayerText(playerid, text[])
{
    new
        vw,
        name[MAX_PLAYER_NAME];
       
    vw = GetPlayerVirtualWorld(playerid);
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(text, 128, "%s: %s", name, text);
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i))continue;
        if(GetPlayerVirtualWorld(i) == vw)
        SendClientMessage(i, GetPlayerColor(playerid), text);//NOTE: getplayercolor will only work if you have used setplayercolor in your script
    }
    return 0;
}
Sir, you just reinvented SendPlayerMessageToPlayer. That function already sends it like <colored name>: <text>
Reply
#6

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
Sir, you just reinvented SendPlayerMessageToPlayer. That function already sends it like <colored name>: <text>
Lol i'm always doing shit like that cant beleive i'v never spotted that function.
Reply
#7

pawn Код:
new vw = GetPlayerVirtualWorld(i);
                        for(new v = 0; v < MAX_PLAYERS; v++)
                        {
                            if(GetPlayerVirtualWorld(v)) == vw)
                            {
                                format(string, sizeof(string), "* %s's phone rings.", called);
                                RingTone[Mobile[i]] = 10;
                                ProxDetector(30.0, Mobile[v], string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                            }
                        }
Код:
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\gamemodes\lsrgta.pwn(5477) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\gamemodes\lsrgta.pwn(5477) : warning 215: expression has no effect
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\gamemodes\lsrgta.pwn(5477) : error 001: expected token: ";", but found ")"
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\gamemodes\lsrgta.pwn(5477) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\gamemodes\lsrgta.pwn(5477) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#8

pawn Код:
if(GetPlayerVirtualWorld(i)) == vw)
that's the line I'm getting the error on =o
Reply
#9

remove a ')' in, '(i))', so '(i)'
Reply
#10

Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)