CMD:buyhouse help
#1

pawn Код:
CMD:buyhouse(playerid, params[])
{
    new string[128];
    new playername[MAX_PLAYER_NAME];
    new sendername[MAX_PLAYER_NAME];
    new Float:oldposx, Float:oldposy, Float:oldposz;
    GetPlayerName(playerid, playername, sizeof(playername));
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);

    if(IsPlayerInRangeOfPoint(playerid,5.0, 0.0, 0.0, 0.0))
    {// This is to prevent players from buying non-ready houses at the 0,0,0  coordinates
        SendClientMessage(playerid, COLOR_WHITE, "You can't purchase houses in this area.");
        return 1;
    }
    for(new h = 0; h < sizeof(HouseInfo); h++)
    {
        if(IsPlayerInRangeOfPoint(playerid,2.0,HouseInfo[h][hExteriorX], HouseInfo[h][hExteriorY], HouseInfo[h][hExteriorZ]))
        {
            if(HouseInfo[h][hOwned] == 0)
            {
                if(PlayerInfo[playerid][pLevel] < HouseInfo[h][hLevel])
                {
                    format(string, sizeof(string), "   You must be Level %d to purchase this!", HouseInfo[h][hLevel]);
                    SendClientMessage(playerid, COLOR_GRAD5, string);
                    return 1;
                }
                if(PlayerInfo[playerid][pHouse] != INVALID_HOUSE_ID)
                {
                    SendClientMessage(playerid, COLOR_GRAD5, "You already own a house.");
                    return 1;
                }
                if(PlayerInfo[playerid][pHouse] == INVALID_HOUSE_ID)
                {

                    if(GetPlayerCash(playerid) >= HouseInfo[h][hValue])
                    {
                        if(GetPVarInt(playerid, "BuyHouseConfirm") == 0)
                        {
                            SetPVarInt(playerid, "BuyHouseConfirm", 1);
                            SendClientMessage(playerid, COLOR_WHITE, "You're about to buy this house. The money can't be returned once you have bought this house.");
                            SendClientMessage(playerid, COLOR_WHITE, "If you're sure you want to buy this house, please re-type the command (/buyhouse).");
                            return 1;
                        }
                        DeletePVar(playerid, "BuyHouseConfirm");

                        PlayerInfo[playerid][pHouse] = h;
                        HouseInfo[h][hOwned] = 1;
                        HouseInfo[h][hRentable] = 0;
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        strmid(HouseInfo[h][hOwner], sendername, 0, strlen(sendername), 255);
                        GivePlayerCash(playerid,-HouseInfo[h][hValue]);
                        SetPlayerInterior(playerid,HouseInfo[h][hHInteriorWorld]);
                        if(HouseInfo[h][hCustomInterior] == 1)
                        {
                            TogglePlayerControllable(playerid, 0);
                            for(new o = 0; o < 6; o++)
                            {
                                TextDrawShowForPlayer(playerid, ObjectsLoadingTD[o]);
                            }
                            SetPVarInt(playerid, "LoadingObjects", 1);
                            SetTimerEx("SafeLoadObjects", 3000, 0, "d", playerid);
                        }

                        format(string, sizeof(string), "* %s has entered their house.", GetPlayerNameEx(playerid));
                        ProxDetector(25.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);

                        SetPlayerPos(playerid,HouseInfo[h][hInteriorX],HouseInfo[h][hInteriorY],HouseInfo[h][hInteriorZ]);
                        SetPlayerFacingAngle(playerid,HouseInfo[h][hInteriorA]);
                        SetCameraBehindPlayer(playerid);
                        GameTextForPlayer(playerid, "~w~Welcome Home~n~You can exit at any time by moving to this door and typing /exit.", 5000, 3);
                        PlayerInfo[playerid][pInt] = HouseInfo[h][hHInteriorWorld];
                        SendClientMessage(playerid, COLOR_WHITE, "Congratulations on your new purchase!");
                        SendClientMessage(playerid, COLOR_WHITE, "Type /househelp to review the help section!");
                        SaveHouses();
                        PlayerInfo[playerid][pInt] = GetPlayerInterior(playerid);
                        PlayerInfo[playerid][pVW] = GetPlayerVirtualWorld(playerid);
                        GetPlayerIp(playerid, PlayerInfo[playerid][pIP], 32);
                        GetPlayerPos(playerid, PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z]);
                        GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pPos_r]);
                        OnPlayerStatsUpdate(playerid);
                        PlayerInfo[playerid][pVW] = h+60000;
                        SetPlayerVirtualWorld(playerid, h+60000);
                        DestroyPickup(HouseInfo[h][hPickupID]);
                        HouseInfo[h][hPickupID] = CreatePickup(1273, 23, HouseInfo[h][hExteriorX], HouseInfo[h][hExteriorY], HouseInfo[h][hExteriorZ], -1);
                        format(string, sizeof(string), "House owner: %s\nLevel: %d\nID: %d",HouseInfo[h][hOwner],HouseInfo[h][hLevel],h);
                        UpdateDynamic3DTextLabelText(HouseInfo[h][hTextID], COLOR_HOUSEGREEN, string);
                        new ip[32];
                        GetPlayerIp(playerid,ip,sizeof(ip));
                        format(string,sizeof(string),"%s (IP: %s) has bought house ID %d for $%d.",GetPlayerNameEx(playerid),ip,h,HouseInfo[h][hValue]);
                        Log("logs/house.log", string);
                        return 1;
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "   You don't have the cash for that.");
                        return 1;
                    }
