(DCMD) Make one command do several things problem
#1

Fixed, see http://forum.sa-mp.com/index.php?top...5653#msg605653
Reply
#2

Try this? http://pastebin.com/m45f86e17
Reply
#3

Quote:
Originally Posted by backwardsman97
I've already tried that before posting, this way it doesn't work at all.
Reply
#4

pawn Код:
new
text[128],string[128];
They are created but empty.
Use 'strtok'.
pawn Код:
new
  text[128], string[128], idx;
text = strtok(params, idx);
string = strtok(params, idx);
STRTOK Function:
pawn Код:
stock strtok(const string[], &index, seperator=' ')
{
  new length = strlen(string);
  new offset = index;
  new result[127];
  while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
  {
    result[index - offset] = string[index];
    index++;
  }

  result[index - offset] = EOS;
  if ((index < length) && (string[index] == seperator))
  {
    index++;
  }
  return result;
}
Reply
#5

pawn Код:
dcmd_house(playerid, params[])
{
    if(Account[playerid][pAdminLvl] <= 20)
        return AdministratorError(playerid,20);
       
    new string[128];
   
    if (params[0]=='\0')
        return SendClientMessage(playerid, COLOR_WHITE, "SERVER: /house [add | delete]");
   
    else if(!strcmp(params, "add", true, 3))
    {
        new Float:X,Float:Y,Float:Z,Interior,World,Float:Angle,houseid;
        GetPlayerPos(playerid,X,Y,Z);
        World=GetPlayerVirtualWorld(playerid);
        Interior=GetPlayerInterior(playerid);
        GetPlayerFacingAngle(playerid,Angle);
        houseid=AddHouse("None",X,Y,Z,World,Interior,Angle,0.0,0.0,0.0,0,0.0,0,0,0,99999999,1);
        format(string,sizeof(string),"INFO: House id %d successfully created, there are now %d houses in the server.",houseid,HOUSE_COUNT);
        return SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
    }
   
    else if(!strcmp(params, "delete", true, 6 ))
    {
        new houseid;
        if (params[6]=='\0' || sscanf(params[7], "d", houseid))
            return SendClientMessage(playerid, COLOR_WHITE, "SERVER: /house [delete] [houseid]");
           
        format(string,sizeof(string),"INFO: House ID %d.",houseid);
        SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
        if(dini_Exists(GetHouse(houseid)))
        {
            DeleteHouse(houseid);
            format(string,sizeof(string),"INFO: House id %d successfully deleted, there are now %d houses in the server.",houseid,HOUSE_COUNT);
            return SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
        }
        else
        {
            format(string,sizeof(string),"INFO: House id %d does not exist!.",houseid);
            return SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
        }
    }
    return 0;
}
Reply
#6

Quote:
Originally Posted by SharkyKH
pawn Код:
new
text[128],string[128];
They are created but empty.
Use 'strtok'.
pawn Код:
new
  text[128], string[128], idx;
text = strtok(params, idx);
string = strtok(params, idx);
STRTOK Function:
pawn Код:
stock strtok(const string[], &index, seperator=' ')
{
  new length = strlen(string);
  new offset = index;
  new result[127];
  while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
  {
    result[index - offset] = string[index];
    index++;
  }

  result[index - offset] = EOS;
  if ((index < length) && (string[index] == seperator))
  {
    index++;
  }
  return result;
}
The whole point in using dcmd is so i don't have to use strtok and pen_†ĥęGun it works perfectly, thanks.

And no they aren't Sharky, the strings are formatting just fine.
Reply
#7

You shouldn't replace your post with fix. Then the search function is pointless and people with a similar problem have to make a new thread because they can't see ones like these.
Reply
#8

Quote:
Originally Posted by backwardsman97
You shouldn't replace your post with fix. Then the search function is pointless and people with a similar problem have to make a new thread because they can't see ones like these.
It's fixed in post three, they don't need to see the original.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)