/toggle OOC for players
#1

Hey guys

Im having some trouble with my coding, i have two commands the one is basically for chatting in OOC and i have another command available for players (togwap) . If they use togwap it must disable ooc for them so that they dont see the messages. I have been struggling to make that happen. I hope you guys can help me, i will post the coding

pawn Код:
CMD:g(playerid, params[])
{
    new msg[128], string[128];
    new string2[128];
    if (sscanf(params, "s[128]", msg)) return SendClientMessage(playerid, RED, "USAGE : {FFFFFF}/g [MESSAGE]");
     for(new i = 0; i < MAX_PLAYERS; i++)
     {
    if (IsPlayerConnected(i) && togwap[i] == 1)
    {
            if ((!PlayerInfo[i][pAdmin]) && (!PlayerInfo[i][pDonator]))
            {
                    format(string, sizeof(string), "(( Player[level %d] %s : %s ))", PlayerInfo[i][pLevel], GetName(i), msg);
                    SendClientMessage(i, COLOR_OOC, string);
            }
            if ((PlayerInfo[i][pAdmin]) && (PlayerInfo[i][pDonator]))
            {
                if (PlayerInfo[i][pAdmin] == 6)
                {
                    format(string, sizeof(string), "(( Server Owner %s : %s ))", GetName(i), msg);
                    SendClientMessage(i, COLOR_OOC, string);
                }
            }
            if ((PlayerInfo[i][pAdmin]) && (!PlayerInfo[i][pDonator]))
            {
                if (PlayerInfo[i][pAdmin] == 6)
                {
                    format(string, sizeof(string), "(( Server Owner %s : %s ))", GetName(i), msg);
                    SendClientMessage(i, COLOR_OOC, string);
                }
            }
            if ((PlayerInfo[i][pDonator]) && (!PlayerInfo[i][pAdmin]))
            {
                if (PlayerInfo[i][pDonator] == 3)
                {
                    format(string2, sizeof(string2), "(( Bronze Donator %s : %s ))", GetName(i), msg);
                    SendClientMessage(i, COLOR_OOC, string2);
                }

       
                if (PlayerInfo[i][pDonator] == 2)
                {
                    format(string2, sizeof(string2), "(( Silver Donator %s : %s ))", GetName(i), msg);
                    SendClientMessage(i, COLOR_OOC, string2);
                }
                if (PlayerInfo[i][pDonator] == 3)
                {
                    format(string2, sizeof(string2), "(( Chrystal Donator %s : %s ))", GetName(i), msg);
                    SendClientMessage(i, COLOR_OOC, string2);
                }
                if (PlayerInfo[i][pDonator] == 4)
                {
                    format(string2, sizeof(string2), "(( Diamond Donator %s : %s ))", GetName(i), msg);
                    SendClientMessage(i, COLOR_OOC, string2);
                }
            }
       
    }
    }

    return 1;
}
I used a for loop :P

the second coding i will post is my /toggle command for players .

pawn Код:
CMD:togwap(playerid, params[])
{
    if (togwap[playerid] == 1)
    {
        SendClientMessage(playerid, RED, "You have just disabled global chat for you!");
    }
    else if (togwap[playerid] == 0)
    {
        SendClientMessage(playerid, GREEN, "You have just enable global chat for you!");
    }
   
    return 1;
}
Reply
#2

pawn Код:
CMD:g(playerid, params[])
{
    new msg[128], string[128];
    new string2[128];
    if (sscanf(params, "s[128]", msg)) return SendClientMessage(playerid, RED, "USAGE : {FFFFFF}/g [MESSAGE]");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i) && togwap[i] == 1)
        {
            if ((!PlayerInfo[playerid][pAdmin]) && (!PlayerInfo[playerid][pDonator]))
            {
                format(string, sizeof(string), "(( Player[level %d] %s : %s ))", PlayerInfo[playerid][pLevel], GetName(playerid), msg);
                SendClientMessage(i, COLOR_OOC, string);
            }
            if ((PlayerInfo[playerid][pAdmin]) && (PlayerInfo[playerid][pDonator]))
                {
                    if (PlayerInfo[playerid][pAdmin] == 6)
                    {
                        format(string, sizeof(string), "(( Server Owner %s : %s ))", GetName(playerid), msg);
                        SendClientMessage(playerid, COLOR_OOC, string);
                    }
                }
                if ((PlayerInfo[playerid][pAdmin]) && (!PlayerInfo[playerid][pDonator]))
                {
                    if (PlayerInfo[playerid][pAdmin] == 6)
                    {
                        format(string, sizeof(string), "(( Server Owner %s : %s ))", GetName(playerid), msg);
                        SendClientMessage(playerid, COLOR_OOC, string);
                    }
                }
                if ((PlayerInfo[playerid][pDonator]) && (!PlayerInfo[playerid][pAdmin]))
                {
                    if (PlayerInfo[playerid][pDonator] == 3)
                    {
                        format(string2, sizeof(string2), "(( Bronze Donator %s : %s ))", GetName(playerid), msg);
                        SendClientMessage(playerid, COLOR_OOC, string2);
                    }

           
                    if (PlayerInfo[playerid][pDonator] == 2)
                    {
                        format(string2, sizeof(string2), "(( Silver Donator %s : %s ))", GetName(playerid), msg);
                        SendClientMessage(playerid, COLOR_OOC, string2);
                    }
                    if (PlayerInfo[playerid][pDonator] == 3)
                    {
                        format(string2, sizeof(string2), "(( Chrystal Donator %s : %s ))", GetName(playerid), msg);
                        SendClientMessage(playerid, COLOR_OOC, string2);
                    }
                    if (PlayerInfo[playerid][pDonator] == 4)
                    {
                        format(string2, sizeof(string2), "(( Diamond Donator %s : %s ))", GetName(playerid), msg);
                        SendClientMessage(playerid, COLOR_OOC, string2);
                    }
                }
        }
    }
    return 1;
}
pawn Код:
CMD:togwap(playerid, params[])
{
    if (togwap[playerid] == 1)
    {
        SendClientMessage(playerid, RED, "You have just disabled global chat for you!");
        togwap[playerid] = 0;
    }
    else if (togwap[playerid] == 0)
    {
        SendClientMessage(playerid, GREEN, "You have just enable global chat for you!");
        togwap[playerid] = 1;
    }
   
    return 1;
}
Reply
#3

