#AdminChatTest // So the text "AdminChatTest" should be send to all admins and not to the main chat. // But When I type any text with # it is send to both the admin chat and the main chat.
public OnPlayerText(playerid, text[])
{
if ( Muted [ playerid ] == 1 )
{
format ( SStr , 128 , "You've been muted from the chat" ) ;
SendClientMessage ( playerid , -1 , SStr ) ;
return 0 ;
}
if ( ( text [ 0 ] == '*' ) && PlayerData [ playerid ] [ VIPLvl ] >= 1 && strlen(text) > 1 )
{
format ( SStr , sizeof ( SStr ) , "|ChatVip| %s(%d): %s" , pName ( playerid ) , playerid , text [ 1 ] ) ;
MessageToPlayerVIP ( -1 , SStr ) ;
SaveLog ( "VIPChatLog" , SStr ) ;
return 0 ;
}
if ( ( text [ 0 ] == '#' ) && PlayerData [ playerid ] [ AdmLvl ] >= 1 && strlen(text) > 1 )
{
format ( SStr , sizeof ( SStr ) , "Admin Chat: %s: %s" , pName ( playerid ) , text [ 1 ] ) ;
MessageToAdmins ( green , SStr ) ;
SaveLog ( "AdmChatLog" , SStr ) ;
return 0 ;
}
SaveChatLog ( playerid , "ChatLogs" , text ) ;
return 1 ;
}
Can you show us your MessageToAdmins and MessageToPlayerVIP functions?
|
forward MessageToAdmins ( color , const string[] ) ;
public MessageToAdmins ( color , const string[] )
{
foreach (new i : Player)
{
if ( IsPlayerConnected ( i ) == 1 && PlayerData [ i ][ AdmLvl ] >= 1 )
{
SendClientMessage ( i , color , string ) ;
}
}
return 1;
}
forward MessageToPlayerVIP ( color , const string[] ) ;
public MessageToPlayerVIP ( color , const string[] )
{
foreach (new i : Player)
{
if ( IsPlayerConnected ( i ) == 1 && PlayerData [ i ] [ VIPLvl ] >= 1 )
{
SendClientMessage ( i , color , string ) ;
}
}
return 1;
}
public OnPlayerText(playerid, text[])
{
if ( Muted [ playerid ] == 1 ) return SendClientMessage ( playerid , -1 , "You've been muted from the chat." ) ;
if ( ( text [ 0 ] == '*' ) && PlayerData [ playerid ] [ VIPLvl ] >= 1 && strlen(text) > 1 )
{
format ( SStr , sizeof ( SStr ) , "|ChatVip| %s(%d): %s" , pName ( playerid ) , playerid , text [ 1 ] ) ;
MessageToPlayerVIP ( -1 , SStr ) ;
SaveLog ( "VIPChatLog" , SStr ) ;
return 0 ;
}
if ( ( text [ 0 ] == '#' ) && PlayerData [ playerid ] [ AdmLvl ] >= 1 && strlen(text) > 1 )
{
format ( SStr , sizeof ( SStr ) , "Admin Chat: %s: %s" , pName ( playerid ) , text [ 1 ] ) ;
MessageToAdmins ( green , SStr ) ;
SaveLog ( "AdmChatLog" , SStr ) ;
return 0 ;
}
if(text[0] != '#' && text[0] != '*')
{
SendPlayerMessageToAll(playerid, text);
}
SaveChatLog ( playerid , "ChatLogs" , text ) ;
return 0 ;
}
forward MessageToAdmins ( color , const string[] ) ;
public MessageToAdmins ( color , const string[] )
{
foreach (new i : Player)
{
if(IsPlayerConnected(i))
{
if(PlayerData[ i ][ AdmLvl ] >= 1 )
{
SendClientMessage ( i , color , string ) ;
}
}
}
return 0;
}
forward MessageToPlayerVIP(color,const string[]);
public MessageToPlayerVIP(color,const string[])
{
foreach(Player, i)
{
if(IsPlayerConnected(i))
{
if(PlayerData[i][VIPLvl] >= 1)
{
SendClientMessage ( i , color , string );
}
}
}
return 0;
}
stock MessageToAdmins(color, const message[])
{
for(new i; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerData[playerid][AdmLvl] >=1(i))
{
SendClientMessage(i, color, message);
}
return 1;
}
Try this:
pawn Код:
|
Try using this stock as MessageToAdmins and try.
pawn Код:
|
stock MessageToAdmins(color, const message[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if PlayerData[playerid][AdmLvl] >=1 ) SendClientMessage(i, color, string);
}
return 1;
}
public OnPlayerText(playerid, text[])
{
if ( Muted [ playerid ] == 1 )
{
format ( SStr , 128 , "You've been muted from the chat" ) ;
SendClientMessage ( playerid , -1 , SStr ) ;
return 0 ;
}
if ( ( text [ 0 ] == '*' ) && PlayerData [ playerid ] [ VIPLvl ] >= 1 && strlen(text) > 1 )
{
format ( SStr , sizeof ( SStr ) , "|ChatVip| %s(%d): %s" , pName ( playerid ) , playerid , text [ 1 ] ) ;
MessageToPlayerVIP ( -1 , SStr ) ;
SaveLog ( "VIPChatLog" , SStr ) ;
return 0 ;
}
if ( ( text [ 0 ] == '#' ) && PlayerData [ playerid ] [ AdmLvl ] >= 1 && strlen(text) > 1 )
{
format ( SStr , sizeof ( SStr ) , "Admin Chat: %s: %s" , pName ( playerid ) , text [ 1 ] ) ;
MessageToAdmins ( green , SStr ) ;
SaveLog ( "AdmChatLog" , SStr ) ;
return 0 ;
}
else
{
SendPlayerMessageToAll(playerid, text);
}
SaveChatLog ( playerid , "ChatLogs" , text ) ;
return 0 ;
}
try this :
pawn Код:
|
C:\Users\Vyom\Desktop\SA-MP 3e\gamemodes\StuntWars.pwn(3326) : error 001: expected token: "*then", but found ")"
C:\Users\Vyom\Desktop\SA-MP 3e\gamemodes\StuntWars.pwn(3326) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
2 Errors.
You don't have why to check IsPlayerConnected in a foreach loop, remove this check, foreach is doing this for you.
This is all of your OnPlayerText code ? |
Afaik , OnPlayerText Must return 0, or the text will be sent twice.
pawn Код:
|