06.01.2012, 11:01
How would I be able to make this in DCMD?
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?
Код:
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;
}


