How can I disable the chat for registered players that aren't logged in?
#1

pawn Код:
PlayerInfo[playerid][Registered] == 1) {
- Registered? Yes.
pawn Код:
if(PlayerInfo[playerid][LoggedIn] == 0) {
- Logged in? No.

What I want is the chat totally disabled for players that are registered but not logged in.
I would like a message in the chat saying that tells the person to login first also.
Reply
#2

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(PlayerInfo[playerid][Registered] == 1 &&  PlayerInfo[playerid][LoggedIn] == 1)
    {
        //Your code for the chat here, if any
        return 1;
    }
    else return SendClientMessage(playerid, 0xFFFF00, "ERROR: You are currently not logged in.");
}
   
   
   
//And to only send messages to players that are logged in you do this


public OnPlayerText(playerid, text[])
{
    if(PlayerInfo[playerid][Registered] == 1 &&  PlayerInfo[playerid][LoggedIn] == 1)
    {
        new string[156];
        new name[24];
        GetPlayerName(playerid, name, 24);
        format(string, sizeof(string), "%s Says: %s", name, text);
        foreach(Player, i)
        {
            if(PlayerInfo[i][Registered] == 1 &&  PlayerInfo[i][LoggedIn] == 1) SendClientMessage(i, 0xFFFF00, string);
        }
    }
    else return SendClientMessage(playerid, 0xFFFF00, "ERROR: You are currently not logged in.");
}
Untested but should work fine
Reply
#3

Quote:
Originally Posted by milanosie
Посмотреть сообщение
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(PlayerInfo[playerid][Registered] == 1 &&  PlayerInfo[playerid][LoggedIn] == 1)
    {
        //Your code for the chat here, if any
        return 1;
    }
    else return SendClientMessage(playerid, 0xFFFF00, "ERROR: You are currently not logged in.");
}
   
   
   
//And to only send messages to players that are logged in you do this


public OnPlayerText(playerid, text[])
{
    if(PlayerInfo[playerid][Registered] == 1 &&  PlayerInfo[playerid][LoggedIn] == 1)
    {
        new string[156];
        new name[24];
        GetPlayerName(playerid, name, 24);
        format(string, sizeof(string), "%s Says: %s", name, text);
        foreach(Player, i)
        {
            if(PlayerInfo[i][Registered] == 1 &&  PlayerInfo[i][LoggedIn] == 1) SendClientMessage(i, 0xFFFF00, string);
        }
    }
    else return SendClientMessage(playerid, 0xFFFF00, "ERROR: You are currently not logged in.");
}
Untested but should work fine
I have no idea where I should have it :S

