01.10.2017, 15:27
well, if you use zcmd and sscanf it will be that easy:
but with your code it will need to be
PHP код:
CMD:house(playerid, params[])
{
new action[7], interiortype[11], price;
if(sscanf(params,"s[6]s[10]i", action, interiortype, price))
{
if(strcmp(interiortype, "Small1", true) == 0)
{
//my code
}
}
else
{
SCM(playerid, COLOR_ERROR,"Usage: /house create [InteriorType] [Price]");
}
}
PHP код:
new cmd[256], tmp[256], idx;
cmd = strtok(cmdtext, idx);
if(strfind(cmd, "/house create", true) == 0) // check if /house create, exists in the start
{
new where = -1;
if(strlen(cmd) > 13 && (where = strfind(cmd, " ", true, 13)) != -1) // check if there's more text after /house create if yes, find the which will be after that text
{
new House[32];
strmid(House, cmd, 13, where); // 13 may need to be 14 , get the internior kind, starting from the end of /house create ending at the space which found by strfind
printf("Interior got: %s", House); // simple debug
if(strcmp(House, "Small1", true) == 0) // check interior kind
{
` new tempprice[10], price;
strmid(tempprice, cmd, where, strlen(cmd)); // get the prize which starts after the last space " ", ends at string finish
printf("Prize got: %d", tempprice); // simple debug
price = strval(tempprice); // gets the prize as integer
//my code
}
}
else
{
SCM(playerid,COLOR_ERROR,"Usage: /house create [InteriorType] [Price]");
}
}