05.05.2015, 04:57
Quote:
Assuming garageid is an integer this:
Код:
switch(strval(garageid)) { case 1://player have typed 1 { //your code } case 2://player have typed 2 { //your code } default://mkae use of this when the player have typed an invalid number } A proper way would be getting the int value from the delimited cmdtext (strtok, dcmd) and put that value into the switch (so basically strval(cmd) instead of strval(garageid) - assuming strtok or dcmd and "cmd" containing the value as string). Theoretically strfind does work for this too, just that it would detect "/checkgarageaddrandomtexthere" as "/checkgarage", since it contains "/checkgarage". TiXz0r, look for command processors on the forums and maybe some tutorials, they explain the differences between the methods very well. |
He's just asking a method to detect what values a player typed (known as params in YCMD, ZCMD..).
My code will work because you can't have direct integers from a command, you always have to convert it using strval, strtok, sscanf...
And strval don't read int values, they convert https://sampwiki.blast.hk/wiki/Strval