Quote:
Originally Posted by Gh0sT_
Ok, I have problem with strcmp. So, for example:
I have command smth like this: /a weapon id gunid ammount
And, everything is okay, just strcmp is fucked up.
cmd example:
pawn Код:
CMD:a( playerid, params[ ] ) { if( ! strcmp( params, "weapon", true ) ) { .................... } else if( ! strcmp( params, "ban", true ) ) { ...................... } else { SendClientMessage( playerid, COLOR, "/a [weapon/ban]" ); } return true; }
and when I type in game /a weapon [another params] I get SendClientMessage( playerid, COLOR, "/a [weapon/ban]" );
|
There's nothing wrong with strcmp, it's your logic. Look at what's happening for a second when you type this:
/a weapon id
pawn Код:
if( ! strcmp( "weapon id", "weapon", true ) )
Obviously they aren't going to match! You need to split the parameters by spaces and take out each parameter for each separate part of the command. Use a function like sscanf.
Person above beat me to it