[Help]Noob question (strcmp)
#1

Sorry for the title I didn't know what else to call it. But I have a question, how can I get the two values a user inputs using strcmp and check if they're not empty? Lets say I have this..

pawn Код:
if(strcmp(cmd, "/action", true) == 0){

if (value1 == 2) {
 print("Value1 is 2");
}

else if (value2 == 3) {
print("Value2 is 3.");

} else {
print("Something else.");
}
 return 1;
}
And lets say the users typed the command /action 2 3 it should return value1 is 2 and value2 is 3. I hope that explains what I want, if not I can try and explain it better .. thank you in advance.
Reply
#2

Use dcmd or zcmd and sscanf

Код:
dcmd_action(playerid, params[])
{
  new value, value2;
  if(sscanf(params, "dd", value, value2)) return SendClientMessage(playerid, WHITE, "Use: /action [value] [value]");
  if(value == 2)
  {
    printf...
  }
  ...
Reply
#3

maybe its me but i think i saw in title strcmp
Reply
#4

You could use strtok.
But I think DCMD or ZCMD and sscanf would be better.
Reply
#5

yeah i agree for more informations go to wiki
Reply
#6

Well I need to use strcmp cause I'm going to use two names for the same command and I don't think you can do that with DCMD. So if anyone can show me how to do that with strcmp it'll be great xD Thanks in advance
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)