Converting command to ZCMD?
#1

Hi all. Is it possible to convert this(or any command for the matter):

Код:
if(strcmp(cmd, "/do", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(gPlayerLogged[playerid] == 0)
	        {
	            SendClientMessage(playerid, COLOR_GREY, "   You havent logged in yet !");
	            return 1;
	        }
	        if(PlayerInfo[playerid][pMuted] == 1)
			{
				SendClientMessage(playerid, TEAM_CYAN_COLOR, "You cannot speak, you have been silenced");
				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: /do [action]");
				return 1;
			}
			if(PlayerInfo[playerid][pAdminDuty] == 1)
			{
   				format(string, sizeof(string), "%s (( Admin ))", result);
			}
			if(PlayerInfo[playerid][pMaskuse] == 1 && PlayerInfo[playerid][pAdminDuty] == 0)
			{
			    format(string, sizeof(string), "* %s (( Stranger ))", result);
			}
			if(PlayerInfo[playerid][pAdminDuty] == 0 && PlayerInfo[playerid][pMaskuse] == 0)
			{
				format(string, sizeof(string), "* %s (( %s ))", result, sendername);
			}
			ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
			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] [/DO] %s: %s",d,m,y,h,mi,s,sendername,giveplayer, result);
			ActionLog(string);
		}
		return 1;
	}
Into a CMD:do?

Thanks
Reply
#2

Yes,Try:
pawn Код:
CMD:do(playerid,cmdtext[])
    {
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_GREY, "   You havent logged in yet !");
                return 1;
            }
            if(PlayerInfo[playerid][pMuted] == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "You cannot speak, you have been silenced");
                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(isnull(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /do [action]");
                return 1;
            }
            if(PlayerInfo[playerid][pAdminDuty] == 1)
            {
                format(string, sizeof(string), "%s (( Admin ))", result);
            }
            if(PlayerInfo[playerid][pMaskuse] == 1 && PlayerInfo[playerid][pAdminDuty] == 0)
            {
                format(string, sizeof(string), "* %s (( Stranger ))", result);
            }
            if(PlayerInfo[playerid][pAdminDuty] == 0 && PlayerInfo[playerid][pMaskuse] == 0)
            {
                format(string, sizeof(string), "* %s (( %s ))", result, sendername);
            }
            ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
            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] [/DO] %s: %s",d,m,y,h,mi,s,sendername,giveplayer, result);
            ActionLog(string);
            return 1;
    }
EDIT: remove IsPlayerConnected(playerid),because not connected player can't do commands,can he?
Reply
#3

So for converting commands all we do is change

Код:
if(strcmp(cmd, "/do", true) == 0)
to

Код:
CMD:do(playerid,cmdtext[])
Reply
#4

and !strlen to isnull if ZCMD
Reply
#5

Thanks. +REP
Reply
#6

No,

change the command to

pawn Код:
CMD:do(playerid, params[])
And replace every " cmdtext " with " params " in the command.
Reply
#7

Quote:
Originally Posted by Guitar
Посмотреть сообщение
No,

change the command to

pawn Код:
CMD:do(playerid, params[])
And replace every " cmdtext " with " params " in the command.
So what? It's still same
Reply
#8

I have +REPd you both. Thanks everyone that's all the help I need.
Reply
#9

Quote:
Originally Posted by AqEeNo
Посмотреть сообщение
So what? It's still same
Sometimes, it gives an error if he doesn't change from cmdtext to params.
Reply
#10

Quote:
Originally Posted by Guitar
Посмотреть сообщение
Sometimes, it gives an error if he doesn't change from cmdtext to params.
What error?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)