chat in virtual worlds
#1

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.
Reply
#2

someone know?
Reply
#3

Use a loop and GetPlayerVirtualWorld in the chat.
Reply
#4

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

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.
Reply
#6

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...'
Reply
#7

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
Reply
#8

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)