Can someone help me to edit this CMD?
a Level 2 VIP can own two houses
Reply
#2

pawn Код:
if(PlayerInfo[playerid][pHouse] != INVALID_HOUSE_ID && PlayerInfo[playerid][pVIP] <2)
                {
                    SendClientMessage(playerid, COLOR_GRAD5, "You already own a house.");
                    return 1;
                }
change the [pVIP] to your VIP variable, this will let VIP 2 buy more than 1 house.
Reply
#3

I want to make the VIP 2 can buy max 2 houses, how?
Reply
#4

Help me please!!
Reply
#5

Quote:
Originally Posted by Jizz
Посмотреть сообщение
pawn Код:
CMD:buyhouse(playerid, params[])
{
    new string[128];
    new playername[MAX_PLAYER_NAME];
    new sendername[MAX_PLAYER_NAME];
    new Float:oldposx, Float:oldposy, Float:oldposz;
    GetPlayerName(playerid, playername, sizeof(playername));
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);

    if(IsPlayerInRangeOfPoint(playerid,5.0, 0.0, 0.0, 0.0))
    {// This is to prevent players from buying non-ready houses at the 0,0,0  coordinates
        SendClientMessage(playerid, COLOR_WHITE, "You can't purchase houses in this area.");
        return 1;
    }
    for(new h = 0; h < sizeof(HouseInfo); h++)
    {
        if(IsPlayerInRangeOfPoint(playerid,2.0,HouseInfo[h][hExteriorX], HouseInfo[h][hExteriorY], HouseInfo[h][hExteriorZ]))
        {
            if(HouseInfo[h][hOwned] == 0)
            {
                if(PlayerInfo[playerid][pLevel] < HouseInfo[h][hLevel])
                {
                    format(string, sizeof(string), "   You must be Level %d to purchase this!", HouseInfo[h][hLevel]);
                    SendClientMessage(playerid, COLOR_GRAD5, string);
                    return 1;
                }
                if(PlayerInfo[playerid][pHouse] != INVALID_HOUSE_ID)
                {
                    SendClientMessage(playerid, COLOR_GRAD5, "You already own a house.");
                    return 1;
                }
                if(PlayerInfo[playerid][pHouse] == INVALID_HOUSE_ID)
                {

                    if(GetPlayerCash(playerid) >= HouseInfo[h][hValue])
                    {
                        if(GetPVarInt(playerid, "BuyHouseConfirm") == 0)
                        {
                            SetPVarInt(playerid, "BuyHouseConfirm", 1);
                            SendClientMessage(playerid, COLOR_WHITE, "You're about to buy this house. The money can't be returned once you have bought this house.");
                            SendClientMessage(playerid, COLOR_WHITE, "If you're sure you want to buy this house, please re-type the command (/buyhouse).");
                            return 1;
                        }
                        DeletePVar(playerid, "BuyHouseConfirm");

                        PlayerInfo[playerid][pHouse] = h;
                        HouseInfo[h][hOwned] = 1;
                        HouseInfo[h][hRentable] = 0;
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        strmid(HouseInfo[h][hOwner], sendername, 0, strlen(sendername), 255);
                        GivePlayerCash(playerid,-HouseInfo[h][hValue]);
                        SetPlayerInterior(playerid,HouseInfo[h][hHInteriorWorld]);
                        if(HouseInfo[h][hCustomInterior] == 1)
                        {
                            TogglePlayerControllable(playerid, 0);
                            for(new o = 0; o < 6; o++)
                            {
                                TextDrawShowForPlayer(playerid, ObjectsLoadingTD[o]);
                            }
                            SetPVarInt(playerid, "LoadingObjects", 1);
                            SetTimerEx("SafeLoadObjects", 3000, 0, "d", playerid);
                        }

                        format(string, sizeof(string), "* %s has entered their house.", GetPlayerNameEx(playerid));
                        ProxDetector(25.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);

                        SetPlayerPos(playerid,HouseInfo[h][hInteriorX],HouseInfo[h][hInteriorY],HouseInfo[h][hInteriorZ]);
                        SetPlayerFacingAngle(playerid,HouseInfo[h][hInteriorA]);
                        SetCameraBehindPlayer(playerid);
                        GameTextForPlayer(playerid, "~w~Welcome Home~n~You can exit at any time by moving to this door and typing /exit.", 5000, 3);
                        PlayerInfo[playerid][pInt] = HouseInfo[h][hHInteriorWorld];
                        SendClientMessage(playerid, COLOR_WHITE, "Congratulations on your new purchase!");
                        SendClientMessage(playerid, COLOR_WHITE, "Type /househelp to review the help section!");
                        SaveHouses();
                        PlayerInfo[playerid][pInt] = GetPlayerInterior(playerid);
                        PlayerInfo[playerid][pVW] = GetPlayerVirtualWorld(playerid);
                        GetPlayerIp(playerid, PlayerInfo[playerid][pIP], 32);
                        GetPlayerPos(playerid, PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z]);
                        GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pPos_r]);
                        OnPlayerStatsUpdate(playerid);
                        PlayerInfo[playerid][pVW] = h+60000;
                        SetPlayerVirtualWorld(playerid, h+60000);
                        DestroyPickup(HouseInfo[h][hPickupID]);
                        HouseInfo[h][hPickupID] = CreatePickup(1273, 23, HouseInfo[h][hExteriorX], HouseInfo[h][hExteriorY], HouseInfo[h][hExteriorZ], -1);
                        format(string, sizeof(string), "House owner: %s\nLevel: %d\nID: %d",HouseInfo[h][hOwner],HouseInfo[h][hLevel],h);
                        UpdateDynamic3DTextLabelText(HouseInfo[h][hTextID], COLOR_HOUSEGREEN, string);
                        new ip[32];
                        GetPlayerIp(playerid,ip,sizeof(ip));
                        format(string,sizeof(string),"%s (IP: %s) has bought house ID %d for $%d.",GetPlayerNameEx(playerid),ip,h,HouseInfo[h][hValue]);
                        Log("logs/house.log", string);
                        return 1;
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "   You don't have the cash for that.");
                        return 1;
                    }
