STRCMP Irc CMD
#1

Hello everyone,

I was converting a game mode for a Client from strcmp to zcmd/sscanf. Im almost done with all the command but there was this particular command which got me thinking , how to convert it to zcmd/sscanf. if anyone can convert it and paste the working command. Will highly appreciate it as well as will Rep+6 you for helping me.

Here the CMD:
pawn Код:
if(strcmp(cmd,"/irc",true)==0)
    {
        if(IsPlayerConnected(playerid))
        {
            new x_nr[128];
            x_nr = strtok(cmdtext, idx);
            if(!strlen(x_nr)) {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/irc join [channelnr] or /irc join [channelnr] [password])  (/irc Leave)  (/irc Admins)");
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc [name] [channelnr]");
                SendClientMessage(playerid, COLOR_WHITE, "Available names: MOTD, Password, NeedPass, Lock, Kick, Status");
                return 1;
            }
            if(strcmp(x_nr,"join",true) == 0)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc join [channelnr] or /irc join [channelnr] [password]");
                    return 1;
                }
                new channel = strval(tmp);
                if(channel < 1 || channel > SCRIPT_MAXIRC) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above the amount !"); return 1; }
                channel -= 1;
                if(IRCInfo[channel][iLock] == 0)
                {
                    if(IRCInfo[channel][iNeedPass] == 0)
                    {
                        JoinChannelNr(playerid, channel);
                    }
                    else
                    {
                        tmp = strtok(cmdtext, idx);
                        if(!strlen(tmp))
                        {
                            SendClientMessage(playerid, COLOR_WHITE, "There's a password required to join this Channel.");
                            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc join [channelnr] [password]");
                            return 1;
                        }
                        JoinChannel(playerid,channel,tmp);
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   That Channel is Locked, please choose a different one !");
                    return 1;
                }
            }
            else if(strcmp(x_nr, "create", true) == 0)
            {
                GetPlayerName(playerid, sendername, sizeof(sendername));
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /irc create [number]");
                    return 1;
                }
                new channel;
                channel = strval(tmp);
                if(channel < 1 || channel > SCRIPT_MAXIRC) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above the amount !"); return 1; }
                if(PlayerInfo[playerid][pConnectTime] < 50)
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "You must have 50 and over time in FC to use this !");
                    return 1;
                }
                for(new i = 0; i < sizeof(IRCInfo); i++)
                {
                    if(strcmp(IRCInfo[i][iAdmin], sendername, true) == 0)
                    {
                        format(string, sizeof(string), "You already have control over IRC Channel: %d", i);
                        SendClientMessage(playerid, COLOR_GRAD2, string);
                        return 1;
                    }
                }
                if(strcmp(IRCInfo[channel][iAdmin], "None", true) == 0)
                {
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(string, sizeof(string), "you are now an IRC Admin over Channel %d.", channel);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    format(string, sizeof(string), "%s", sendername);
                    strmid(IRCInfo[channel][iAdmin], string, 0, strlen(string), 255);
                    IRCInfo[channel][iNeedPass] = 0; IRCInfo[channel][iLock] = 0;
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "This channel is taken already !");
                }
                return 1;
            }
            else if(strcmp(x_nr,"status",true) == 0)
            {
                for(new i = 0; i < sizeof(IRCInfo); i++)
                {
                    if(strcmp(IRCInfo[i][iAdmin], "None", true) == 0)
                    {
                        return 1;
                    }
                    else
                    {
                        format(string, sizeof(string), "Channel %d: %d Players Connected.",i + 1, IRCInfo[i][iPlayers]);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                    }
                }
                return 1;
            }
            else if(strcmp(x_nr,"password",true) == 0)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc password [channelnr] [password]");
                    return 1;
                }
                new channel = strval(tmp);
                if(channel < 1 || channel > SCRIPT_MAXIRC) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above the amount !"); return 1; }
                channel -= 1;
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s", sendername);
                strmid(wstring, string, 0, strlen(string), 255);
                if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
                {
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc password [channelnr] [password]");
                        return 1;
                    }
                    strmid(IRCInfo[channel][iPassword], tmp, 0, strlen(tmp), 255);
                    format(string, sizeof(string), "You've changed the IRC Channel's Password to: %s.",IRCInfo[channel][iPassword]);
                    SendClientMessage(playerid, COLOR_YELLOW, string);
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of that Channel !");
                    return 1;
                }
            }
            else if(strcmp(x_nr,"needpass",true) == 0)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc needpass [channelnr]");
                    return 1;
                }
                new channel = strval(tmp);
                if(channel < 1 || channel > SCRIPT_MAXIRC) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above the amount !"); return 1; }
                channel -= 1;
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s", sendername);
                strmid(wstring, string, 0, strlen(string), 255);
                if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
                {
                    if(IRCInfo[channel][iNeedPass] != 0)
                    {
                        IRCInfo[channel][iNeedPass] = 0;
                        SendClientMessage(playerid, COLOR_YELLOW, "Players won't have to fill in a password in order to join the IRC Channel now.");
                    }
                    else
                    {
                        IRCInfo[channel][iNeedPass] = 1;
                        SendClientMessage(playerid, COLOR_YELLOW, "Players must fill in a password in order to join the IRC Channel now.");
                    }
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of that Channel !");
                    return 1;
                }
            }
            else if(strcmp(x_nr,"lock",true) == 0)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc lock [channelnr]");
                    return 1;
                }
                new channel = strval(tmp);
                if(channel < 1 || channel > SCRIPT_MAXIRC) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above the amount !"); return 1; }
                channel -= 1;
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s", sendername);
                strmid(wstring, string, 0, strlen(string), 255);
                if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
                {
                    if(IRCInfo[channel][iLock] != 0)
                    {
                        IRCInfo[channel][iLock] = 0;
                        SendClientMessage(playerid, COLOR_YELLOW, "You've unlocked the IRC Channel.");
                    }
                    else
                    {
                        IRCInfo[channel][iLock] = 1;
                        SendClientMessage(playerid, COLOR_YELLOW, "You've locked the IRC Channel.");
                    }
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of that Channel !");
                    return 1;
                }
            }
            else if(strcmp(x_nr,"motd",true) == 0)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc motd [channelnr] [motdtext]");
                    return 1;
                }
                new channel = strval(tmp);
                if(channel < 1 || channel > SCRIPT_MAXIRC) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above the amount !"); return 1; }
                channel -= 1;
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s", sendername);
                strmid(wstring, string, 0, strlen(string), 255);
                if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
                {
                    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: /irc motd [motdtext]");
                        return 1;
                    }
                    strmid(IRCInfo[channel][iMOTD], result, 0, strlen(result), 255);
                    SendClientMessage(playerid, COLOR_YELLOW, "You've adjusted the IRC Channel's MOTD Text.");
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of that Channel !");
                    return 1;
                }
            }
            else if(strcmp(x_nr,"leave",true) == 0)
            {
                if(PlayerInfo[playerid][pPlayersChannel] < 999)
                {
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(string, sizeof(string), "* %s has left the Channel.", sendername);
                    SendIRCMessage(PlayerInfo[playerid][pPlayersChannel], COLOR_GREEN, string);
                    IRCInfo[PlayerInfo[playerid][pPlayersChannel]][iPlayers] -= 1;
                    PlayerInfo[playerid][pPlayersChannel] = 999;
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not in an IRC Channel !");
                    return 1;
                }
            }
            else if(strcmp(x_nr,"admins",true) == 0)
            {
                for(new i = 0; i < sizeof(IRCInfo); i++)
                {
                    format(string, sizeof(string), "Channel %d: %s.", i + 1, IRCInfo[i][iAdmin]);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                }
                return 1;
            }
            else if(strcmp(x_nr,"kick",true) == 0)
            {
                if(PlayerInfo[playerid][pPlayersChannel] == 999)
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not in an IRC Channel !");
                    return 1;
                }
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s", sendername);
                strmid(wstring, string, 0, strlen(string), 255);
                if(strcmp(IRCInfo[PlayerInfo[playerid][pPlayersChannel]][iAdmin],wstring, true ) == 0 )
                {
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc kick [playerid/PartOfName]");
                        return 1;
                    }
                    giveplayerid = ReturnUser(tmp);
                    if(IsPlayerConnected(giveplayerid))
                    {
                        if(giveplayerid != INVALID_PLAYER_ID)
                        {
                            if(PlayerInfo[giveplayerid][pPlayersChannel] == PlayerInfo[playerid][pPlayersChannel])
                            {
                                GetPlayerName(playerid, sendername, sizeof(sendername));
                                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                                format(string, sizeof(string), "* You've kicked %s out of your IRC Channel.",giveplayer);
                                SendClientMessage(playerid, COLOR_YELLOW, string);
                                format(string, sizeof(string), "* You've been kicked out of the IRC Channel by Channel Admin: %s.",sendername);
                                SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                                format(string, sizeof(string), "* %s has left the Channel (Kicked).", sendername);
                                SendIRCMessage(PlayerInfo[playerid][pPlayersChannel], COLOR_GREEN, string);
                                IRCInfo[PlayerInfo[giveplayerid][pPlayersChannel]][iPlayers] -= 1;
                                PlayerInfo[giveplayerid][pPlayersChannel] = 999;
                            }
                            else
                            {
                                SendClientMessage(playerid, COLOR_GREY, "   That player is not in your IRC Channel !");
                                return 1;
                            }
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GREY, "   That player is Offline !");
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of the Channel !");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   Invalid IRC Channel Number ! ");
                return 1;
            }
        }
        return 1;
    }
