Simple help
#10

well, if you use zcmd and sscanf it will be that easy:
PHP код:
CMD:house(playeridparams[])
{
    new 
action[7], interiortype[11], price;
    if(
sscanf(params,"s[6]s[10]i"actioninteriortypeprice))
    {
        if(
strcmp(interiortype"Small1"true) == 0)
        {
            
//my code
        
}
    }
    else
    {
        
SCM(playeridCOLOR_ERROR,"Usage: /house create [InteriorType] [Price]");
    }

but with your code it will need to be

PHP код:
new cmd[256], tmp[256], idx;
cmd strtok(cmdtextidx);
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" "true13)) != -1// check if there's more text after /house create if yes, find the which will be after that text
    
{
        new 
House[32];
        
strmid(Housecmd13where); // 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]");
    }

Reply


Messages In This Thread
Simple help - by Kraeror - 01.10.2017, 12:49
Re: Simple help - by jlalt - 01.10.2017, 12:51
Re: Simple help - by Kraeror - 01.10.2017, 12:54
Re: Simple help - by Kraeror - 01.10.2017, 13:22
Re: Simple help - by Kraeror - 01.10.2017, 13:48
Re: Simple help - by jlalt - 01.10.2017, 14:00
Re: Simple help - by Kraeror - 01.10.2017, 14:02
Re: Simple help - by jlalt - 01.10.2017, 14:03
Re: Simple help - by Kraeror - 01.10.2017, 14:38
Re: Simple help - by jlalt - 01.10.2017, 15:27

Forum Jump:


Users browsing this thread: 1 Guest(s)