[Help] - Using params under "OnPlayerCommandReceived"
#1

Hi guys! I need to use a command with params. So, if i type just /arrest i will get the message with "usage: /arrest id but if i type: /arest id:9 for example, i will get that message with /leave - for exit... Also if you guys have a better idea to make these commands work under this if ( PlayerInfo[ playerid ][ ActionID ] == 8 ) ...

pawn Код:
public OnPlayerCommandReceived( playerid, cmdtext[ ] )
{
    if ( PlayerInfo[ playerid ][ ActionID ] == 8 )
    {
        if ( !strcmp( cmdtext, "/leave", true ) || !strcmp( cmdtext, "/arrest", true ) || !strcmp( cmdtext, "/neon", true ) || !strcmp( cmdtext, "/radio", true ) ) return ( 1 );
        Announce( playerid, "~g~~h~Use ~r~~h~/leave ~g~~h~for exit.", 3000, 4 );
        return ( 0 );
    }
}
Reply
#2

Erm?
pawn Код:
CMD:arrest(playerid, params[])
{
   if ( PlayerInfo[ playerid ][ ActionID ] == 8 ) return 1; // Or error message
   else
   {
         // All working code
    }
return 1;
This? Or did I misunderstand something?
Reply
#3

You don't understand... i want to include that command in this if ( !strcmp( cmdtext, "/ar", true ) but if i add params to the command don't work... without params everything it's ok!
Reply
#4

What Rajat_Pawar is saying is: Why do you use strcmp commands when you already have ZCMD?
Reply
#5

Shit I don't use STRCMP commands
I'm using this callback public OnPlayerCommandReceived( playerid, cmdtext[ ] ) to check what command was used by player, and then if player it's in a minigame...a message with "~g~~h~Use ~r~~h~/leave ~g~~h~for exit." will appear ...
Reply
#6

you could always try sscanf, if I'm understanding correctly, if not then I'm very sorry.
Reply
#7

Using sscanf instead of this? if ( !strcmp( cmdtext, "/leave", true ) ) ??
Reply
#8

Yeah, sorry, I told you I didn't understand , put, something like
pawn Код:
new Params;
sscanf(cmdtext, "s", Params))
Reply
#9

Thanks to Romel for correcting this.
@MikeLovesToHelp, I think you should make the Params like
pawn Код:
new Params[60];
But I think with sscanf that will still not work, that's just my thinking

-------

OT:
I get what you meant, maybe use strfind? ( I know, this is a stupid idea, but why not try? )
Reply
#10

first of all greentarch.
Params is not a integer.
If string doesn't have sizes putted on, only something like params[].
Doesn't mean it is a integer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)