dcmd command :)
#1

Hey guys

I am using this command for a house system:
pawn Код:
dcmd_house(playerid, params[])
{
    new text[48]; new novac;// novac = money
    if(sscanf(params, "s[48]i",text , novac))
    {
        SendClientMessage(playerid, WHITE, "HELP: /house info [ ] | lock [ ] | takemoney [value] | putmoney [value]");
        return 1;
    }
    if(strcmp(text,"info",true) == 0) // apartment info.
    {
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            new string[500];
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
            {
                SendClientMessage(playerid, YELLOW, "|========================================|");
                if(ApartmentInfo[i][sLocked] == 1)
                {
                    SendClientMessage(playerid, WHITE, "Locked: Yes");
                }
                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, "|========================================|");
                return 1;
            }
        }
        return 1;
    }
    if(strcmp(text,"lock",true) == 0) // lock/unlock apartment
    {
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]) && InApartment[playerid] == 501)
            {
                GetPlayerName(playerid, plname, sizeof(plname));
                if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
                {
                    if(ApartmentInfo[i][sLocked] == 1)
                    {
                        GameTextForPlayer(playerid, "~g~Unlocked", 5000, 6);
                        ApartmentInfo[i][sLocked] = 0;
                        return 1;
                    }
                    if(ApartmentInfo[i][sLocked] == 0)
                    {
                        GameTextForPlayer(playerid, "~r~Locked", 5000, 6);
                        ApartmentInfo[i][sLocked] = 1;
                        return 1;
                    }
                }
            }
            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]) && InApartment[playerid] != 501)
                {
                    GetPlayerName(playerid, plname, sizeof(plname));
                    if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
                    {
                        if(ApartmentInfo[i][sLocked] == 1)
                        {
                            GameTextForPlayer(playerid, "~g~Unlocked", 5000, 6);
                            ApartmentInfo[i][sLocked] = 0;
                            return 1;
                        }
                        if(ApartmentInfo[i][sLocked] == 0)
                        {
                            GameTextForPlayer(playerid, "~r~Locked", 5000, 6);
                            ApartmentInfo[i][sLocked] = 1;
                            return 1;
                        }
                    }
                }
                else { SendClientMessage(playerid, WHITE,"You are not in front of doors."); return 1; }
            }
        }
        return 1;
    }
    if(strcmp(text,"putmoney",true) == 0) // taking money from safe
    {
        new string[128];
        if(novac < 0) { return 1; }
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            GetPlayerName(playerid, plname, sizeof(plname));
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0 && GetPlayerVirtualWorld(playerid) == ApartmentInfo[i][sWorld])
            {
                if(GetPlayerMoney(playerid) >= novac)
                {
                    ApartmentInfo[i][sMoney] += novac;
                    GivePlayerMoney(playerid,-novac);
                    format(string, sizeof(string), "You have put %d $ in safe, now you have: %d", novac, ApartmentInfo[i][sMoney]);
                    SendClientMessage(playerid, YELLOW, string);
                    SaveApartment(i);
                    return 1;
                }
                else { SendClientMessage(playerid,GREY,"You don't have enoguht money!"); return 1; }
            }
        }
        return 1;
    }
    if(strcmp(text,"takemoney",true) == 0) // puting money in safe
    {
        new string[128];
        if(novac < 0) { return 1; }
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            GetPlayerName(playerid, plname, sizeof(plname));
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0 && GetPlayerVirtualWorld(playerid) == ApartmentInfo[i][sWorld])
            {
                if(ApartmentInfo[i][sMoney] >= novac)
                {
                    ApartmentInfo[i][sMoney] -= novac;
                    GivePlayerMoney(playerid,novac);
                    format(string, sizeof(string), "You have take %d $ from safe, now you have: %d $", novac, ApartmentInfo[i][sMoney]);
                    SendClientMessage(playerid, YELLOW, string);
                    SaveApartment(i);
                    return 1;
                }
                else { SendClientMessage(playerid,GREY,"You don't have enoguht money!"); return 1; }
            }
        }
        return 1;
    }
    return 1;
}
The problem is when I type the "/house info" or "/house lock" it shows me what is the right form to write the command: (HELP: /house info [ ] | lock [ ] | takemoney [value] | putmoney [value])

Can someone help me plz ?
Reply
#2

