PDA

View Full Version : [Tutorial] How to convert strcmp to ZCMD/DCMD or vice versa.


Mean
25/02/2011, 08:56 PM
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:
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.
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:
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:
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

Rock18
25/02/2011, 09:40 PM
Thanks . Didn't know .

strcmp
id = strval( cmdtext ); //cmdtext
ZCMD
id = strval( params ); // So, cmdtext here turns into params.

Mean
25/02/2011, 09:42 PM
Exactly, it turns into params.

Memoryz
25/02/2011, 10:28 PM
Anyway to do this a lot faster? I got about 80 commands.

alpha500delta
26/02/2011, 10:01 AM
You can use the 'replace' function of pawno

Mean
26/02/2011, 10:14 AM
Not "alot" faster, but it's much faster if you have alot of cmds.

maramizo
26/02/2011, 12:23 PM
Mean, good job.
/support.

LZLo
26/02/2011, 01:18 PM
nice tutorial for DCMD and ZCMD, but y_commands are the fastest :D
(i think DCMD is not less useful than y_commands :))

nice tutorial!

Mean
26/02/2011, 08:04 PM
Mean, good job.
/support.I don't understand what this /support is for, but thanks ;).

nice tutorial for DCMD and ZCMD, but y_commands are the fastest :D
(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.

zSuYaNw
27/02/2011, 03:30 AM
more good tutorials, good job!

Mean
27/02/2011, 01:16 PM
Garfield[XDB];1092137']more good tutorials, good job!Thankies you.