SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 28/03/2011, 10:47 AM   #1
Magazinez
Banned
 
Join Date: Mar 2011
Location: MyPC/Desktop/Scripts/Pawno
Posts: 8
Reputation: 0
Default [Help]: Housing System

Hi, Im trying to create a house system and im having some trouble, Everything works fine but only for 1 house (The 1st House ID) and the rest say that im not at a valid house location..Ive tried everything and im stuck now, I have no idea whats happening, May someone kindly look at it and explain my mistakes please..

pawn Code:
#include <a_samp>

#define HOUSE_FILE "Properties/%s.ini"

#define MAX_HOUSES 39

new HouseCount = -1;
new PickupID[MAX_HOUSES];
new InHouse[MAX_PLAYERS] = -1;

enum HouseInfo
{
    hName[64],
    hCost,
    hOwner[64],
    Float:ExtX,
    Float:ExtY,
    Float:ExtZ,
    Float:IntX,
    Float:IntY,
    Float:IntZ,
    IntID,
    hSell,
    IsOwned,
    vWorld
};

new hInfo[MAX_HOUSES][HouseInfo];

public OnGameModeInit()
{
    Create1StoryHouse("prop1", 2056.5713,2665.1870,10.8203 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);
    Create1StoryHouse("prop2", 2037.0551,2664.5078,10.8203 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);
    Create1StoryHouse("prop3", 2017.9668,2664.6616,11.2989 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);
    Create1StoryHouse("prop4", 1989.1700,2665.1931,10.8203 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);
    Create1StoryHouse("prop5", 1969.6868,2664.5044,10.8203 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);
    Create1StoryHouse("prop6", 1950.5684,2664.6631,11.2989 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);
    Create1StoryHouse("prop7", 1921.7871,2665.1890,10.8203 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);
    Create1StoryHouse("prop8", 1931.2377,2721.2581,10.8203 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);
    Create1StoryHouse("prop9", 1950.7180,2721.9451,10.8203 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);
    Create1StoryHouse("prop10", 1969.8501,2721.7927,11.2989 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);
    Create1StoryHouse("prop11", 1998.6288,2721.2603,10.8203 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);
    Create1StoryHouse("prop12", 2018.1108,2721.9460,10.8203 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);
    Create1StoryHouse("prop13", 2037.2518,2721.4917,11.5430 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);
    Create1StoryHouse("prop14", 2066.0220,2721.2646,10.8203 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);
    Create1StoryHouse("prop15", -2552.1436,2266.4768,5.4755 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);
    Create1StoryHouse("prop16", -2523.9070,2238.8455,5.3984 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);
    Create1StoryHouse("prop17", -2437.4514,2354.9456,5.4431 , 2193.9001, -1202.4185, 1049.0234, 6, 800000, 500000);

    Create2StoryHouse("prop18", 2049.6538,2764.2891,10.8203 , 2320.0730, -1023.9533, 1050.2109, 9, 1000000, 800000);
    Create2StoryHouse("prop19", 2039.5837,2766.5464,10.8265 , 2320.0730, -1023.9533, 1050.2109, 9, 1000000, 800000);
    Create2StoryHouse("prop20", 2018.6033,2766.5466,10.8265 , 2320.0730, -1023.9533, 1050.2109, 9, 1000000, 800000);
    Create2StoryHouse("prop21", 1992.5646,2764.6348,10.8203 , 2320.0730, -1023.9533, 1050.2109, 9, 1000000, 800000);
    Create2StoryHouse("prop22", 1967.3890,2766.5469,10.8265 , 2320.0730, -1023.9533, 1050.2109, 9, 1000000, 800000);
    Create2StoryHouse("prop23", 1929.8540,2774.2407,10.8203 , 2320.0730, -1023.9533, 1050.2109, 9, 1000000, 800000);

    CreateSmallMansion("prop24", -2424.6890,2449.0520,13.1392 , 2324.4490, -1145.2841, 1050.7101, 12, 1500000, 1200000);
    CreateSmallMansion("prop25", -2421.7190,2406.6719,13.0253 , 2324.4490, -1145.2841, 1050.7101, 12, 1500000, 1200000);
    CreateSmallMansion("prop26", -2398.1401,2408.8418,8.9108 , 2324.4490, -1145.2841, 1050.7101, 12, 1500000, 1200000);
    CreateSmallMansion("prop27", -2348.3062,2423.5574,7.3295 , 2324.4490, -1145.2841, 1050.7101, 12, 1500000, 1200000);
    CreateSmallMansion("prop28", -2627.6328,2283.3877,8.3148 , 2324.4490, -1145.2841, 1050.7101, 12, 1500000, 1200000);
    CreateSmallMansion("prop29", -2627.6355,2292.0122,8.3149 , 2324.4490, -1145.2841, 1050.7101, 12, 1500000, 1200000);
    CreateSmallMansion("prop30", -2627.5818,2310.0366,8.3144 , 2324.4490, -1145.2841, 1050.7101, 12, 1500000, 1200000);
    CreateSmallMansion("prop31", -2627.5818,2318.6316,8.3144 , 2324.4490, -1145.2841, 1050.7101, 12, 1500000, 1200000);
    CreateSmallMansion("prop32", -2636.4116,2351.0195,8.4892 , 2324.4490, -1145.2841, 1050.7101, 12, 1500000, 1200000);
    CreateSmallMansion("prop33", -2632.5308,2374.8826,9.0407 , 2324.4490, -1145.2841, 1050.7101, 12, 1500000, 1200000);
    CreateSmallMansion("prop34", -2634.8674,2401.7126,11.2212 , 2324.4490, -1145.2841, 1050.7101, 12, 1500000, 1200000);
    CreateSmallMansion("prop35", -2632.4038,2410.5344,14.0237 , 2324.4490, -1145.2841, 1050.7101, 12, 1500000, 1200000);

    CreateLargeMansion("prop36", -2479.8328,2449.9624,17.3230 , 140.1788, 1369.1936, 1083.8641, 5, 2000000, 1700000);
    CreateLargeMansion("prop37", -2386.2771,2447.5134,10.1694 , 140.1788, 1369.1936, 1083.8641, 5, 2000000, 1700000);
    CreateLargeMansion("prop38", -2583.1306,2300.2971,7.0029 , 140.1788, 1369.1936, 1083.8641, 5, 2000000, 1700000);
    CreateLargeMansion("prop39", -2597.3147,2364.5999,9.8830 , 140.1788, 1369.1936, 1083.8641, 5, 2000000, 1700000);
    return 1;
}