pawn Код:
//==============================OnPlayerText====================================
public OnPlayerText(playerid, text[])
{
    if(IsIPInText(text)) {
        SendClientMessage(playerid,RED,"You are not allowed to use IP adresses in your chat!");
        return 1;
    }
    if(text[0] == '@' && PlayerInfo[playerid][Level] >= 1) {
        new to_others[MAX_CHATBUBBLE_LENGTH+1];
        format(to_others,MAX_CHATBUBBLE_LENGTH,"Says: %s",text);
        SetPlayerChatBubble(playerid,to_others,MESSAGE_COLOR,35.0,10000);
        return 0;
    }
    if(text[0] == '!') {
        new gangChat[128];
        new senderName[MAX_PLAYER_NAME];
        new string[128];
        strmid(gangChat,text,1,strlen(text));
        GetPlayerName(playerid, senderName, sizeof(senderName));
        format(string, sizeof(string),"%s: %s", senderName, gangChat);
        for(new i = 0; i < MAX_PLAYERS; i++) {
            if(PlayerInfo[i][team] == PlayerInfo[playerid][team]) {
                SendClientMessage(i, COLOR_YELLOW, string);
            }
        }
        return 0;
    }
    for(new i = 1; i < MAX_CHAT_LINES-1; i++) Chat[i] = Chat[i+1];
    new ChatSTR[128]; GetPlayerName(playerid,ChatSTR,sizeof(ChatSTR)); format(ChatSTR,128,"[lchat]%s: %s",ChatSTR, text[0] );
    Chat[MAX_CHAT_LINES-1] = ChatSTR;
    if(PlayerInfo[playerid][Caps] == 1) UpperToLower(text);
    if(ServerInfo[NoCaps] == 1) UpperToLower(text);
    if(ServerInfo[DisableChat] == 1) {
        SendClientMessage(playerid,red,"Chat has been disabled");
        return 0;
    }
    if(PlayerInfo[playerid][Muted] == 1)
    {
        PlayerInfo[playerid][MuteWarnings]++;
        new string[128];
        if(PlayerInfo[playerid][MuteWarnings] < ServerInfo[MaxMuteWarnings]) {
            format(string, sizeof(string),"WARNING: You are muted, if you continue to speak you will be kicked. (%d / %d)", PlayerInfo[playerid][MuteWarnings], ServerInfo[MaxMuteWarnings] );
            SendClientMessage(playerid,red,string);
        } else {
            SendClientMessage(playerid,red,"You have been warned ! Now you have been kicked");
            format(string, sizeof(string),"***%s (ID %d) was kicked for exceeding mute warnings", PlayerName2(playerid), playerid);
            SendClientMessageToAll(grey,string);
            SaveToFile("KickLog",string); Kick(playerid);
        }
        return 0;
    }

    if(ServerInfo[AntiSpam] == 1 && (PlayerInfo[playerid][Level] == 0 && !IsPlayerAdmin(playerid)) )
    {
        if(PlayerInfo[playerid][SpamCount] == 0) PlayerInfo[playerid][SpamTime] = TimeStamp();

        PlayerInfo[playerid][SpamCount]++;
        if(TimeStamp() - PlayerInfo[playerid][SpamTime] > SPAM_TIMELIMIT) { // Its OK your messages were far enough apart
            PlayerInfo[playerid][SpamCount] = 0;
            PlayerInfo[playerid][SpamTime] = TimeStamp();
        }
        else if(PlayerInfo[playerid][SpamCount] == SPAM_MAX_MSGS) {
            new string[64]; format(string,sizeof(string),"%s has been kicked (Flood/Spam Protection)", PlayerName2(playerid));
            SendClientMessageToAll(grey,string); print(string);
            SaveToFile("KickLog",string);
            Kick(playerid);
        }
        else if(PlayerInfo[playerid][SpamCount] == SPAM_MAX_MSGS-1) {
            SendClientMessage(playerid,red,"Anti Spam Warning! Next is a kick.");
            return 0;
        }
    }
    if(ServerInfo[AntiSwear] == 1 && PlayerInfo[playerid][Level] < ServerInfo[MaxAdminLevel])
    for(new s = 0; s < ForbiddenWordCount; s++)
    {
        new pos;
        while((pos = strfind(text,ForbiddenWords[s],true)) != -1) for(new i = pos, j = pos + strlen(ForbiddenWords[s]); i < j; i++) text[i] = '*';
    }
   
    if (Calling[playerid] > -1 && Answered[playerid] == 1)
    {
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        new pReciever[MAX_PLAYER_NAME];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "%s: %s", sendername, text);
        SaveToFile("PhoneCalls",string);
        SendClientMessage(Calling[playerid], COLOR_YELLOW, string);
        format(string, sizeof(string), "%s: %s", sendername, text);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);

        GetPlayerName(Calling[playerid], pReciever, sizeof(pReciever));
        format(string, sizeof(string), "|- Call: %s To %s: %s", sendername, pReciever, text);
        IRC_GroupSay(gGroupID2, IRC_ADMINCHANNEL, string);
        for (new a = 0; a < MAX_PLAYERS; a++)
        if(IsPlayerConnected(a) && (PlayerInfo[a][Level] >= ServerInfo[MaxAdminLevel]) && a != playerid)
        SendClientMessage(a, grey, string);
        return 0;
    }
    if (Helping[playerid] > -1)
    {
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "%s: %s", sendername, text);
        SendClientMessage(Helping[playerid], COLOR_YELLOW, string);
        format(string, sizeof(string), "%s: %s", sendername, text);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        return 0;
    }
    else
    {
        new to_others[MAX_CHATBUBBLE_LENGTH+1];
        format(to_others,MAX_CHATBUBBLE_LENGTH,"Says: %s",text);
        SetPlayerChatBubble(playerid,to_others,MESSAGE_COLOR,35.0,10000);
    }
    {
        new string[128];
        format(string, sizeof string, "{BABABA}[%d]{FFFFFF} %s", playerid, text);
        SendPlayerMessageToAll(playerid, string);
    }
    {
        new string[128];
        new PlayerName[128];
        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        format(string, sizeof string, "%s: [%d] %s", PlayerName, playerid, text);
        IRC_GroupSay(gGroupID, IRC_CHANNEL, string);
    }
    return 0;
}
Reply
#4

