25.02.2011, 19:56
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:
We want it in ZCMD or DCMD.
What we do mainly is that we replace the strcmp part, with the DCMD/ZCMD part.
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:
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:
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
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" );
}
What we do mainly is that we replace the strcmp part, with the DCMD/ZCMD part.
pawn Код:
CMD:test( playerid, params[ ] )
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" );
}
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" );
}
Hope I have helped with this tutorial.
CHEERS