Help please. Rep +1
#1

I made a newbie chat..but fails

pawn Код:
if(strcmp(cmd, "/newbie", true) == 0 || strcmp(cmd, "/n", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pMuted] == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "You cannot speak, you have been silenced");
                return 1;
            }
            if(nonewbie == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "Newbie chat is off.");
                return 1;
            }
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[128];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/n)ewbie [newbie chat]");
                return 1;
            }
            if(PlayerInfo[playerid][pHelper] == 0)
            {
                format(string, sizeof(string), "[NEWBIE]: Newbie %s: %s", sendername, result);
            }
            else if(PlayerInfo[playerid][pHelper] == 1)
            {
               format(string, sizeof(string), "[NEWBIE]: Helper %s: %s", sendername, result);
            }
            else if(PlayerInfo[playerid][pDonateRank] == 1)
            {
               format(string, sizeof(string), "[NEWBIE]: Donater %s: %s", sendername, result);
            }
            else if(PlayerInfo[playerid][pAdmin] == 1)
            {
                format(string, sizeof(string), "[NEWBIE]: Administrator %s: %s", sendername, result);
            }
            SendClientMessageToAll(0x62B382AA, string);
            new y, m, d;
            new h,mi,s;
            getdate(y,m,d);
            gettime(h,mi,s);
            format(string, sizeof(string), "[%d/%d/%d](%d:%d:%d) %s (newbie): (%s)",d,m,y,h,mi,s, sendername, result);
            ChatLog(string);
        }
        return 1;
    }
When i write /n it works with my helper..but even if a player is a admin or donater it says Newbie..
Help please.
Thanks
Reply
#2

if(PlayerInfo[playerid][pHelper] == 0)

your not checking if hes also an admin or donator at the same time.
change it to:
pawn Код:
if(PlayerInfo[playerid][pHelper] == 0 && PlayerInfo[playerid][pAdmin] ==  0 && PlayerInfo[playerid][pHelper] == 0)
Reply
#3

Make it in this order.....To check first if player is admin , else check if its donater , else if he is helper else a newbie....

pawn Код:
if(strcmp(cmd, "/newbie", true) == 0 || strcmp(cmd, "/n", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pMuted] == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "You cannot speak, you have been silenced");
                return 1;
            }
            if(nonewbie == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "Newbie chat is off.");
                return 1;
            }
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[128];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/n)ewbie [newbie chat]");
                return 1;
            }
            if(PlayerInfo[playerid][pAdmin] == 1)
            {
                format(string, sizeof(string), "[NEWBIE]: Administrator %s: %s", sendername, result);
            }
            else if(PlayerInfo[playerid][pDonateRank] == 1)
            {
               format(string, sizeof(string), "[NEWBIE]: Donater %s: %s", sendername, result);
            }
            else if(PlayerInfo[playerid][pHelper] == 1)
            {
               format(string, sizeof(string), "[NEWBIE]: Helper %s: %s", sendername, result);
            }
            else if(PlayerInfo[playerid][pHelper] == 0)
            {
                format(string, sizeof(string), "[NEWBIE]: Newbie %s: %s", sendername, result);
            }
            SendClientMessageToAll(0x62B382AA, string);
            new y, m, d;
            new h,mi,s;
            getdate(y,m,d);
            gettime(h,mi,s);
            format(string, sizeof(string), "[%d/%d/%d](%d:%d:%d) %s (newbie): (%s)",d,m,y,h,mi,s, sendername, result);
            ChatLog(string);
        }
        return 1;
    }
Reply
#4

and i would of said

make
pawn Код:
PlayerInfo[playerid][pNewbie]
and use
pawn Код:
if(PlayerInfo[playerid][pNewbie] == 1)
instead of
pawn Код:
if(PlayerInfo[playerid][pHelper] == 0)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)