dcmd command :)
#10

This should work for you, hopefully :/

pawn Код:
dcmd_house(playerid, params[])
{
    new text[48], novac;// novac = money
    if(sscanf(params, "s[48]I(0)", text, novac)) return SendClientMessage(playerid, WHITE, "HELP: /house (info [ ] | lock [ ] | takemoney [value] | putmoney [value])");
    if(strcmp(text, "info", true) == 0) // apartment info.
    {
        new bool:inrange = false;
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            if(!IsPlayerInRangeOfPoint(playerid, 10.0, ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz])) continue;
            if(strcmp(ApartmentInfo[i][sOwner], plname, false) != 0) continue;
            new string[30];
            SendClientMessage(playerid, YELLOW, "|========================================|");
            if(ApartmentInfo[i][sLocked] == 1) SendClientMessage(playerid, WHITE, "Locked: Yes");
            else if(ApartmentInfo[i][sLocked] == 0) SendClientMessage(playerid, WHITE, "Locked: No");
            format(string, sizeof(string), "Money in safe: $%d", ApartmentInfo[i][sMoney]);
            SendClientMessage(playerid, WHITE, string);
            format(string, sizeof(string), "House Price: $%d", ApartmentInfo[i][sPrice]);
            SendClientMessage(playerid, WHITE, string);
            SendClientMessage(playerid, YELLOW, "|========================================|");
            inrange = true;
            break;
        }
        if(!inrange) return SendClientMessage(playerid, WHITE, "You are not in range of your apartment."); //Change this however you like.
        return 1;
    }
    if(strcmp(text, "lock", true) == 0) // lock/unlock apartment
    {
        new bool:inrange = false;
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 3.0, ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]))
            {
                if(InApartment[playerid] != 501) continue;
                GetPlayerName(playerid, plname, sizeof(plname));
                if(strcmp(ApartmentInfo[i][sOwner], plname, false) != 0) return SendClientMessage(playerid, WHITE, "You are not the owner of this apartment.");
                inrange = true;
                if(ApartmentInfo[i][sLocked] == 1)
                {
                    GameTextForPlayer(playerid, "~g~Unlocked", 5000, 6);
                    ApartmentInfo[i][sLocked] = 0;
                    break;
                }
                else if(ApartmentInfo[i][sLocked] == 0)
                {
                    GameTextForPlayer(playerid, "~r~Locked", 5000, 6);
                    ApartmentInfo[i][sLocked] = 1;
                    break;
                }
            }
            else if(IsPlayerInRangeOfPoint(playerid, 25, ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]))
            {
                if(!IsPlayerInRangeOfPoint(playerid, 3, ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz])) return SendClientMessage(playerid, WHITE, "You are not in front of the doors.");
                if(InApartment[playerid] == 501) continue;
                GetPlayerName(playerid, plname, sizeof(plname));
                if(strcmp(ApartmentInfo[i][sOwner], plname, false) != 0) return SendClientMessage(playerid, WHITE, "You are not the owner of this apartment.");
                inrange = true;
                if(ApartmentInfo[i][sLocked] == 1)
                {
                    GameTextForPlayer(playerid, "~g~Unlocked", 5000, 6);
                    ApartmentInfo[i][sLocked] = 0;
                    break;
                }
                else if(ApartmentInfo[i][sLocked] == 0)
                {
                    GameTextForPlayer(playerid, "~r~Locked", 5000, 6);
                    ApartmentInfo[i][sLocked] = 1;
                    break;
                }
            }
        }
        if(!inrange) return SendClientMessage(playerid, WHITE, "You are not in range of your apartment."); //Change this however you like.
        return 1;
    }
    else if(strcmp(text, "putmoney", true) == 0) // taking money from safe
    {
        if(novac < 1) return SendClientMessage(playerid, WHITE, "HELP: /house putmoney [value]");
        new bool:inrange = false;
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            if(!IsPlayerInRangeOfPoint(playerid, 10.0, ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz])) continue;
            GetPlayerName(playerid, plname, sizeof(plname));
            if(strcmp(ApartmentInfo[i][sOwner], plname, false) != 0) return SendClientMessage(playerid, WHITE, "You are not the owner of this apartment.");
            if(GetPlayerVirtualWorld(playerid) != ApartmentInfo[i][sWorld]) continue;
            if(GetPlayerMoney(playerid) < novac) return SendClientMessage(playerid, GREY, "You don't have enough money!");
            ApartmentInfo[i][sMoney] += novac;
            GivePlayerMoney(playerid, -novac);
            new string[65];
            format(string, sizeof(string), "You have put $%d in the safe, now you have: $%d", novac, ApartmentInfo[i][sMoney]);
            SendClientMessage(playerid, YELLOW, string);
            SaveApartment(i);
            inrange = true;
            break;
        }
        if(!inrange) return SendClientMessage(playerid, WHITE, "You are not in range of your apartment."); //Change this however you like.
        return 1;
    }
    else if(strcmp(text, "takemoney", true) == 0) // puting money in safe
    {
        if(novac < 1) return SendClientMessage(playerid, WHITE, "HELP: /house takemoney [value]");
        new bool:inrange = false;
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            if(!IsPlayerInRangeOfPoint(playerid, 10.0, ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz])) continue;
            GetPlayerName(playerid, plname, sizeof(plname));
            if(strcmp(ApartmentInfo[i][sOwner], plname, false) != 0) return SendClientMessage(playerid, WHITE, "You are not the owner of this apartment.");
            if(GetPlayerVirtualWorld(playerid) != ApartmentInfo[i][sWorld]) continue;
            if(ApartmentInfo[i][sMoney] < novac) return SendClientMessage(playerid, GREY, "You don't have enough money!");
            ApartmentInfo[i][sMoney] -= novac;
            GivePlayerMoney(playerid, novac);
            new string[70];
            format(string, sizeof(string), "You have taken $%d from the safe, now you have: $%d", novac, ApartmentInfo[i][sMoney]);
            SendClientMessage(playerid, YELLOW, string);
            SaveApartment(i);
            inrange = true;
            break;
        }
        if(!inrange) return SendClientMessage(playerid, WHITE, "You are not in range of your apartment."); //Change this however you like.
        return 1;
    }
    else return SendClientMessage(playerid, WHITE, "HELP: /house (info [ ] | lock [ ] | takemoney [value] | putmoney [value])");
}
Reply


Messages In This Thread
dcmd command :) - by kubeba59 - 11.01.2014, 17:04
Re: dcmd command :) - by dominik523 - 11.01.2014, 17:22
Re: dcmd command :) - by kubeba59 - 11.01.2014, 17:32
Re: dcmd command :) - by ViciousRoleplay123 - 11.01.2014, 17:39
Re: dcmd command :) - by kubeba59 - 11.01.2014, 17:45
Re: dcmd command :) - by kubeba59 - 12.01.2014, 08:01
Re: dcmd command :) - by kubeba59 - 13.01.2014, 17:28
Re: dcmd command :) - by ConnorHunter - 13.01.2014, 18:13
Re: dcmd command :) - by kubeba59 - 16.01.2014, 06:03
Re: dcmd command :) - by Threshold - 16.01.2014, 07:28

Forum Jump:


Users browsing this thread: 5 Guest(s)