Thanks very much, will try it out!
Reply
#4

Not working, it sends a ooc only to the person who typed it and it sent it twice.
Reply
#5

That is because you have got SendClientMessage(playerid, ....); instead of SendClientMessage(i,...);

About two messages; not sure but it could be two states possible for a client.
Reply
#6

pawn Код:
CMD:g(playerid, params[])
{
    new msg[128], string[128];
    new string2[128];
    if (sscanf(params, "s[128]", msg)) return SendClientMessage(playerid, RED, "USAGE : {FFFFFF}/g [MESSAGE]");
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if (IsPlayerConnected(i) && togwap[i] == 1)
            {
                if (PlayerInfo[playerid][pAdmin] == 0 && PlayerInfo[playerid][pDonator] == 0)
                {
                    format(string, sizeof(string), "(( Player[level %d] %s : %s ))", PlayerInfo[playerid][pLevel], GetName(playerid), msg);
                    SendClientMessage(i, COLOR_OOC, string);
                }
                if (PlayerInfo[playerid][pAdmin] >= 1 && PlayerInfo[playerid][pDonator] >= 1)
                {
                    if (PlayerInfo[playerid][pAdmin] == 6)
                    {
                        format(string, sizeof(string), "(( Server Owner %s : %s ))", GetName(playerid), msg);
                        SendClientMessage(i, COLOR_OOC, string);
                    }
                }
                if (PlayerInfo[playerid][pAdmin] >= 1 && PlayerInfo[playerid][pDonator] == 0)
                {
                    if (PlayerInfo[playerid][pAdmin] == 6)
                    {
                        format(string, sizeof(string), "(( Server Owner %s : %s ))", GetName(playerid), msg);
                        SendClientMessage(i, COLOR_OOC, string);
                    }
                }
                if (PlayerInfo[playerid][pDonator] >= 1 && PlayerInfo[playerid][pAdmin] == 0)
                {
                    if (PlayerInfo[playerid][pDonator] == 1)
                    {
                        format(string2, sizeof(string2), "(( Bronze Donator %s : %s ))", GetName(playerid), msg);
                        SendClientMessage(i, COLOR_OOC, string2);
                    }
                    if (PlayerInfo[playerid][pDonator] == 2)
                    {
                        format(string2, sizeof(string2), "(( Silver Donator %s : %s ))", GetName(playerid), msg);
                        SendClientMessage(i, COLOR_OOC, string2);
                    }
                    if (PlayerInfo[playerid][pDonator] == 3)
                    {
                        format(string2, sizeof(string2), "(( Chrystal Donator %s : %s ))", GetName(playerid), msg);
                        SendClientMessage(i, COLOR_OOC, string2);
                    }
                    if (PlayerInfo[playerid][pDonator] == 4)
                    {
                        format(string2, sizeof(string2), "(( Diamond Donator %s : %s ))", GetName(playerid), msg);
                        SendClientMessage(i, COLOR_OOC, string2);
                    }
                }
            }
        }
    }
    return 1;
}
pawn Код:
CMD:togwap(playerid, params[])
{
    if (togwap[playerid] == 1)
    {
        SendClientMessage(playerid, RED, "You have just disabled global chat for you!");
        togwap[playerid] = 0;
    }
    else if (togwap[playerid] == 0)
    {
        SendClientMessage(playerid, GREEN, "You have just enable global chat for you!");
        togwap[playerid] = 1;
    }
   
    return 1;
}
Try this, i hope it will work
Reply
#7

Still not working for some reason, even if the other player did /togwap the message still displayed at their side. Please help me
Reply
#8

I don't see anything wrong with the code, you must have a problem.
Reply
#9

What kind of problem ? No messages get double posted anymore but the messages still display at the players side even if they did /togwap
Reply
#10

Now try my code i edited that. now it will work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)