Using DCMD
#1

How would I be able to make this in DCMD?

Код:
dcmd_house(playerid, params[])
{
    new tmp[32];
    new string[128];
    new house = PlayerInfo[playerid][pHouseKey];
    if(PlayerInfo[playerid][pHouseKey] != INVALID_HOUSE_ID)
    {
        if(sscanf(params, "s[32]", tmp))
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /house [name]");
            SendClientMessage(playerid, COLOR_GREY, "Available: Lock, Name");
            return 1;
        }
        
        if(strcmp(tmp,"lock",true) == 0)
        {
            if(IsPlayerInRangeOfPoint(playerid, 2.0, HouseInfo[house][hEntrancex], HouseInfo[house][hEntrancey], HouseInfo[house][hEntrancez]) || IsPlayerInRangeOfPoint(playerid, 2.0, HouseInfo[house][hExitx], HouseInfo[house][hExity], HouseInfo[house][hExitz]))
            {
                if(HouseInfo[house][hLock] == 0)
                {
					HouseInfo[house][hLock] = 1;
					PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
					format(string, sizeof(string), "* %s has locked the door to their house.", GetPlayerNameEx(playerid));
					SaveStaticHouse(house);
					ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                }
                else
                {
					HouseInfo[house][hLock] = 0;
				   	PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
					format(string, sizeof(string), "* %s has unlocked the door to their house.", GetPlayerNameEx(playerid));
					ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "You need to be near your house in order to use this feature.");
            }
        }
        if(strcmp(tmp,"name",true) == 0)
        {
            if(sscanf(params, "s[32]", result)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /house name [name]");
            if(strlen(tmp) > 10) return SendClientMessage(playerid, COLOR_GREY, "The name that you've chosen for your house is to long.");
			strmid(HouseInfo[house][hDescription], tmp, 0, strlen(tmp), 255);
			SaveStaticHouse(house);
			LoadStaticHouse(house);
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, "You need a house in order to use this feature.");
    }
    return 1;
}
I want to make it so when you use /house name [input] so the input will be the name, this worked perfectly with strtok, but I want to transfer all strtok based commands to dcmd and afterwards to CMD. Any solution?
Reply
#2

Check out the sscanf thread for additional information regarding multiple parameters- it's the best option for you.

As for your commend about changing to DCMD then to CMD, (by CMD, I'm assuming you mean ZCMD), that is stupid. Just include ZCMD and use the ZCMD syntax (CMD:commandname(playerid, params)). There is no reason to use DCMD first.
Reply
#3

I've got about 200 commands with strtok and 20 with DCMD, ZCMD limits me from using strtok based commands while DCMD doesn't. (OnPlayerCommand)
P.S: Nothing has been listed on the Sscanf2 thread about multiple params..
Reply
#4

I guess I didn't use the direct terminology, look into using specifiers for sscanf.

As for the commands, are you working with an edit?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)