Reply
#2

I'm not too sure who wants to 344 lines of code for free. I tried, but gave up at the "join" part lol.

Not trying to be an asshole, but the best way to approach this is make use of the 'optional' specifiers in sscanf, and if you don't know how to use them, then you shouldn't be doing this for cash.

This is how far I got, not even sure it works.
pawn Код:
CMD:irc(playerid, params[])
{
    new x_nr[128];
    if(isnull(params))
    {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/irc join [channelnr] or /irc join [channelnr] [password])  (/irc Leave)  (/irc Admins)");
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc [name] [channelnr]");
        SendClientMessage(playerid, COLOR_WHITE, "Available names: MOTD, Password, NeedPass, Lock, Kick, Status");
        return 1;
    }
    if(!strcmp(x_nr, "join", true))
    {
        new
            channel,
            pass[128]
        ;
        if(sscanf(params, "s[128]dS[128]", x_nr, channel, pass)) // Capital S = optional string
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc join [channelnr] or /irc join [channelnr] [password]");
            return 1;
        }
        if(channel < 1 || channel > SCRIPT_MAXIRC)
        {
            SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above the amount !");
            return 1;
        }
        channel -= 1;
        if(IRCInfo[channel][iLock] == 0)
        {
            if(IRCInfo[channel][iNeedPass] == 0)
            {
                JoinChannelNr(playerid, channel);
            }
            else
            {
                if(!strlen(pass))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "There's a password required to join this Channel.");
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc join [channelnr] [password]");
                    return 1;
                }
                JoinChannel(playerid, channel, pass);
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "   That Channel is Locked, please choose a different one !");
            return 1;
        }
    }
    // more
    else if(!strcmp(x_nr, "othernames", true))