Try this:
pawn Код:
dcmd_house(playerid, params[])
{
    new text[48]; new novac;// novac = money
    if(sscanf(params, "s[48]",text))
    {
        SendClientMessage(playerid, WHITE, "HELP: /house info [ ] | lock [ ] | takemoney [value] | putmoney [value]");
        return 1;
    }
    if(strcmp(text,"info",true) == 0) // apartment info.
    {
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            new string[500];
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
            {
                SendClientMessage(playerid, YELLOW, "|========================================|");
                if(ApartmentInfo[i][sLocked] == 1)
                {
                    SendClientMessage(playerid, WHITE, "Locked: Yes");
                }
                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, "|========================================|");
                return 1;
            }
        }
        return 1;
    }
    if(strcmp(text,"lock",true) == 0) // lock/unlock apartment
    {
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]) && InApartment[playerid] == 501)
            {
                GetPlayerName(playerid, plname, sizeof(plname));
                if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
                {
                    if(ApartmentInfo[i][sLocked] == 1)
                    {
                        GameTextForPlayer(playerid, "~g~Unlocked", 5000, 6);
                        ApartmentInfo[i][sLocked] = 0;
                        return 1;
                    }
                    if(ApartmentInfo[i][sLocked] == 0)
                    {
                        GameTextForPlayer(playerid, "~r~Locked", 5000, 6);
                        ApartmentInfo[i][sLocked] = 1;
                        return 1;
                    }
                }
            }
            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]) && InApartment[playerid] != 501)
                {
                    GetPlayerName(playerid, plname, sizeof(plname));
                    if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
                    {
                        if(ApartmentInfo[i][sLocked] == 1)
                        {
                            GameTextForPlayer(playerid, "~g~Unlocked", 5000, 6);
                            ApartmentInfo[i][sLocked] = 0;
                            return 1;
                        }
                        if(ApartmentInfo[i][sLocked] == 0)
                        {
                            GameTextForPlayer(playerid, "~r~Locked", 5000, 6);
                            ApartmentInfo[i][sLocked] = 1;
                            return 1;
                        }
                    }
                }
                else { SendClientMessage(playerid, WHITE,"You are not in front of doors."); return 1; }
            }
        }
        return 1;
    }
    if(strcmp(text,"putmoney",true) == 0) // taking money from safe
    {
        if(sscanf(params, "s[48]i",text , novac)) return SendClientMessage(playerid, -1, "HELP: ...");
        new string[128];
        if(novac < 0) { return 1; }
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            GetPlayerName(playerid, plname, sizeof(plname));
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0 && GetPlayerVirtualWorld(playerid) == ApartmentInfo[i][sWorld])
            {
                if(GetPlayerMoney(playerid) >= novac)
                {
                    ApartmentInfo[i][sMoney] += novac;
                    GivePlayerMoney(playerid,-novac);
                    format(string, sizeof(string), "You have put %d $ in safe, now you have: %d", novac, ApartmentInfo[i][sMoney]);
                    SendClientMessage(playerid, YELLOW, string);
                    SaveApartment(i);
                    return 1;
                }
                else { SendClientMessage(playerid,GREY,"You don't have enoguht money!"); return 1; }
            }
        }
        return 1;
    }
    if(strcmp(text,"takemoney",true) == 0) // puting money in safe
    {
        if(sscanf(params, "s[48]i",text , novac)) return SendClientMessage(playerid, -1, "HELP: ...");
        new string[128];
        if(novac < 0) { return 1; }
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            GetPlayerName(playerid, plname, sizeof(plname));
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0 && GetPlayerVirtualWorld(playerid) == ApartmentInfo[i][sWorld])
            {
                if(ApartmentInfo[i][sMoney] >= novac)
                {
                    ApartmentInfo[i][sMoney] -= novac;
                    GivePlayerMoney(playerid,novac);
                    format(string, sizeof(string), "You have take %d $ from safe, now you have: %d $", novac, ApartmentInfo[i][sMoney]);
                    SendClientMessage(playerid, YELLOW, string);
                    SaveApartment(i);
                    return 1;
                }
                else { SendClientMessage(playerid,GREY,"You don't have enoguht money!"); return 1; }
            }
        }
        return 1;
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by dominik523
Посмотреть сообщение
Try this:
pawn Код:
dcmd_house(playerid, params[])
{
    new text[48]; new novac;// novac = money
    if(sscanf(params, "s[48]",text))
    {
        SendClientMessage(playerid, WHITE, "HELP: /house info [ ] | lock [ ] | takemoney [value] | putmoney [value]");
        return 1;
    }
    if(strcmp(text,"info",true) == 0) // apartment info.
    {
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            new string[500];
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
            {
                SendClientMessage(playerid, YELLOW, "|========================================|");
                if(ApartmentInfo[i][sLocked] == 1)
                {
                    SendClientMessage(playerid, WHITE, "Locked: Yes");
                }
                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, "|========================================|");
                return 1;
            }
        }
        return 1;
    }
    if(strcmp(text,"lock",true) == 0) // lock/unlock apartment
    {
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]) && InApartment[playerid] == 501)
            {
                GetPlayerName(playerid, plname, sizeof(plname));
                if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
                {
                    if(ApartmentInfo[i][sLocked] == 1)
                    {
                        GameTextForPlayer(playerid, "~g~Unlocked", 5000, 6);
                        ApartmentInfo[i][sLocked] = 0;
                        return 1;
                    }
                    if(ApartmentInfo[i][sLocked] == 0)
                    {
                        GameTextForPlayer(playerid, "~r~Locked", 5000, 6);
                        ApartmentInfo[i][sLocked] = 1;
                        return 1;
                    }
                }
            }
            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]) && InApartment[playerid] != 501)
                {
                    GetPlayerName(playerid, plname, sizeof(plname));
                    if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
                    {
                        if(ApartmentInfo[i][sLocked] == 1)
                        {
                            GameTextForPlayer(playerid, "~g~Unlocked", 5000, 6);
                            ApartmentInfo[i][sLocked] = 0;
                            return 1;
                        }
                        if(ApartmentInfo[i][sLocked] == 0)
                        {
                            GameTextForPlayer(playerid, "~r~Locked", 5000, 6);
                            ApartmentInfo[i][sLocked] = 1;
                            return 1;
                        }
                    }
                }
                else { SendClientMessage(playerid, WHITE,"You are not in front of doors."); return 1; }
            }
        }
        return 1;
    }
    if(strcmp(text,"putmoney",true) == 0) // taking money from safe
    {
        if(sscanf(params, "s[48]i",text , novac)) return SendClientMessage(playerid, -1, "HELP: ...");
        new string[128];
        if(novac < 0) { return 1; }
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            GetPlayerName(playerid, plname, sizeof(plname));
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0 && GetPlayerVirtualWorld(playerid) == ApartmentInfo[i][sWorld])
            {
                if(GetPlayerMoney(playerid) >= novac)
                {
                    ApartmentInfo[i][sMoney] += novac;
                    GivePlayerMoney(playerid,-novac);
                    format(string, sizeof(string), "You have put %d $ in safe, now you have: %d", novac, ApartmentInfo[i][sMoney]);
                    SendClientMessage(playerid, YELLOW, string);
                    SaveApartment(i);
                    return 1;
                }
                else { SendClientMessage(playerid,GREY,"You don't have enoguht money!"); return 1; }
            }
        }
        return 1;
    }
    if(strcmp(text,"takemoney",true) == 0) // puting money in safe
    {
        if(sscanf(params, "s[48]i",text , novac)) return SendClientMessage(playerid, -1, "HELP: ...");
        new string[128];
        if(novac < 0) { return 1; }
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            GetPlayerName(playerid, plname, sizeof(plname));
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0 && GetPlayerVirtualWorld(playerid) == ApartmentInfo[i][sWorld])
            {
                if(ApartmentInfo[i][sMoney] >= novac)
                {
                    ApartmentInfo[i][sMoney] -= novac;
                    GivePlayerMoney(playerid,novac);
                    format(string, sizeof(string), "You have take %d $ from safe, now you have: %d $", novac, ApartmentInfo[i][sMoney]);
                    SendClientMessage(playerid, YELLOW, string);
                    SaveApartment(i);
                    return 1;
                }
                else { SendClientMessage(playerid,GREY,"You don't have enoguht money!"); return 1; }
            }
        }
        return 1;
    }
    return 1;
}
Now when I type the command it doesn't respone..
Reply
#4

