17.03.2014, 00:00
Quote:
Well, I actually never managed to get a command like /car get (has 1 paramter, id)/create(has multiple paramters like model, colors etc) to get it working with sscanf only, I always got some warnings of format specificer does not match parameter count, etc..
If someone has any example code for me or could tell me how to do it exactly that'd be great. Thanks! |
pawn Код:
new option[12],param[5];
sscanf(params,"s[12]I(0)I(0)I(0)I(0)", option, param[0],param[1],param[2],param[3],param[4]);
pawn Код:
if(strcmp(option,"create",false) == 0)
{
new model = param[0];
new color = param[1];
new color2 = param[2];
}
pawn Код:
new option[12];
sscanf(params,"s[12] ",option);
if(strcmp(option,"create", false) == 0)
{
new model, color, color2;
sscanf(params[strlen(option)],"iii", model, color, color2);
}
EDIT:
This
pawn Код:
new params[128];
new option[12];
strcat(params, "create 400 2 2");
sscanf(params, "s[12] ", option);
printf("%s",option);
new model, color, color2;
sscanf(params[strlen(option)],"iii",model, color, color2);
printf("%d %d %d", model, color, color2);
Код:
create 400 2 2