Reply
#3

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
I'm not too sure who wants to 344 lines of code for free. I tried, but gave up at the "join" part lol.

Not trying to be an asshole, but the best way to approach this is make use of the 'optional' specifiers in sscanf, and if you don't know how to use them, then you shouldn't be doing this for cash.

This is how far I got, not even sure it works.
pawn Код:
CMD:irc(playerid, params[])
{
    new x_nr[128];
    if(isnull(params))
    {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/irc join [channelnr] or /irc join [channelnr] [password])  (/irc Leave)  (/irc Admins)");
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc [name] [channelnr]");
        SendClientMessage(playerid, COLOR_WHITE, "Available names: MOTD, Password, NeedPass, Lock, Kick, Status");
        return 1;
    }
    if(!strcmp(x_nr, "join", true))
    {
        new
            channel,
            pass[128]
        ;
        if(sscanf(params, "s[128]dS[128]", x_nr, channel, pass)) // Capital S = optional string
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc join [channelnr] or /irc join [channelnr] [password]");
            return 1;
        }
        if(channel < 1 || channel > SCRIPT_MAXIRC)
        {
            SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above the amount !");
            return 1;
        }
        channel -= 1;
        if(IRCInfo[channel][iLock] == 0)
        {
            if(IRCInfo[channel][iNeedPass] == 0)
            {
                JoinChannelNr(playerid, channel);
            }
            else
            {
                if(!strlen(pass))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "There's a password required to join this Channel.");
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc join [channelnr] [password]");
                    return 1;
                }
                JoinChannel(playerid, channel, pass);
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "   That Channel is Locked, please choose a different one !");
            return 1;
        }
    }
    // more
    else if(!strcmp(x_nr, "othernames", true))
Vinci i understand your point completely. The optional parameters are a bit confusing. Im trying to get handy with them by every way i can.

By the way , the login part you did i think it will work. You just taught me how to use additions params while comparing two strings inside a command. Hopefully i will be able to do the rest myself. Gonna do them right now. I think it will work 95%. Hope i could Rep+6 you again. You're not an asshole. Youre being true. I like it that ways xD

In case anyone can convert the whole Command or tell me how to add optional params. Will be fucking awesome.
Reply
#4

