SA-MP Forums Archive
Chat in Virutal Worlds - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Chat in Virutal Worlds (/showthread.php?tid=193048)



Chat in Virutal Worlds - Lars_Frederiksen - 24.11.2010

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?


Re: Chat in Virutal Worlds - Hiddos - 24.11.2010

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.


Re: Chat in Virutal Worlds - Zh3r0 - 24.11.2010

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);
    }
}



Re: Chat in Virutal Worlds - iggy1 - 24.11.2010

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.


Re: Chat in Virutal Worlds - Hiddos - 24.11.2010

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>


Re: Chat in Virutal Worlds - iggy1 - 24.11.2010

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.


Re: Chat in Virutal Worlds - Lars_Frederiksen - 24.11.2010

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.



Re: Chat in Virutal Worlds - Lars_Frederiksen - 24.11.2010

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


Re: Chat in Virutal Worlds - [L3th4l] - 24.11.2010

remove a ')' in, '(i))', so '(i)'


Re: Chat in Virutal Worlds - Lars_Frederiksen - 24.11.2010

Thank you