pawn Код:
public OnPlayerText(playerid, text[])
{

    if(PlayerInfo[playerid][Registered] == 1 &&  PlayerInfo[playerid][LoggedIn] == 1)
    {
    if(IsIPInText(text)) {
        SendClientMessage(playerid,RED,"You are not allowed to use IP adresses in your chat!");
        return 1;
    }
    if(text[0] == '@' && PlayerInfo[playerid][Level] >= 1) {
        new to_others[MAX_CHATBUBBLE_LENGTH+1];
        format(to_others,MAX_CHATBUBBLE_LENGTH,"Says: %s",text);
        SetPlayerChatBubble(playerid,to_others,MESSAGE_COLOR,35.0,10000);
        return 0;
    }
    if(text[0] == '!') {
        new gangChat[128];
        new senderName[MAX_PLAYER_NAME];
        new string[128];
        strmid(gangChat,text,1,strlen(text));
        GetPlayerName(playerid, senderName, sizeof(senderName));
        format(string, sizeof(string),"%s: %s", senderName, gangChat);
        for(new i = 0; i < MAX_PLAYERS; i++) {
            if(PlayerInfo[i][team] == PlayerInfo[playerid][team]) {
                SendClientMessage(i, COLOR_YELLOW, string);
            }
        }
        return 0;
    }
    for(new i = 1; i < MAX_CHAT_LINES-1; i++) Chat[i] = Chat[i+1];
    new ChatSTR[128]; GetPlayerName(playerid,ChatSTR,sizeof(ChatSTR)); format(ChatSTR,128,"[lchat]%s: %s",ChatSTR, text[0] );
    Chat[MAX_CHAT_LINES-1] = ChatSTR;
    if(PlayerInfo[playerid][Caps] == 1) UpperToLower(text);
    if(ServerInfo[NoCaps] == 1) UpperToLower(text);
    if(ServerInfo[DisableChat] == 1) {
        SendClientMessage(playerid,red,"Chat has been disabled");
        return 0;
    }
    if(PlayerInfo[playerid][Muted] == 1)
    {
        PlayerInfo[playerid][MuteWarnings]++;
        new string[128];
        if(PlayerInfo[playerid][MuteWarnings] < ServerInfo[MaxMuteWarnings]) {
            format(string, sizeof(string),"WARNING: You are muted, if you continue to speak you will be kicked. (%d / %d)", PlayerInfo[playerid][MuteWarnings], ServerInfo[MaxMuteWarnings] );
            SendClientMessage(playerid,red,string);
        } else {
            SendClientMessage(playerid,red,"You have been warned ! Now you have been kicked");
            format(string, sizeof(string),"***%s (ID %d) was kicked for exceeding mute warnings", PlayerName2(playerid), playerid);
            SendClientMessageToAll(grey,string);
            SaveToFile("KickLog",string); Kick(playerid);
        }
        return 0;
    }

    if(ServerInfo[AntiSpam] == 1 && (PlayerInfo[playerid][Level] == 0 && !IsPlayerAdmin(playerid)) )
    {
        if(PlayerInfo[playerid][SpamCount] == 0) PlayerInfo[playerid][SpamTime] = TimeStamp();

        PlayerInfo[playerid][SpamCount]++;
        if(TimeStamp() - PlayerInfo[playerid][SpamTime] > SPAM_TIMELIMIT) { // Its OK your messages were far enough apart
            PlayerInfo[playerid][SpamCount] = 0;
            PlayerInfo[playerid][SpamTime] = TimeStamp();
        }
        else if(PlayerInfo[playerid][SpamCount] == SPAM_MAX_MSGS) {
            new string[64]; format(string,sizeof(string),"%s has been kicked (Flood/Spam Protection)", PlayerName2(playerid));
            SendClientMessageToAll(grey,string); print(string);
            SaveToFile("KickLog",string);
            Kick(playerid);
        }
        else if(PlayerInfo[playerid][SpamCount] == SPAM_MAX_MSGS-1) {
            SendClientMessage(playerid,red,"Anti Spam Warning! Next is a kick.");
            return 0;
        }
    }
    if(ServerInfo[AntiSwear] == 1 && PlayerInfo[playerid][Level] < ServerInfo[MaxAdminLevel])
    for(new s = 0; s < ForbiddenWordCount; s++)
    {
        new pos;
        while((pos = strfind(text,ForbiddenWords[s],true)) != -1) for(new i = pos, j = pos + strlen(ForbiddenWords[s]); i < j; i++) text[i] = '*';
    }

    if (Calling[playerid] > -1 && Answered[playerid] == 1)
    {
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        new pReciever[MAX_PLAYER_NAME];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "%s: %s", sendername, text);
        SaveToFile("PhoneCalls",string);
        SendClientMessage(Calling[playerid], COLOR_YELLOW, string);
        format(string, sizeof(string), "%s: %s", sendername, text);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);

        GetPlayerName(Calling[playerid], pReciever, sizeof(pReciever));
        format(string, sizeof(string), "|- Call: %s To %s: %s", sendername, pReciever, text);
        IRC_GroupSay(gGroupID2, IRC_ADMINCHANNEL, string);
        for (new a = 0; a < MAX_PLAYERS; a++)
        if(IsPlayerConnected(a) && (PlayerInfo[a][Level] >= ServerInfo[MaxAdminLevel]) && a != playerid)
        SendClientMessage(a, grey, string);
        return 0;
    }
    if (Helping[playerid] > -1)
    {
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "%s: %s", sendername, text);
        SendClientMessage(Helping[playerid], COLOR_YELLOW, string);
        format(string, sizeof(string), "%s: %s", sendername, text);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        return 0;
    }
    else
    {
        new to_others[MAX_CHATBUBBLE_LENGTH+1];
        format(to_others,MAX_CHATBUBBLE_LENGTH,"Says: %s",text);
        SetPlayerChatBubble(playerid,to_others,MESSAGE_COLOR,35.0,10000);
    }
    {
        new string[128];
        format(string, sizeof string, "{BABABA}[%d]{FFFFFF} %s", playerid, text);
        SendPlayerMessageToAll(playerid, string);
    }
    {
        new string[128];
        new PlayerName[128];
        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        format(string, sizeof string, "%s: [%d] %s", PlayerName, playerid, text);
        IRC_GroupSay(gGroupID, IRC_CHANNEL, string);
    }
    return 0;
    }
    else
    {
        SendClientMessage(playerid, 0xFFFF00, "ERROR: You are currently not logged in.");
    }
    return 0;
}
Reply
#5