stock Create1StoryHouse(Filename[], Float:eX, Float:eY, Float:eZ, Float:iX, Float:iY, Float:iZ, Int, Cost, Sell)
{
    if(!dini_Exists(HOUSE_FILE))
    {
        dini_Create(HOUSE_FILE);
    }
    HouseCount ++;
    new i = HouseCount;
    format(hInfo[i][hName], 64, "%s", Filename);
    hInfo[i][ExtX] = eX;
    hInfo[i][ExtY] = eY;
    hInfo[i][ExtZ] = eZ;
    hInfo[i][IntX] = iX;
    hInfo[i][IntY] = iY;
    hInfo[i][IntZ] = iZ;
    hInfo[i][IntID] = Int;
    hInfo[i][vWorld] = 100000 + i;
    hInfo[i][hCost] = Cost;
    hInfo[i][hSell] = Sell;
    format(hInfo[i][hOwner], 64, " ");
    if(strlen(dini_Get(HOUSE_FILE, Filename)))
    {
        format(hInfo[i][hOwner], 64, "%s", dini_Get(HOUSE_FILE, Filename));
        hInfo[i][IsOwned] = 1;
    }
    PickupID[i] = CreatePickup(1273, 23, eX, eY, eZ, -1);
    Create3DTextLabel("Property: 1 Story Housing Estate\nWorth: $800,000\nValue: $500,000", LIGHTGREEN, eX, eY, eZ + 1.0, 15.0, 0, 1);
}

