[Include] [INC] Command Toolkit
#1

Hey mates! Today I'm bringing you my new include for pawno:
CommandToolkit!
It will add only two functions, but the ones atleast I find very useful.

First of them is:
string GetParam(text[],seporator[],bool:tillend,index=0);
this function returns a parameter from the command easily. Text is the commandtext, seporator is the symbol that will be held as seporator that seporates the command from parameter, or parameters themselves. tillend is a boolean stating wether after the seporator was found, the remaining string after the seporator should be returned, or only the string until next seporator. index is where to start looking for the seporator.

And another is:
bool IsInvalidParam(param[]);
This one, returns wether the parameter was given or not.

Here is a piece of script for you to understand what I'm talking about a lil' bit better:

My login command:
pawn Code:
if (!strcmp("/login", cmdtext, true,6))
    {
        if(playerDB[playerid][authstate]!=0)
        {
            SendClientMessage(playerid,LOGIN_COLOR,"AFS: You are already logged in.");
            return 1;
        }
       
        new file[128],name[MAX_PLAYER_NAME];
        GetPlayerName(playerid,name,sizeof(name));
        format(file,sizeof(file),"saves/%s.ini",name);
       
        if(!fexist(file))
        {
            SendClientMessage(playerid,LOGIN_COLOR,"AFS: you are not registered yet, please use: /register");
            return 1;
        }

        if(!cmdtext[6])
        {
            SendClientMessage(playerid,LOGIN_COLOR,"AFS: login: /login [password]");
            return 1;
        }
       
        //And here is the part with these functions:
        new password[128];
        password = GetParam(cmdtext," ",true);
        if(IsInvalidParam(password))
        {
            SendClientMessage(playerid,LOGIN_COLOR,"AFS: the password was not given.");
            return 1;
        }
       
        if(!CheckPassword(file,password,"Slaptazodis"))
        {
            SendClientMessage(playerid,LOGIN_COLOR,"AFS: the given password is incorrect.");
            return 1;
        }

        SendClientMessage(playerid,LOGIN_COLOR,"AFS: you have succesfully logged in!");
        playerDB[playerid][authstate]=2;
        return 1;
    }
Easyer huh?

Here's the download:


Cheers, KANiS!
Reply
#2

Somewhat, easier for new players. Good work.
Reply
#3

great work KANiS6111
Reply
#4

Good work, I will use this
Reply
#5

Nice idea Kanis
Reply
#6

lol its looks like stealed somepart of ladmin cmd ha ha
Reply
#7

simple... keep workin =)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)