Can someone help me to edit this CMD?
a Level 2 VIP can own two houses
NGRP Script old version ?
Reply
#6

HZRP old scripts
Reply
#7

Quote:
Originally Posted by JamesH
Посмотреть сообщение
pawn Код:
if(PlayerInfo[playerid][pHouse] != INVALID_HOUSE_ID && PlayerInfo[playerid][pVIP] <2)
                {
                    SendClientMessage(playerid, COLOR_GRAD5, "You already own a house.");
                    return 1;
                }
change the [pVIP] to your VIP variable, this will let VIP 2 buy more than 1 house.
It's much more complex than that.

You need to store the house information that means you will have to choose an approach to do this the best way is probably the most difficult since these mindless roleplay scripts don't have a modular approach. This means all the systems are slapped into the gamemode in a very messy way the only real way to achieve what you want is to strip out the whole houses system and implement it into it's own include module. There really is no easy solution to your problem in fact the time you will spend getting everything in order you'll be better off making your own gamemode.

I just don't think your analyzing your problem fully, well you wouldn't be asking if you were sure because your not sure so I'm trying to be objective here and give you a realistic outlook.

- For myself to do this I would estimate the time would take up to 2-3 days
- The whole housing system needs to be stripped out of the gamemode and implemented into a include
- Code needs to be modified to accomodate more than one house
- Dynamic design would have to looked over
- If there is no mysql/sqlite support it would have to be coded (ini is a hinderance)
- The lookup method for houses is unacceptable woud have to be re-written
- Code needs to be tested throughly

In other words you don't know what your doing you'll never get it done it's more than what you would think to do it properly. There is also probably a lot of other things that would need to be done as well along the way this is why you don't use crappy gamemodes downloaded off the forum and expect to get anywhere with it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)