Admin/VIP chat bugged.
#1

I am making admin and vip chat. Everything seems perfect but I don't know but they are bugged. What actually happens is -

For example, If I do -

Код:
#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.
Here is my code -

pawn Код:
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 ;
}
I can't figure out the problem.
Reply
#2

Can you show us your MessageToAdmins and MessageToPlayerVIP functions?
Reply
#3

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
Can you show us your MessageToAdmins and MessageToPlayerVIP functions?
Sure, here -

pawn Код:
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;
}
Reply
#4

Try this:
pawn Код:
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;
}
If that does not work, try searching any other filterscripts or gamemodes you are using, and remove any code under OnPlayerText that might affect this outcome.
Reply
#5

Try using this stock as MessageToAdmins and try.
pawn Код:
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;
}
If working, use like this for VIP chat function also.
Reply
#6

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
Try this:
pawn Код:
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;
}
If that does not work, try searching any other filterscripts or gamemodes you are using, and remove any code under OnPlayerText that might affect this outcome.
I also tried without loading any filterscripts.

Quote:
Originally Posted by [xB]Lordz
Посмотреть сообщение
Try using this stock as MessageToAdmins and try.
pawn Код:
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;
}
If working, use like this for VIP chat function also.
@Lordz, not working.


Unfortunately, none. HELP!
Reply
#7

try this :

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;
}
Works Perfect for me..
Reply
#8

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 ?
Reply
#9

Afaik , OnPlayerText Must return 0, or the text will be sent twice.
pawn Код:
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 ;
}
Reply
#10

Quote:
Originally Posted by XtremeR
Посмотреть сообщение
try this :

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;
}
Works Perfect for me..
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.
And as you're looping the playerid should be "i"

Quote:
Originally Posted by costel_nistor96
Посмотреть сообщение
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 ?
Yes, that's the only code on my OnPlayerText.

Quote:
Originally Posted by HuSs3n
Посмотреть сообщение
Afaik , OnPlayerText Must return 0, or the text will be sent twice.
pawn Код:
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 ;
}
I tried it before. Doesn't seems to be working.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)