sscanf & zcmd help..! sscanf inside strcmp
#1

I made this command, when i do /myhouse cash [withdraw/deposit]
it doesn't work.

pawn Код:
CMD:myhouse(playerid, params[])
{
    new option[7], secoption[128], str[128],pName[MAX_PLAYER_NAME];
    new house = PlayerInfo[playerid][pHouseKey];
    GetPlayerName(playerid, pName, sizeof(pName));
    if (house != -1 && strcmp(pName, HouseInfo[PlayerInfo[playerid][pHouseKey]][hOwner], true) == 0)
    {
        if(sscanf(params, "s[7]S(NULL)[128]", option, secoption)) return SyntaxMSG(playerid, "/myhouse [info/cash]");
        if(!strcmp(option, "info", true))
        {
            format(str, sizeof(str), "House Info: Market Price - $%d, Level - %d, Rent Price - $%d.", HouseInfo[house][hPrice], HouseInfo[house][hLevelbuy], HouseInfo[house][hRentprice]);
            HouseMSG(playerid, str);
        }
        else if(!strcmp(option, "cash", true))
        {
            new choise[11], thirdoption[128], amount;
            if(sscanf(params, "{s[7]}s[11]S(NULL)[128]", choise, thirdoption))
            {
                SyntaxMSG(playerid, "/myhouse cash [withdraw/deposit]");
                format(str, sizeof(str), "You have $%d in your cashbox.", HouseInfo[house][hCash]);
                HouseMSG(playerid, str);
                return 1;
            }
            if(!strcmp(choise, "withdraw", true))
            {
                if(sscanf(params, "{s[7]}d", amount)) return SyntaxMSG(playerid, "/myhouse cash withdraw [amount]");
                if (amount > HouseInfo[house][hCash] || amount < 1)
                {
                    HouseMSG(playerid, "You dont have that much!");
                    return 1;
                }
                if (!PlayerToPoint(100, playerid,HouseInfo[house][hExitX],HouseInfo[house][hExitY],HouseInfo[house][hExitZ])) return HouseMSG(playerid, "You must be inside the house.");
                GiveCash(playerid, amount);
                HouseInfo[house][hCash] -= amount;
                format(str, sizeof(str), "You have withdrawn $%d from your cashbox Total: $%d ", amount,HouseInfo[house][hCash]);
                HouseMSG(playerid, str);
                UpdateHouseInfo(house);
            }
            else if(!strcmp(choise, "deposit", true))
            {
                if(sscanf(params, "{s[7]}d", amount)) return SyntaxMSG(playerid, "/myhouse cash withdraw [amount]");
                if (amount >  GetCash(playerid) || amount < 1)
                {
                    HouseMSG(playerid, "You dont have that much!");
                    return 1;
                }
                if (!PlayerToPoint(100, playerid,HouseInfo[house][hExitX],HouseInfo[house][hExitY],HouseInfo[house][hExitZ])) return HouseMSG(playerid, "You must be inside the house.");
                GiveCash(playerid, -amount);
                HouseInfo[house][hCash] += amount;
                format(str, sizeof(str), "You have placed $%d in your cashbox Total: $%d ", amount,HouseInfo[house][hCash]);
                HouseMSG(playerid, str);
                UpdateHouseInfo(house);
            }
        }
    }
    else
    {
        HouseMSG(playerid, "You don't own a house.");
    }
    return 1;
}
Reply
#2

help plox
Reply
#3

Never mind fixed up ....

Код HTML:
CMD:myhouse(playerid, params[])
{
    new option[7], secoption[128], thirdoption, str[128],pName[MAX_PLAYER_NAME];
	new house = PlayerInfo[playerid][pHouseKey];
	GetPlayerName(playerid, pName, sizeof(pName));
	if (house != -1 && strcmp(pName, HouseInfo[PlayerInfo[playerid][pHouseKey]][hOwner], true) == 0)
	{
		if(sscanf(params, "s[7]S(NULL)[128]D(-1)", option, secoption, thirdoption)) return SyntaxMSG(playerid, "/myhouse [info/cash]");
		if(!strcmp(option, "info", true))
		{
			format(str, sizeof(str), "House Info: Market Price - $%d, Level - %d, Rent Price - $%d.", HouseInfo[house][hPrice], HouseInfo[house][hLevelbuy], HouseInfo[house][hRentprice]);
			HouseMSG(playerid, str);
		}
		else if(!strcmp(option, "cash", true)) 
		{
			new choise[11], amount;
			if(sscanf(params, "{s[7]}s[11]d", choise, amount))
			{
				SyntaxMSG(playerid, "/myhouse cash [withdraw/deposit] [amount]");
				format(str, sizeof(str), "You have $%d in your cashbox.", HouseInfo[house][hCash]);
				HouseMSG(playerid, str);
				return 1;
			}
			if(!strcmp(choise, "withdraw", true)) 
			{
				if (!PlayerToPoint(100, playerid,HouseInfo[house][hExitX],HouseInfo[house][hExitY],HouseInfo[house][hExitZ])) return HouseMSG(playerid, "You must be inside the house.");
				if (amount > HouseInfo[house][hCash] || amount < 1)
				{
					HouseMSG(playerid, "You dont have that much!");
					return 1;
				}
				GiveCash(playerid, amount);
				HouseInfo[house][hCash] -= amount;
				format(str, sizeof(str), "You have withdrawn $%d from your cashbox Total: $%d ", amount,HouseInfo[house][hCash]);
				HouseMSG(playerid, str);
				UpdateHouseInfo(house);
			}
			else if(!strcmp(choise, "deposit", true)) 
			{
				if (!PlayerToPoint(100, playerid,HouseInfo[house][hExitX],HouseInfo[house][hExitY],HouseInfo[house][hExitZ])) return HouseMSG(playerid, "You must be inside the house.");
				if (amount >  GetCash(playerid) || amount < 1)
				{
					HouseMSG(playerid, "You dont have that much!");
					return 1;
				}
				GiveCash(playerid, -amount);
				HouseInfo[house][hCash] += amount;
				format(str, sizeof(str), "You have placed $%d in your cashbox Total: $%d ", amount,HouseInfo[house][hCash]);
				HouseMSG(playerid, str);
				UpdateHouseInfo(house);
			}
		}
	}
	else
	{
		HouseMSG(playerid, "You don't own a house.");
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)