stock Create2StoryHouse(Filename[], Float:eX, Float:eY, Float:eZ, Float:iX, Float:iY, Float:iZ, Int, Cost, Sell)
{
    if(!dini_Exists(HOUSE_FILE))
    {
        dini_Create(HOUSE_FILE);
    }
    HouseCount ++;
    new i = HouseCount;
    format(hInfo[i][hName], 64, "%s", Filename);
    hInfo[i][ExtX] = eX;
    hInfo[i][ExtY] = eY;
    hInfo[i][ExtZ] = eZ;
    hInfo[i][IntX] = iX;
    hInfo[i][IntY] = iY;
    hInfo[i][IntZ] = iZ;
    hInfo[i][IntID] = Int;
    hInfo[i][vWorld] = 100000 + i;
    hInfo[i][hCost] = Cost;
    hInfo[i][hSell] = Sell;
    format(hInfo[i][hOwner], 64, " ");
    if(strlen(dini_Get(HOUSE_FILE, Filename)))
    {
        format(hInfo[i][hOwner], 64, "%s", dini_Get(HOUSE_FILE, Filename));
        hInfo[i][IsOwned] = 1;
    }
    PickupID[i] = CreatePickup(1273, 23, eX, eY, eZ, -1);
    Create3DTextLabel("Property: 2 Story Housing Estate\nWorth: $1,000,000\nValue: $800,000", LIGHTGREEN, eX, eY, eZ + 1.0, 15.0, 0, 1);
}

stock CreateSmallMansion(Filename[], Float:eX, Float:eY, Float:eZ, Float:iX, Float:iY, Float:iZ, Int, Cost, Sell)
{
    if(!dini_Exists(HOUSE_FILE))
    {
        dini_Create(HOUSE_FILE);
    }
    HouseCount ++;
    new i = HouseCount;
    format(hInfo[i][hName], 64, "%s", Filename);
    hInfo[i][ExtX] = eX;
    hInfo[i][ExtY] = eY;
    hInfo[i][ExtZ] = eZ;
    hInfo[i][IntX] = iX;
    hInfo[i][IntY] = iY;
    hInfo[i][IntZ] = iZ;
    hInfo[i][IntID] = Int;
    hInfo[i][vWorld] = 100000 + i;
    hInfo[i][hCost] = Cost;
    hInfo[i][hSell] = Sell;
    format(hInfo[i][hOwner], 64, " ");
    if(strlen(dini_Get(HOUSE_FILE, Filename)))
    {
        format(hInfo[i][hOwner], 64, "%s", dini_Get(HOUSE_FILE, Filename));
        hInfo[i][IsOwned] = 1;
    }
    PickupID[i] = CreatePickup(1273, 23, eX, eY, eZ, -1);
    Create3DTextLabel("Property: Small Mansion Estate\nWorth: $1,500,000\nValue: $1,200,000", LIGHTGREEN, eX, eY, eZ + 1.0, 15.0, 0, 1);
}

stock CreateLargeMansion(Filename[], Float:eX, Float:eY, Float:eZ, Float:iX, Float:iY, Float:iZ, Int, Cost, Sell)
{
    if(!dini_Exists(HOUSE_FILE))
    {
        dini_Create(HOUSE_FILE);
    }
    HouseCount ++;
    new i = HouseCount;
    format(hInfo[i][hName], 64, "%s", Filename);
    hInfo[i][ExtX] = eX;
    hInfo[i][ExtY] = eY;
    hInfo[i][ExtZ] = eZ;
    hInfo[i][IntX] = iX;
    hInfo[i][IntY] = iY;
    hInfo[i][IntZ] = iZ;
    hInfo[i][IntID] = Int;
    hInfo[i][vWorld] = 100000 + i;
    hInfo[i][hCost] = Cost;
    hInfo[i][hSell] = Sell;
    format(hInfo[i][hOwner], 64, " ");
    if(strlen(dini_Get(HOUSE_FILE, Filename)))
    {
        format(hInfo[i][hOwner], 64, "%s", dini_Get(HOUSE_FILE, Filename));
        hInfo[i][IsOwned] = 1;
    }
    PickupID[i] = CreatePickup(1273, 23, eX, eY, eZ, -1);
    Create3DTextLabel("Property: Large Mansion Estate\nWorth: $2,000,000\nValue: $1,700,000", LIGHTGREEN, eX, eY, eZ + 1.0, 15.0, 0, 1);
}