Try this 2-3 months ago a guy gave me this to solve a problem I solved it but another one arised. I don't remember it. Anyway, here's the code:
pawn Код:
CMD:irc(playerid, params[])
{
     new x_nr[256];
     x_nr = strtok(params, idx);
     if(IsPlayerConnected(playerid))
        {
            if(isnull(params)) {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/irc join [channelnr] or /irc join [channelnr] [password])  (/irc Leave)  (/irc Admins)");
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc [name] [channelnr]");
                SendClientMessage(playerid, COLOR_WHITE, "Available names: MOTD, Password, NeedPass, Lock, Kick, Status");
                return 1;
            }
            if(strcmp(params,"join",true) == 0)
            {
                tmp = strtok(params, idx);
                if(isnull(params)) {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc join [channelnr] or /irc join [channelnr] [password]");
                    return 1;
                }
                new channel = strval(tmp);
                if(channel < 1 || channel > 10) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above 10 !"); return 1; }
                channel -= 1;
                if(IRCInfo[channel][iLock] == 0)
                {
                    if(IRCInfo[channel][iNeedPass] == 0)
                    {
                        JoinChannelNr(playerid, channel);
                    }
                    else
                    {
                        tmp = strtok(params, idx);
                        if(!strlen(tmp))
                        {
                            SendClientMessage(playerid, COLOR_WHITE, "There's a password required to join this Channel.");
                            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc join [channelnr] [password]");
                            return 1;
                        }
                        JoinChannel(playerid,channel,tmp);
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   That Channel is Locked, please choose a different one !");
                    return 1;
                }
            }
            else if(strcmp(params,"status",true) == 0)
            {
                for(new i = 0; i < sizeof(IRCInfo); i++)
                {
                    new string[128];
                    format(string, sizeof(string), "Channel %d: %d Players Connected.",i + 1, IRCInfo[i][iPlayers]);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                }
                return 1;
            }
            else if(strcmp(params,"password",true) == 0)
            {
                tmp = strtok(params, idx);
                if(isnull(params))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc password [channelnr] [password]");
                    return 1;
                }
                new channel = strval(tmp);
                if(channel < 1 || channel > 10) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above 10 !"); return 1; }
                channel -= 1;
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(wstring, sizeof(wstring), "%s", sendername);
                strmid(wstring, wstring, 0, strlen(wstring), 255);
                if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
                {
                    tmp = strtok(params, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc password [channelnr] [password]");
                        return 1;
                    }
                    new string[128];
                    strmid(IRCInfo[channel][iPassword], tmp, 0, strlen(tmp), 255);
                    format(string, sizeof(string), "You've changed the IRC Channel's Password to: %s.",IRCInfo[channel][iPassword]);
                    SendClientMessage(playerid, COLOR_YELLOW, string);
                    SaveIRC();
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of that Channel !");
                    return 1;
                }
            }
            else if(strcmp(params,"needpass",true) == 0)
            {
                tmp = strtok(params, idx);
                if(isnull(params))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc needpass [channelnr]");
                    return 1;
                }
                new channel = strval(tmp);
                if(channel < 1 || channel > 10) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above 10 !"); return 1; }
                channel -= 1;
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(wstring, sizeof(wstring), "%s", sendername);
                strmid(wstring, wstring, 0, strlen(wstring), 255);
                if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
                {
                    if(IRCInfo[channel][iNeedPass] != 0)
                    {
                        IRCInfo[channel][iNeedPass] = 0;
                        SendClientMessage(playerid, COLOR_YELLOW, "Players won't have to fill in a password in order to join the IRC Channel now.");
                    }
                    else
                    {
                        IRCInfo[channel][iNeedPass] = 1;
                        SendClientMessage(playerid, COLOR_YELLOW, "Players must fill in a password in order to join the IRC Channel now.");
                    }
                    SaveIRC();
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of that Channel !");
                    return 1;
                }
            }
            else if(strcmp(params,"lock",true) == 0)
            {
                tmp = strtok(params, idx);
                if(isnull(params))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc lock [channelnr]");
                    return 1;
                }
                new channel = strval(tmp);
                if(channel < 1 || channel > 10) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above 10 !"); return 1; }
                channel -= 1;
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(wstring, sizeof(wstring), "%s", sendername);
                strmid(wstring, wstring, 0, strlen(wstring), 255);
                if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
                {
                    if(IRCInfo[channel][iLock] != 0)
                    {
                        IRCInfo[channel][iLock] = 0;
                        SendClientMessage(playerid, COLOR_YELLOW, "You've unlocked the IRC Channel.");
                    }
                    else
                    {
                        IRCInfo[channel][iLock] = 1;
                        SendClientMessage(playerid, COLOR_YELLOW, "You've locked the IRC Channel.");
                    }
                    SaveIRC();
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of that Channel !");
                    return 1;
                }
            }
            else if(strcmp(params,"motd",true) == 0)
            {
                tmp = strtok(params, idx);
                if(isnull(params))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc motd [channelnr] [motdtext]");
                    return 1;
                }
                new channel = strval(tmp);
                if(channel < 1 || channel > 10) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above 10 !"); return 1; }
                channel -= 1;
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(wstring, sizeof(wstring), "%s", sendername);
                strmid(wstring, wstring, 0, strlen(wstring), 255);
                if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
                {
                    if(isnull(params))
                        return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /irc motd [motdtext]");


                    new result[128];
                    strmid(IRCInfo[channel][iMOTD], result, 0, strlen(result), 255);
                    SendClientMessage(playerid, COLOR_YELLOW, "You've adjusted the IRC Channel's MOTD Text.");
                    SaveIRC();
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of that Channel !");
                    return 1;
                }
            }
            else if(strcmp(params,"leave",true) == 0)
            {
                if(PlayersChannel[playerid] < 999)
                {
                    new string[128];
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(string, sizeof(string), "* %s has left the Channel.", sendername);
                    SendIRCMessage(PlayersChannel[playerid], COLOR_GREEN, string);
                    IRCInfo[PlayersChannel[playerid]][iPlayers] -= 1;
                    PlayersChannel[playerid] = 999;
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not in an IRC Channel !");
                    return 1;
                }
            }
            else if(strcmp(params,"admins",true) == 0)
            {
                for(new i = 0; i < sizeof(IRCInfo); i++)
                {
                    new string[128];
                    format(string, sizeof(string), "Channel %d: %s.", i + 1, IRCInfo[i][iAdmin]);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                }
                return 1;
            }
            else if(strcmp(params,"kick",true) == 0)
            {
                if(PlayersChannel[playerid] == 999)
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not in an IRC Channel !");
                    return 1;
                }
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(wstring, sizeof(wstring), "%s", sendername);
                strmid(wstring, wstring, 0, strlen(wstring), 255);
                if(strcmp(IRCInfo[PlayersChannel[playerid]][iAdmin],wstring, true ) == 0 )
                {
                    tmp = strtok(params, idx);
                    if(isnull(params))
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc kick [playerid/PartOfName]");
                        return 1;
                    }
                    giveplayerid = ReturnUser(tmp);
                    if(IsPlayerConnected(giveplayerid))
                    {
                        if(giveplayerid != INVALID_PLAYER_ID)
                        {
                            if(PlayersChannel[giveplayerid] == PlayersChannel[playerid])
                            {
                                new string[128];
                                GetPlayerName(playerid, sendername, sizeof(sendername));
                                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                                format(string, sizeof(string), "* You've kicked %s out of your IRC Channel.",giveplayer);
                                SendClientMessage(playerid, COLOR_YELLOW, string);
                                format(string, sizeof(string), "* You've been kicked out of the IRC Channel by Channel Admin: %s.",sendername);
                                SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                                format(string, sizeof(string), "* %s has left the Channel (Kicked).", sendername);
                                SendIRCMessage(PlayersChannel[playerid], COLOR_GREEN, string);
                                IRCInfo[PlayersChannel[giveplayerid]][iPlayers] -= 1;
                                PlayersChannel[giveplayerid] = 999;
                            }
                            else
                            {
                                SendClientMessage(playerid, COLOR_GREY, "   That player is not in your IRC Channel !");
                                return 1;
                            }
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GREY, "   That player is Offline !");
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of the Channel !");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   Invalid IRC Channel Number ! ");
                return 1;
            }
        }
        return 1;
    }
