[Tutorial] How to convert strcmp to ZCMD/DCMD or vice versa.
#1

Introduction
WellHello, I saw ALOT of people that don't know this, they've been asking how to convert strcmp to ZCMD/DCMD, well here is a solution.

First, we have a standard strcmp command:
pawn Код:
if( strcmp( cmdtext, "/test", true, 5 ) == 0 )
{
    new id;
    id = strval( cmdtext );
    return SendClientMessage( id, 0xAAAAAA, "Test" );
}
We want it in ZCMD or DCMD.
What we do mainly is that we replace the strcmp part, with the DCMD/ZCMD part.
pawn Код:
CMD:test( playerid, params[ ] )
So, now we converted the command to ZCMD, but you might getting errors, if it's a multi parameter command.
So, strcmp uses cmdtext[ ] as its param, and ZCMD/DCMD use params[ ]
So, you need to replace all your "cmdtext" to "params". Example:
pawn Код:
CMD:test( playerid, params[ ] /* Here are the params */ )
{
    new id;
    id = strval( params ); // So, cmdtext here turns into params.
    return SendClientMessage( id, 0xAAAAAA, "Test" );
}
So you have now converted it to ZCMD.
You do the same with DCMD, because it uses "params" too, but, you need to do it like this:
pawn Код:
public OnPlayerCommandText( playerid, cmdtext[ ] )
{
    dcmd( test, 4, cmdtext ); // Note that the characters in DCMD exclude the "/", so we use 4, instead of 5 we used in strcmp
    return 0;
}

dcmd_test( playerid, params[ ] )
{
    new id;
    id = strval( params ); // We use params again
    return SendClientMessage( id, 0xAAAAAA, "Test" );
}
When you use ZCMD, make sure you have deleted all your strcmp commands, because they can conflict, it's best to remove the WHOLE OnPlayerCommandText ( only in ZCMD ) and put the commands anywhere, just like a public.

Hope I have helped with this tutorial.

CHEERS
Reply
#2

Thanks . Didn't know .

strcmp
Код:
id = strval( cmdtext ); //cmdtext
ZCMD
Код:
id = strval( params ); // So, cmdtext here turns into params.
Reply
#3

Exactly, it turns into params.
Reply
#4

Anyway to do this a lot faster? I got about 80 commands.
Reply
#5

You can use the 'replace' function of pawno
Reply
#6

Not "alot" faster, but it's much faster if you have alot of cmds.
Reply
#7

Mean, good job.
/support.
Reply
#8

nice tutorial for DCMD and ZCMD, but y_commands are the fastest
(i think DCMD is not less useful than y_commands )

nice tutorial!
Reply
#9

Quote:
Originally Posted by maramizo
Посмотреть сообщение
Mean, good job.
/support.
I don't understand what this /support is for, but thanks .

Quote:
Originally Posted by LZLo
Посмотреть сообщение
nice tutorial for DCMD and ZCMD, but y_commands are the fastest
(i think DCMD is not less useful than y_commands )

nice tutorial!
Thank you. Y_Commands is same as converting to ZCMD, it uses the same macro. So you don't even need to convert from ZCMD to Y_Commands, just put the include.
Reply
#10

more good tutorials, good job!
Reply
#11

Quote:
Originally Posted by [Full]Garfield[XDB]
View Post
more good tutorials, good job!
Thankies you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)