SA-MP Forums Archive
chat in virtual 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 virtual worlds (/showthread.php?tid=74212)



chat in virtual worlds - Laurentt - 20.04.2009

Well 2 players from diferent virtual world can talk , how i can turn this off so only if they are in the same virtual world they can talk.


Re: chat in virtual worlds - Laurentt - 20.04.2009

someone know?


Re: chat in virtual worlds - Donny_k - 20.04.2009

Use a loop and GetPlayerVirtualWorld in the chat.


Re: chat in virtual worlds - Rks25 - 20.04.2009

pawn Код:
for(new i =0; i<MAX_PLAYERS; i++)
{
  if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld[playerid])
  {
    SendClientMessage(i,COLOR,text);
  }
}
UNTESTED!


Re: chat in virtual worlds - Donny_k - 20.04.2009

Quote:
Originally Posted by Rk_
pawn Код:
for(new i =0; i<MAX_PLAYERS; i++)
{
  if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld[playerid])
  {
    SendClientMessage(i,COLOR,text);
  }
}
UNTESTED!
I would do it like this I think:

pawn Код:
public OnPlayerText( playerid, text[] )
{
  new
    i,
    world = GetPlayerVirtualWorld( playerid );

  for ( i = 0; i < MAX_PLAYERS; i ++ )
  {
    if ( i != playerid && GetPlayerVirtualWorld( i ) == world )
    {
      SendPlayerMessageToPlayer( i, playerid, text );
    }
  }
  return false;
}
I've not got Pawno on my system right now to check that SPMTP function but I'm sure it works but isn't documented, the arguments could be the wrong way around also.


Re: chat in virtual worlds - Daren_Jacobson - 20.04.2009

Quote:
Originally Posted by Donny
pawn Код:
public OnPlayerText( playerid, text[] )
{
  new
    i,
    world = GetPlayerVirtualWorld( playerid );

  for ( i = 0; i < MAX_PLAYERS; i ++ )
  {
    if ( i != playerid && GetPlayerVirtualWorld( i ) == world )
    {
      SendPlayerMessageToPlayer( i, playerid, text );
    }
  }
  return false;
}
since you only use i inside the loop it would be best to create it at the beggining of the for. 'for(new i...'


Re: chat in virtual worlds - ICECOLDKILLAK8 - 20.04.2009

Quote:
Originally Posted by Daren_Jacobson
Quote:
Originally Posted by Donny
pawn Код:
public OnPlayerText( playerid, text[] )
{
  new
    i,
    world = GetPlayerVirtualWorld( playerid );

  for ( i = 0; i < MAX_PLAYERS; i ++ )
  {
    if ( i != playerid && GetPlayerVirtualWorld( i ) == world )
    {
      SendPlayerMessageToPlayer( i, playerid, text );
    }
  }
  return false;
}
since you only use i inside the loop it would be best to create it at the beggining of the for. 'for(new i...'
It just depends on the way people script


Re: chat in virtual worlds - Donny_k - 20.04.2009

Quote:
Originally Posted by Daren_Jacobson
since you only use i inside the loop it would be best to create it at the beggining of the for. 'for(new i...'
It's habit and for such a small snippet it won't have any difference as the callback ends on the very next lines directly after the loop has ended so it gets destroyed then instead of that millisecond earlier if it was indeed local to only the loops scope.

You are correct though dude don't get me wrong, locals are always better IMO also so thankyou for the correction.