Reply
#5

Quote:
Originally Posted by Faisal_khan
Посмотреть сообщение
Try this 2-3 months ago a guy gave me this to solve a problem I solved it but another one arised. I don't remember it. Anyway, here's the code:
pawn Код:
CMD:irc(playerid, params[])
{
     new x_nr[256];
     x_nr = strtok(params, idx);
     if(IsPlayerConnected(playerid))
        {
            if(isnull(params)) {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/irc join [channelnr] or /irc join [channelnr] [password])  (/irc Leave)  (/irc Admins)");
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc [name] [channelnr]");
                SendClientMessage(playerid, COLOR_WHITE, "Available names: MOTD, Password, NeedPass, Lock, Kick, Status");
                return 1;
            }
            if(strcmp(params,"join",true) == 0)
            {
                tmp = strtok(params, idx);
                if(isnull(params)) {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc join [channelnr] or /irc join [channelnr] [password]");
                    return 1;
                }
                new channel = strval(tmp);
                if(channel < 1 || channel > 10) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above 10 !"); return 1; }
                channel -= 1;
                if(IRCInfo[channel][iLock] == 0)
                {
                    if(IRCInfo[channel][iNeedPass] == 0)
                    {
                        JoinChannelNr(playerid, channel);
                    }
                    else
                    {
                        tmp = strtok(params, idx);
                        if(!strlen(tmp))
                        {
                            SendClientMessage(playerid, COLOR_WHITE, "There's a password required to join this Channel.");
                            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc join [channelnr] [password]");
                            return 1;
                        }
                        JoinChannel(playerid,channel,tmp);
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   That Channel is Locked, please choose a different one !");
                    return 1;
                }
            }
            else if(strcmp(params,"status",true) == 0)
            {
                for(new i = 0; i < sizeof(IRCInfo); i++)
                {
                    new string[128];
                    format(string, sizeof(string), "Channel %d: %d Players Connected.",i + 1, IRCInfo[i][iPlayers]);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                }
                return 1;
            }
            else if(strcmp(params,"password",true) == 0)
            {
                tmp = strtok(params, idx);
                if(isnull(params))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc password [channelnr] [password]");
                    return 1;
                }
                new channel = strval(tmp);
                if(channel < 1 || channel > 10) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above 10 !"); return 1; }
                channel -= 1;
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(wstring, sizeof(wstring), "%s", sendername);
                strmid(wstring, wstring, 0, strlen(wstring), 255);
                if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
                {
                    tmp = strtok(params, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc password [channelnr] [password]");
                        return 1;
                    }
                    new string[128];
                    strmid(IRCInfo[channel][iPassword], tmp, 0, strlen(tmp), 255);
                    format(string, sizeof(string), "You've changed the IRC Channel's Password to: %s.",IRCInfo[channel][iPassword]);
                    SendClientMessage(playerid, COLOR_YELLOW, string);
                    SaveIRC();
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of that Channel !");
                    return 1;
                }
            }
            else if(strcmp(params,"needpass",true) == 0)
            {
                tmp = strtok(params, idx);
                if(isnull(params))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc needpass [channelnr]");
                    return 1;
                }
                new channel = strval(tmp);
                if(channel < 1 || channel > 10) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above 10 !"); return 1; }
                channel -= 1;
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(wstring, sizeof(wstring), "%s", sendername);
                strmid(wstring, wstring, 0, strlen(wstring), 255);
                if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
                {
                    if(IRCInfo[channel][iNeedPass] != 0)
                    {
                        IRCInfo[channel][iNeedPass] = 0;
                        SendClientMessage(playerid, COLOR_YELLOW, "Players won't have to fill in a password in order to join the IRC Channel now.");
                    }
                    else
                    {
                        IRCInfo[channel][iNeedPass] = 1;
                        SendClientMessage(playerid, COLOR_YELLOW, "Players must fill in a password in order to join the IRC Channel now.");
                    }
                    SaveIRC();
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of that Channel !");
                    return 1;
                }
            }
            else if(strcmp(params,"lock",true) == 0)
            {
                tmp = strtok(params, idx);
                if(isnull(params))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc lock [channelnr]");
                    return 1;
                }
                new channel = strval(tmp);
                if(channel < 1 || channel > 10) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above 10 !"); return 1; }
                channel -= 1;
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(wstring, sizeof(wstring), "%s", sendername);
                strmid(wstring, wstring, 0, strlen(wstring), 255);
                if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
                {
                    if(IRCInfo[channel][iLock] != 0)
                    {
                        IRCInfo[channel][iLock] = 0;
                        SendClientMessage(playerid, COLOR_YELLOW, "You've unlocked the IRC Channel.");
                    }
                    else
                    {
                        IRCInfo[channel][iLock] = 1;
                        SendClientMessage(playerid, COLOR_YELLOW, "You've locked the IRC Channel.");
                    }
                    SaveIRC();
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of that Channel !");
                    return 1;
                }
            }
            else if(strcmp(params,"motd",true) == 0)
            {
                tmp = strtok(params, idx);
                if(isnull(params))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc motd [channelnr] [motdtext]");
                    return 1;
                }
                new channel = strval(tmp);
                if(channel < 1 || channel > 10) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above 10 !"); return 1; }
                channel -= 1;
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(wstring, sizeof(wstring), "%s", sendername);
                strmid(wstring, wstring, 0, strlen(wstring), 255);
                if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
                {
                    if(isnull(params))
                        return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /irc motd [motdtext]");


                    new result[128];
                    strmid(IRCInfo[channel][iMOTD], result, 0, strlen(result), 255);
                    SendClientMessage(playerid, COLOR_YELLOW, "You've adjusted the IRC Channel's MOTD Text.");
                    SaveIRC();
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of that Channel !");
                    return 1;
                }
            }
            else if(strcmp(params,"leave",true) == 0)
            {
                if(PlayersChannel[playerid] < 999)
                {
                    new string[128];
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(string, sizeof(string), "* %s has left the Channel.", sendername);
                    SendIRCMessage(PlayersChannel[playerid], COLOR_GREEN, string);
                    IRCInfo[PlayersChannel[playerid]][iPlayers] -= 1;
                    PlayersChannel[playerid] = 999;
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not in an IRC Channel !");
                    return 1;
                }
            }
            else if(strcmp(params,"admins",true) == 0)
            {
                for(new i = 0; i < sizeof(IRCInfo); i++)
                {
                    new string[128];
                    format(string, sizeof(string), "Channel %d: %s.", i + 1, IRCInfo[i][iAdmin]);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                }
                return 1;
            }
            else if(strcmp(params,"kick",true) == 0)
            {
                if(PlayersChannel[playerid] == 999)
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not in an IRC Channel !");
                    return 1;
                }
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(wstring, sizeof(wstring), "%s", sendername);
                strmid(wstring, wstring, 0, strlen(wstring), 255);
                if(strcmp(IRCInfo[PlayersChannel[playerid]][iAdmin],wstring, true ) == 0 )
                {
                    tmp = strtok(params, idx);
                    if(isnull(params))
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc kick [playerid/PartOfName]");
                        return 1;
                    }
                    giveplayerid = ReturnUser(tmp);
                    if(IsPlayerConnected(giveplayerid))
                    {
                        if(giveplayerid != INVALID_PLAYER_ID)
                        {
                            if(PlayersChannel[giveplayerid] == PlayersChannel[playerid])
                            {
                                new string[128];
                                GetPlayerName(playerid, sendername, sizeof(sendername));
                                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                                format(string, sizeof(string), "* You've kicked %s out of your IRC Channel.",giveplayer);
                                SendClientMessage(playerid, COLOR_YELLOW, string);
                                format(string, sizeof(string), "* You've been kicked out of the IRC Channel by Channel Admin: %s.",sendername);
                                SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                                format(string, sizeof(string), "* %s has left the Channel (Kicked).", sendername);
                                SendIRCMessage(PlayersChannel[playerid], COLOR_GREEN, string);
                                IRCInfo[PlayersChannel[giveplayerid]][iPlayers] -= 1;
                                PlayersChannel[giveplayerid] = 999;
                            }
                            else
                            {
                                SendClientMessage(playerid, COLOR_GREY, "   That player is not in your IRC Channel !");
                                return 1;
                            }
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GREY, "   That player is Offline !");
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of the Channel !");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   Invalid IRC Channel Number ! ");
                return 1;
            }
        }
        return 1;
    }