correct if wrong but why u return 2 times at the end?
Reply
#5

Quote:
Originally Posted by ViciousRoleplay123
Посмотреть сообщение
correct if wrong but why u return 2 times at the end?
Because the command have to return..
Reply
#6

UP...
Reply
#7

UP..
Reply
#8

pawn Код:
dcmd_house(playerid, params[])
{
    new text[48]; new novac;// novac = money
    if(sscanf(params, "s",text)) // You already made the variable amount as 48
    {
        SendClientMessage(playerid, WHITE, "HELP: /house info [ ] | lock [ ] | takemoney [value] | putmoney [value]");
        return 1;
    }
    if(strcmp(text,"info",true) == 0) // apartment info.
    {
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            new string[500];
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
            {
                SendClientMessage(playerid, YELLOW, "|========================================|");
                if(ApartmentInfo[i][sLocked] == 1)
                {
                    SendClientMessage(playerid, WHITE, "Locked: Yes");
                }
                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, "|========================================|");
                return 1;
            }
        }
    }
    if(strcmp(text,"lock",true) == 0) // lock/unlock apartment
    {
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]) && InApartment[playerid] == 501)
            {
                GetPlayerName(playerid, plname, sizeof(plname));
                if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
                {
                    if(ApartmentInfo[i][sLocked] == 1)
                    {
                        GameTextForPlayer(playerid, "~g~Unlocked", 5000, 6);
                        ApartmentInfo[i][sLocked] = 0;
                        return 1;
                    }
                    if(ApartmentInfo[i][sLocked] == 0)
                    {
                        GameTextForPlayer(playerid, "~r~Locked", 5000, 6);
                        ApartmentInfo[i][sLocked] = 1;
                        return 1;
                    }
                }
            }
            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]) && InApartment[playerid] != 501)
                {
                    GetPlayerName(playerid, plname, sizeof(plname));
                    if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
                    {
                        if(ApartmentInfo[i][sLocked] == 1)
                        {
                            GameTextForPlayer(playerid, "~g~Unlocked", 5000, 6);
                            ApartmentInfo[i][sLocked] = 0;
                            return 1;
                        }
                        if(ApartmentInfo[i][sLocked] == 0)
                        {
                            GameTextForPlayer(playerid, "~r~Locked", 5000, 6);
                            ApartmentInfo[i][sLocked] = 1;
                            return 1;
                        }
                    }
                }
                else { SendClientMessage(playerid, WHITE,"You are not in front of doors."); return 1; }
            }
        }
    }
    if(strcmp(text,"putmoney",true) == 0) // taking money from safe
    {
        if(sscanf(params, "s[48]i",text , novac)) return SendClientMessage(playerid, -1, "HELP: ...");
        new string[128];
        if(novac < 0) { return 1; }
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            GetPlayerName(playerid, plname, sizeof(plname));
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0 && GetPlayerVirtualWorld(playerid) == ApartmentInfo[i][sWorld])
            {
                if(GetPlayerMoney(playerid) >= novac)
                {
                    ApartmentInfo[i][sMoney] += novac;
                    GivePlayerMoney(playerid,-novac);
                    format(string, sizeof(string), "You have put %d $ in safe, now you have: %d", novac, ApartmentInfo[i][sMoney]);
                    SendClientMessage(playerid, YELLOW, string);
                    SaveApartment(i);
                    return 1;
                }
                else { SendClientMessage(playerid,GREY,"You don't have enoguht money!"); return 1; }
            }
        }
    }
    if(strcmp(text,"takemoney",true) == 0) // puting money in safe
    {
        if(sscanf(params, "s[48]i",text , novac)) return SendClientMessage(playerid, -1, "HELP: ...");
        new string[128];
        if(novac < 0) { return 1; }
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            GetPlayerName(playerid, plname, sizeof(plname));
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0 && GetPlayerVirtualWorld(playerid) == ApartmentInfo[i][sWorld])
            {
                if(ApartmentInfo[i][sMoney] >= novac)
                {
                    ApartmentInfo[i][sMoney] -= novac;
                    GivePlayerMoney(playerid,novac);
                    format(string, sizeof(string), "You have take %d $ from safe, now you have: %d $", novac, ApartmentInfo[i][sMoney]);
                    SendClientMessage(playerid, YELLOW, string);
                    SaveApartment(i);
                    return 1;
                }
                else { SendClientMessage(playerid,GREY,"You don't have enoguht money!"); return 1; }
            }
        }
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by ConnorHunter
Посмотреть сообщение
pawn Код:
dcmd_house(playerid, params[])
{
    new text[48]; new novac;// novac = money
    if(sscanf(params, "s",text)) // You already made the variable amount as 48
    {
        SendClientMessage(playerid, WHITE, "HELP: /house info [ ] | lock [ ] | takemoney [value] | putmoney [value]");
        return 1;
    }
    if(strcmp(text,"info",true) == 0) // apartment info.
    {
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            new string[500];
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
            {
                SendClientMessage(playerid, YELLOW, "|========================================|");
                if(ApartmentInfo[i][sLocked] == 1)
                {
                    SendClientMessage(playerid, WHITE, "Locked: Yes");
                }
                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, "|========================================|");
                return 1;
            }
        }
    }
    if(strcmp(text,"lock",true) == 0) // lock/unlock apartment
    {
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]) && InApartment[playerid] == 501)
            {
                GetPlayerName(playerid, plname, sizeof(plname));
                if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
                {
                    if(ApartmentInfo[i][sLocked] == 1)
                    {
                        GameTextForPlayer(playerid, "~g~Unlocked", 5000, 6);
                        ApartmentInfo[i][sLocked] = 0;
                        return 1;
                    }
                    if(ApartmentInfo[i][sLocked] == 0)
                    {
                        GameTextForPlayer(playerid, "~r~Locked", 5000, 6);
                        ApartmentInfo[i][sLocked] = 1;
                        return 1;
                    }
                }
            }
            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]) && InApartment[playerid] != 501)
                {
                    GetPlayerName(playerid, plname, sizeof(plname));
                    if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
                    {
                        if(ApartmentInfo[i][sLocked] == 1)
                        {
                            GameTextForPlayer(playerid, "~g~Unlocked", 5000, 6);
                            ApartmentInfo[i][sLocked] = 0;
                            return 1;
                        }
                        if(ApartmentInfo[i][sLocked] == 0)
                        {
                            GameTextForPlayer(playerid, "~r~Locked", 5000, 6);
                            ApartmentInfo[i][sLocked] = 1;
                            return 1;
                        }
                    }
                }
                else { SendClientMessage(playerid, WHITE,"You are not in front of doors."); return 1; }
            }
        }
    }
    if(strcmp(text,"putmoney",true) == 0) // taking money from safe
    {
        if(sscanf(params, "s[48]i",text , novac)) return SendClientMessage(playerid, -1, "HELP: ...");
        new string[128];
        if(novac < 0) { return 1; }
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            GetPlayerName(playerid, plname, sizeof(plname));
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0 && GetPlayerVirtualWorld(playerid) == ApartmentInfo[i][sWorld])
            {
                if(GetPlayerMoney(playerid) >= novac)
                {
                    ApartmentInfo[i][sMoney] += novac;
                    GivePlayerMoney(playerid,-novac);
                    format(string, sizeof(string), "You have put %d $ in safe, now you have: %d", novac, ApartmentInfo[i][sMoney]);
                    SendClientMessage(playerid, YELLOW, string);
                    SaveApartment(i);
                    return 1;
                }
                else { SendClientMessage(playerid,GREY,"You don't have enoguht money!"); return 1; }
            }
        }
    }
    if(strcmp(text,"takemoney",true) == 0) // puting money in safe
    {
        if(sscanf(params, "s[48]i",text , novac)) return SendClientMessage(playerid, -1, "HELP: ...");
        new string[128];
        if(novac < 0) { return 1; }
        for(new i = 0; i < sizeof(ApartmentInfo); i++)
        {
            GetPlayerName(playerid, plname, sizeof(plname));
            if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0 && GetPlayerVirtualWorld(playerid) == ApartmentInfo[i][sWorld])
            {
                if(ApartmentInfo[i][sMoney] >= novac)
                {
                    ApartmentInfo[i][sMoney] -= novac;
                    GivePlayerMoney(playerid,novac);
                    format(string, sizeof(string), "You have take %d $ from safe, now you have: %d $", novac, ApartmentInfo[i][sMoney]);
                    SendClientMessage(playerid, YELLOW, string);
                    SaveApartment(i);
                    return 1;
                }
                else { SendClientMessage(playerid,GREY,"You don't have enoguht money!"); return 1; }
            }
        }
    }
    return 1;
}
When I type /house info it doesn't respone..Can you help me bro ?
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)