SA-MP Forums Archive
[Help]Noob question (strcmp) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help]Noob question (strcmp) (/showthread.php?tid=114544)



[Help]Noob question (strcmp) - zilvernex - 19.12.2009

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.



Re: [Help]Noob question (strcmp) - M4S7ERMIND - 19.12.2009

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...
  }
  ...



Re: [Help]Noob question (strcmp) - SlashPT - 19.12.2009

maybe its me but i think i saw in title strcmp


Re: [Help]Noob question (strcmp) - Rzzr - 19.12.2009

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


Re: [Help]Noob question (strcmp) - SlashPT - 19.12.2009

yeah i agree for more informations go to wiki


Re: [Help]Noob question (strcmp) - zilvernex - 20.12.2009

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