I wanted to do make a command like that using sscanf. By the x_nr[256] , Dont you think that will create big memory loss? We never use 256 Cells in Pawn. Thats lags is what i know.
Reply
#6

Hmm.. Yeah it will consume memory try using x_nr[128] or x_nr[64].
Reply
#7

Quote:
Originally Posted by Faisal_khan
Посмотреть сообщение
Hmm.. Yeah it will consume memory try using x_nr[128] or x_nr[64].
Aigh' By the way. I will see how can i make this command work. Thanks for the help bro . Rep+6 again.
Reply
#8

pawn Код:
CMD:irc(playerid, params[])
    {
        if(IsPlayerConnected(playerid))
        {
            new x_nr[16], val[32], val2[32], val3[32];
            if(sscanf(params, "s[16]S(NoNe)[32]S(nOnE)[32]S(NOne)[32]", x_nr, val, val2, val3)) {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/irc join [channelnr] or /irc join [channelnr] [password])  (/irc Leave)  (/irc Admins)");
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc [name] [channelnr]");
                SendClientMessage(playerid, COLOR_WHITE, "Available names: MOTD, Password, NeedPass, Lock, Kick, Status");
                return 1;
            }
            if(strcmp(x_nr,"join",true) == 0)
            {
                if(!strlen(val) || !strcmp("NoNe", val, true))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc join [channelnr] or /irc join [channelnr] [password]");
                    return 1;
                }
                new channel = strval(val);
                if(channel < 1 || channel > SCRIPT_MAXIRC) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above the amount !"); return 1; }
                channel -= 1;
                if(IRCInfo[channel][iLock] == 0)
                {
                    if(IRCInfo[channel][iNeedPass] == 0)
                    {
                        JoinChannelNr(playerid, channel);
                    }
                    else
                    {
                        if(!strlen(val2) || !strcmp("nOnE", val2, true))
                        {
                            SendClientMessage(playerid, COLOR_WHITE, "There's a password required to join this Channel.");
                            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc join [channelnr] [password]");
                            return 1;
                        }
                        JoinChannel(playerid,channel,val2);
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   That Channel is Locked, please choose a different one !");
                    return 1;
                }
            }
            else if(strcmp(x_nr, "create", true) == 0)
            {
                GetPlayerName(playerid, sendername, sizeof(sendername));
                if(!strlen(val) || !strcmp("NoNe", val, true))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /irc create [number]");
                    return 1;
                }
                new channel;
                channel = strval(val);
                if(channel < 1 || channel > SCRIPT_MAXIRC) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above the amount !"); return 1; }
                if(PlayerInfo[playerid][pConnectTime] < 50)
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "You must have 50 and over time in FC to use this !");
                    return 1;
                }
                for(new i = 0; i < sizeof(IRCInfo); i++)
                {
                    if(strcmp(IRCInfo[i][iAdmin], sendername, true) == 0)
                    {
                        format(string, sizeof(string), "You already have control over IRC Channel: %d", i);
                        SendClientMessage(playerid, COLOR_GRAD2, string);
                        return 1;
                    }
                }
                if(strcmp(IRCInfo[channel][iAdmin], "None", true) == 0)
                {
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(string, sizeof(string), "you are now an IRC Admin over Channel %d.", channel);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    format(string, sizeof(string), "%s", sendername);
                    strmid(IRCInfo[channel][iAdmin], string, 0, strlen(string), 255);
                    IRCInfo[channel][iNeedPass] = 0; IRCInfo[channel][iLock] = 0;
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "This channel is taken already !");
                }
                return 1;
            }
            else if(strcmp(x_nr,"status",true) == 0)
            {
                for(new i = 0; i < sizeof(IRCInfo); i++)
                {
                    if(strcmp(IRCInfo[i][iAdmin], "None", true) == 0)
                    {
                        return 1;
                    }
                    else
                    {
                        format(string, sizeof(string), "Channel %d: %d Players Connected.",i + 1, IRCInfo[i][iPlayers]);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                    }
                }
                return 1;
            }
            else if(strcmp(x_nr,"password",true) == 0)
            {
                if(!strlen(val) || !strcmp("NoNe", val, true))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc password [channelnr] [password]");
                    return 1;
                }
                new channel = strval(val2);
                if(channel < 1 || channel > SCRIPT_MAXIRC) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above the amount !"); return 1; }
                channel -= 1;
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s", sendername);
                strmid(wstring, string, 0, strlen(string), 255);
                if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
                {
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(val3) || !strcmp("NOne", val3, true))
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc password [channelnr] [password]");
                        return 1;
                    }
                    strmid(IRCInfo[channel][iPassword], val3, 0, strlen(val3), 255);
                    format(string, sizeof(string), "You've changed the IRC Channel's Password to: %s.",IRCInfo[channel][iPassword]);
                    SendClientMessage(playerid, COLOR_YELLOW, string);
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of that Channel !");
                    return 1;
                }
            }
            else if(strcmp(x_nr,"needpass",true) == 0)
            {
                if(!strlen(val) || !strcmp("NoNe", val, true))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc needpass [channelnr]");
                    return 1;
                }
                new channel = strval(val);
                if(channel < 1 || channel > SCRIPT_MAXIRC) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above the amount !"); return 1; }
                channel -= 1;
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s", sendername);
                strmid(wstring, string, 0, strlen(string), 255);
                if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
                {
                    if(IRCInfo[channel][iNeedPass] != 0)
                    {
                        IRCInfo[channel][iNeedPass] = 0;
                        SendClientMessage(playerid, COLOR_YELLOW, "Players won't have to fill in a password in order to join the IRC Channel now.");
                    }
                    else
                    {
                        IRCInfo[channel][iNeedPass] = 1;
                        SendClientMessage(playerid, COLOR_YELLOW, "Players must fill in a password in order to join the IRC Channel now.");
                    }
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of that Channel !");
                    return 1;
                }
            }
            else if(strcmp(x_nr,"lock",true) == 0)
            {
                if(!strlen(val) || !strcmp("NoNe", val, true))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc lock [channelnr]");
                    return 1;
                }
                new channel = strval(val);
                if(channel < 1 || channel > SCRIPT_MAXIRC) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above the amount !"); return 1; }
                channel -= 1;
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s", sendername);
                strmid(wstring, string, 0, strlen(string), 255);
                if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
                {
                    if(IRCInfo[channel][iLock] != 0)
                    {
                        IRCInfo[channel][iLock] = 0;
                        SendClientMessage(playerid, COLOR_YELLOW, "You've unlocked the IRC Channel.");
                    }
                    else
                    {
                        IRCInfo[channel][iLock] = 1;
                        SendClientMessage(playerid, COLOR_YELLOW, "You've locked the IRC Channel.");
                    }
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of that Channel !");
                    return 1;
                }
            }
            else if(strcmp(x_nr,"motd",true) == 0)
            {
                if(!strlen(val) || !strcmp("NoNe", val, true))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc motd [channelnr] [motdtext]");
                    return 1;
                }
                new channel = strval(val);
                if(channel < 1 || channel > SCRIPT_MAXIRC) { SendClientMessage(playerid, COLOR_GREY, "   Channel Number can't be below 1 or above the amount !"); return 1; }
                channel -= 1;
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s", sendername);
                strmid(wstring, string, 0, strlen(string), 255);
                if(strcmp(IRCInfo[channel][iAdmin],wstring, true ) == 0 )
                {
                    if(!strlen(val2) || !strcmp("nOnE", val2, true))
                    {
                        SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /irc motd [motdtext]");
                        return 1;
                    }
                    strmid(IRCInfo[channel][iMOTD], result, 0, strlen(val2), 255);
                    SendClientMessage(playerid, COLOR_YELLOW, "You've adjusted the IRC Channel's MOTD Text.");
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of that Channel !");
                    return 1;
                }
            }
            else if(strcmp(x_nr,"leave",true) == 0)
            {
                if(PlayerInfo[playerid][pPlayersChannel] < 999)
                {
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(string, sizeof(string), "* %s has left the Channel.", sendername);
                    SendIRCMessage(PlayerInfo[playerid][pPlayersChannel], COLOR_GREEN, string);
                    IRCInfo[PlayerInfo[playerid][pPlayersChannel]][iPlayers] -= 1;
                    PlayerInfo[playerid][pPlayersChannel] = 999;
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not in an IRC Channel !");
                    return 1;
                }
            }
            else if(strcmp(x_nr,"admins",true) == 0)
            {
                for(new i = 0; i < sizeof(IRCInfo); i++)
                {
                    format(string, sizeof(string), "Channel %d: %s.", i + 1, IRCInfo[i][iAdmin]);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                }
                return 1;
            }
            else if(strcmp(x_nr,"kick",true) == 0)
            {
                if(PlayerInfo[playerid][pPlayersChannel] == 999)
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not in an IRC Channel !");
                    return 1;
                }
                new wstring[128];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s", sendername);
                strmid(wstring, string, 0, strlen(string), 255);
                if(strcmp(IRCInfo[PlayerInfo[playerid][pPlayersChannel]][iAdmin],wstring, true ) == 0 )
                {
                    if(!strlen(val))
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /irc kick [playerid/PartOfName]");
                        return 1;
                    }
                    giveplayerid = ReturnUser(val);
                    if(IsPlayerConnected(giveplayerid))
                    {
                        if(giveplayerid != INVALID_PLAYER_ID)
                        {
                            if(PlayerInfo[giveplayerid][pPlayersChannel] == PlayerInfo[playerid][pPlayersChannel])
                            {
                                GetPlayerName(playerid, sendername, sizeof(sendername));
                                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                                format(string, sizeof(string), "* You've kicked %s out of your IRC Channel.",giveplayer);
                                SendClientMessage(playerid, COLOR_YELLOW, string);
                                format(string, sizeof(string), "* You've been kicked out of the IRC Channel by Channel Admin: %s.",sendername);
                                SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                                format(string, sizeof(string), "* %s has left the Channel (Kicked).", sendername);
                                SendIRCMessage(PlayerInfo[playerid][pPlayersChannel], COLOR_GREEN, string);
                                IRCInfo[PlayerInfo[giveplayerid][pPlayersChannel]][iPlayers] -= 1;
                                PlayerInfo[giveplayerid][pPlayersChannel] = 999;
                            }
                            else
                            {
                                SendClientMessage(playerid, COLOR_GREY, "   That player is not in your IRC Channel !");
                                return 1;
                            }
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GREY, "   That player is Offline !");
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not the Admin of the Channel !");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   Invalid IRC Channel Number ! ");
                return 1;
            }
        }
        return 1;
    }
Not tested, should work :3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)