How to convert strcmp to ZCMD/DCMD or vice versa. -
Mean - 25.02.2011
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
Re: How to convert strcmp to ZCMD/DCMD or vice versa. -
Rock18 - 25.02.2011
Thanks . Didn't know .
strcmp
Код:
id = strval( cmdtext ); //cmdtext
ZCMD
Код:
id = strval( params ); // So, cmdtext here turns into params.
Re: How to convert strcmp to ZCMD/DCMD or vice versa. -
Mean - 25.02.2011
Exactly, it turns into params.
Re: How to convert strcmp to ZCMD/DCMD or vice versa. -
Memoryz - 25.02.2011
Anyway to do this a lot faster? I got about 80 commands.
Re: How to convert strcmp to ZCMD/DCMD or vice versa. -
alpha500delta - 26.02.2011
You can use the 'replace' function of pawno
Re: How to convert strcmp to ZCMD/DCMD or vice versa. -
Mean - 26.02.2011
Not "alot" faster, but it's much faster if you have alot of cmds.
Re: How to convert strcmp to ZCMD/DCMD or vice versa. -
maramizo - 26.02.2011
Mean, good job.
/support.
Re: How to convert strcmp to ZCMD/DCMD or vice versa. -
LZLo - 26.02.2011
nice tutorial for DCMD and ZCMD, but y_commands are the fastest
(i think DCMD is not less useful than y_commands
)
nice tutorial!
Re: How to convert strcmp to ZCMD/DCMD or vice versa. -
Mean - 26.02.2011
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.
Respuesta: How to convert strcmp to ZCMD/DCMD or vice versa. -
zSuYaNw - 27.02.2011
more good tutorials, good job!
Re: Respuesta: How to convert strcmp to ZCMD/DCMD or vice versa. -
Mean - 27.02.2011
Quote:
Originally Posted by [Full]Garfield[XDB]
more good tutorials, good job!
|
Thankies you.