strcmp
#7

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
Reply


Messages In This Thread
strcmp - by Gh0sT_ - 24.01.2011, 12:16
Re: strcmp - by alpha500delta - 24.01.2011, 12:31
Re: strcmp - by Gh0sT_ - 24.01.2011, 13:12
Re: strcmp - by Stylock - 24.01.2011, 13:46
Re: strcmp - by Gh0sT_ - 24.01.2011, 14:07
Re: strcmp - by Stylock - 24.01.2011, 14:25
Re: strcmp - by JaTochNietDan - 24.01.2011, 14:37

Forum Jump:


Users browsing this thread: 1 Guest(s)