CMD:buy(playerid, params[])
{
    for(new i; i<MAX_HOUSES; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, hInfo[i][ExtX], hInfo[i][ExtY], hInfo[i][ExtZ]))
        {
            new Pname[24]; GetPlayerName(playerid, Pname, 24);
            if(strlen(dini_Get(HOUSE_FILE, Pname)))
            if(GetPlayerMoney(playerid) < hInfo[i][hCost]) return SendClientMessage(playerid, RED, "You Dont Have Enough Money To Buy This House!");
            if(hInfo[i][IsOwned] == 1) return SendClientMessage(playerid, RED, "This House Is Already Owned!");
            GivePlayerCash(playerid, -hInfo[i][hCost]);
            GameTextForPlayer(playerid, "~r~House Purchased!", 2000, 3);
            hInfo[i][IsOwned] = 1;
            GetPlayerName(playerid, Pname, 24);
            format(hInfo[i][hOwner], 24, "%s", Pname);
            dini_Set(HOUSE_FILE, Pname, hInfo[i][hName]);
            return true;
        }
        else
        {
            SendClientMessage(playerid, RED, "Your Not At A Valid House Location!");//Shows this for every other house, I can buy the 1st house ID fine..
        }
        return true;
    }
    return true;
}

CMD:sell(playerid, params[])
{
    for(new i; i<MAX_HOUSES; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, hInfo[i][ExtX], hInfo[i][ExtY], hInfo[i][ExtZ]))
        {
            new Pname[24]; GetPlayerName(playerid, Pname, 24);
            if(strcmp(Pname, hInfo[i][hOwner]) != 0) return SendClientMessage(playerid, RED, "You Dont Own This House!");
            GivePlayerCash(playerid, hInfo[i][hSell]);
            format(hInfo[i][hOwner], 64, " ");
            GameTextForPlayer(playerid, "~r~House Sold!", 2000, 3);
            hInfo[i][IsOwned] = 0;
            hInfo[i][hOwner] = EOS;
            dini_Unset(HOUSE_FILE, Pname);
            return true;
        }
        else
        {
            SendClientMessage(playerid, RED, "You Must Be At The Door To Sell It!");
        }
        return true;
    }
    return true;
}

CMD:enter(playerid, params[])
{
    for(new i; i<MAX_HOUSES; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3, hInfo[i][ExtX], hInfo[i][ExtY], hInfo[i][ExtZ]))
        {
            new Pname[24]; GetPlayerName(playerid, Pname, 24);
            if(strcmp(Pname, hInfo[i][hOwner]) != 0) return SendClientMessage(playerid, RED, "You Dont Own This House!");
            SetPlayerPos(playerid, hInfo[i][IntX], hInfo[i][IntY], hInfo[i][IntZ]);
            SetPlayerInterior(playerid, hInfo[i][IntID]);
            InHouse[playerid] = i;
            SetPlayerVirtualWorld(playerid, hInfo[i][vWorld]);
            SendClientMessage(playerid, YELLOW, "You Have Entered Your House, Use /exit To Exit!");
            return true;
        }
        else
        {
            SendClientMessage(playerid, RED, "You Must Be At The Door To Enter Your House!");
        }
        return true;
    }
    return true;
}

CMD:exit(playerid, params[])
{
    if(InHouse[playerid] == -1) return SendClientMessage(playerid, RED, "Your Not Inside Your House!");
    SetPlayerPos(playerid, hInfo[InHouse[playerid]][ExtX], hInfo[InHouse[playerid]][ExtY], hInfo[InHouse[playerid]][ExtZ]);
    SetPlayerInterior(playerid, 0);
    SetPlayerVirtualWorld(playerid, 0);
    InHouse[playerid] = -1;
    return true;
}

Thats the whole code..

Thanks in advanced!
Magazinez is offline  
Old 28/03/2011, 02:06 PM   #2
Hornet600
Big Clucker
 
Join Date: Oct 2010
Posts: 124
Reputation: 0
Default Re: [Help]: Housing System

i guess i saw this in some tut and you didnt created this house system :P you should learn and ask small things not a whole script and alot of cmds
Hornet600 is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Housing System jamesb93 Help Archive 9 15/02/2010 10:08 PM
does someone has a housing system? Jackass123 Help Archive 1 06/12/2009 09:38 PM
Help me with my Dynamic Housing System Sean12 Help Archive 2 30/04/2009 08:26 AM


All times are GMT. The time now is 07:16 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.