Quote:
Originally Posted by milanosie
Посмотреть сообщение
pawn Код:
public OnPlayerText(playerid, text[])
{

    if(PlayerInfo[playerid][Registered] == 1 &&  PlayerInfo[playerid][LoggedIn] == 1)
    {
    if(IsIPInText(text)) {
        SendClientMessage(playerid,RED,"You are not allowed to use IP adresses in your chat!");
        return 1;
    }
    if(text[0] == '@' && PlayerInfo[playerid][Level] >= 1) {
        new to_others[MAX_CHATBUBBLE_LENGTH+1];
        format(to_others,MAX_CHATBUBBLE_LENGTH,"Says: %s",text);
        SetPlayerChatBubble(playerid,to_others,MESSAGE_COLOR,35.0,10000);
        return 0;
    }
    if(text[0] == '!') {
        new gangChat[128];
        new senderName[MAX_PLAYER_NAME];
        new string[128];
        strmid(gangChat,text,1,strlen(text));
        GetPlayerName(playerid, senderName, sizeof(senderName));
        format(string, sizeof(string),"%s: %s", senderName, gangChat);
        for(new i = 0; i < MAX_PLAYERS; i++) {
            if(PlayerInfo[i][team] == PlayerInfo[playerid][team]) {
                SendClientMessage(i, COLOR_YELLOW, string);
            }
        }
        return 0;
    }
    for(new i = 1; i < MAX_CHAT_LINES-1; i++) Chat[i] = Chat[i+1];
    new ChatSTR[128]; GetPlayerName(playerid,ChatSTR,sizeof(ChatSTR)); format(ChatSTR,128,"[lchat]%s: %s",ChatSTR, text[0] );
    Chat[MAX_CHAT_LINES-1] = ChatSTR;
    if(PlayerInfo[playerid][Caps] == 1) UpperToLower(text);
    if(ServerInfo[NoCaps] == 1) UpperToLower(text);
    if(ServerInfo[DisableChat] == 1) {
        SendClientMessage(playerid,red,"Chat has been disabled");
        return 0;
    }
    if(PlayerInfo[playerid][Muted] == 1)
    {
        PlayerInfo[playerid][MuteWarnings]++;
        new string[128];
        if(PlayerInfo[playerid][MuteWarnings] < ServerInfo[MaxMuteWarnings]) {
            format(string, sizeof(string),"WARNING: You are muted, if you continue to speak you will be kicked. (%d / %d)", PlayerInfo[playerid][MuteWarnings], ServerInfo[MaxMuteWarnings] );
            SendClientMessage(playerid,red,string);
        } else {
            SendClientMessage(playerid,red,"You have been warned ! Now you have been kicked");
            format(string, sizeof(string),"***%s (ID %d) was kicked for exceeding mute warnings", PlayerName2(playerid), playerid);
            SendClientMessageToAll(grey,string);
            SaveToFile("KickLog",string); Kick(playerid);
        }
        return 0;
    }

    if(ServerInfo[AntiSpam] == 1 && (PlayerInfo[playerid][Level] == 0 && !IsPlayerAdmin(playerid)) )
    {
        if(PlayerInfo[playerid][SpamCount] == 0) PlayerInfo[playerid][SpamTime] = TimeStamp();

        PlayerInfo[playerid][SpamCount]++;
        if(TimeStamp() - PlayerInfo[playerid][SpamTime] > SPAM_TIMELIMIT) { // Its OK your messages were far enough apart
            PlayerInfo[playerid][SpamCount] = 0;
            PlayerInfo[playerid][SpamTime] = TimeStamp();
        }
        else if(PlayerInfo[playerid][SpamCount] == SPAM_MAX_MSGS) {
            new string[64]; format(string,sizeof(string),"%s has been kicked (Flood/Spam Protection)", PlayerName2(playerid));
            SendClientMessageToAll(grey,string); print(string);
            SaveToFile("KickLog",string);
            Kick(playerid);
        }
        else if(PlayerInfo[playerid][SpamCount] == SPAM_MAX_MSGS-1) {
            SendClientMessage(playerid,red,"Anti Spam Warning! Next is a kick.");
            return 0;
        }
    }
    if(ServerInfo[AntiSwear] == 1 && PlayerInfo[playerid][Level] < ServerInfo[MaxAdminLevel])
    for(new s = 0; s < ForbiddenWordCount; s++)
    {
        new pos;
        while((pos = strfind(text,ForbiddenWords[s],true)) != -1) for(new i = pos, j = pos + strlen(ForbiddenWords[s]); i < j; i++) text[i] = '*';
    }

    if (Calling[playerid] > -1 && Answered[playerid] == 1)
    {
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        new pReciever[MAX_PLAYER_NAME];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "%s: %s", sendername, text);
        SaveToFile("PhoneCalls",string);
        SendClientMessage(Calling[playerid], COLOR_YELLOW, string);
        format(string, sizeof(string), "%s: %s", sendername, text);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);

        GetPlayerName(Calling[playerid], pReciever, sizeof(pReciever));
        format(string, sizeof(string), "|- Call: %s To %s: %s", sendername, pReciever, text);
        IRC_GroupSay(gGroupID2, IRC_ADMINCHANNEL, string);
        for (new a = 0; a < MAX_PLAYERS; a++)
        if(IsPlayerConnected(a) && (PlayerInfo[a][Level] >= ServerInfo[MaxAdminLevel]) && a != playerid)
        SendClientMessage(a, grey, string);
        return 0;
    }
    if (Helping[playerid] > -1)
    {
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "%s: %s", sendername, text);
        SendClientMessage(Helping[playerid], COLOR_YELLOW, string);
        format(string, sizeof(string), "%s: %s", sendername, text);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        return 0;
    }
    else
    {
        new to_others[MAX_CHATBUBBLE_LENGTH+1];
        format(to_others,MAX_CHATBUBBLE_LENGTH,"Says: %s",text);
        SetPlayerChatBubble(playerid,to_others,MESSAGE_COLOR,35.0,10000);
    }
    {
        new string[128];
        format(string, sizeof string, "{BABABA}[%d]{FFFFFF} %s", playerid, text);
        SendPlayerMessageToAll(playerid, string);
    }
    {
        new string[128];
        new PlayerName[128];
        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        format(string, sizeof string, "%s: [%d] %s", PlayerName, playerid, text);
        IRC_GroupSay(gGroupID, IRC_CHANNEL, string);
    }
    return 0;
    }
    else
    {
        SendClientMessage(playerid, 0xFFFF00, "ERROR: You are currently not logged in.");
    }
    return 0;
}
Oh isn't it harder than that
Thanks for the help.
Reply
#6

return 1; return the value , return 0; do not return it, so if using in a function return 0; you will can 't chat
or in another functions
Reply
#7

Quote:
Originally Posted by XStormiest
Посмотреть сообщение
return 1; return the value , return 0; do not return it, so if using in a function return 0; you will can 't chat
or in another functions
But since he is using a custom function to chat yo need to use return 0 in order to not show the default text aswell.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)