[HELP]: House System
#1

Hello SA-MP !

I got one problem with my house system. I created a checkpoint near every house with command /makehouse. And then, when player enter the checkpoint, he/she gets the dialog. If house isn't owned, he/she gets diaolg for buying house, this one works perfectly. But if the house is owned, then he/she gets the dialog for entering/selling the house and this doesn't work. When i click on enter, it always enter me into the house size 3, even if i made a house size 2, 1, it always puts me into size 3 house. Also, when i select sell house, there is nothing happend. Can someone fix it ?

OnPlayerEnterDynamicCP
pawn Код:
for(new i = 0; i < MAX_HOUSES; i ++)
    {
    if(checkpointid == HouseEnter[i])
    {
    if(hInfo[i][Owned] == 1)
    {
    ShowPlayerDialog(playerid, DIALOG_SELLHOUSE, DIALOG_STYLE_LIST, "House Options:", "1. - Enter House\n2. - Sell House", "Ok", "Close");
    }
OnDialogResponse
pawn Код:
if(dialogid == DIALOG_SELLHOUSE)
    {
    if(!response)return 0;
    if(response)
    {
    if(listitem == 0)
    {
    for(new i = 0; i < MAX_HOUSES; i ++)
    {
    if(hInfo[i][Size] == 1)
    {
    GetPlayerPos(playerid, EnterPosX, EnterPosY, EnterPosZ);
    SetPVarInt(playerid, "PlayerVirtualWorldHouse", GetPlayerVirtualWorld(playerid));
    SetPlayerVirtualWorld(playerid, hInfo[i][VirtualWorld]);
    SetPlayerPos(playerid, 2308.8926, -1209.8003, 1049.0234);
    SetPlayerInterior(playerid, 6);
    PlayerInHouseID[playerid] = i;
    }
    else if(hInfo[i][Size] == 2)
    {
    GetPlayerPos(playerid, EnterPosX, EnterPosY, EnterPosZ);
    SetPVarInt(playerid, "PlayerVirtualWorldHouse", GetPlayerVirtualWorld(playerid));
    SetPlayerVirtualWorld(playerid, hInfo[i][VirtualWorld]);
    SetPlayerPos(playerid, 2365.3000, -1130.9200, 1050.8750);
    SetPlayerInterior(playerid, 8);
    PlayerInHouseID[playerid] = i;
    }
    else if(hInfo[i][Size] == 3)
    {
    GetPlayerPos(playerid, EnterPosX, EnterPosY, EnterPosZ);
    SetPVarInt(playerid, "PlayerVirtualWorldHouse", GetPlayerVirtualWorld(playerid));
    SetPlayerVirtualWorld(playerid, hInfo[i][VirtualWorld]);
    SetPlayerPos(playerid, 2324.4199, -1145.5400, 1050.7101);
    SetPlayerInterior(playerid, 12);
    PlayerInHouseID[playerid] = i;
    }
    }
    if(listitem == 1)
    {
    for(new i = 0; i < MAX_HOUSES; i ++)
    {
    if(!IsPlayerInRangeOfPoint(playerid, 4.0, hInfo[i][posX], hInfo[i][posY], hInfo[i][posZ])) continue;
    if(hInfo[i][Owned] == 0)return SendClientMessage(playerid, -1, "This house isn't yours / Isn't owned !");
    new pName[24];
    GetPlayerName(playerid, pName, sizeof(pName));
    if(hInfo[i][Owned] == 1 && strcmp(pName, hInfo[i][Owner]) != 0)return SendClientMessage(playerid, -1, "This house isn't yours / Isn't owned !");
    hInfo[i][Owned] = 0;
    new string[300];
    format(hInfo[i][Owner], 24, "None");
    new str[100];
    format(str, sizeof(str), "Red_VS_Blue/Houses/%i.ini", i);
    new INI:file = INI_Open(str);
    INI_SetTag(file, "House's Data");
    INI_WriteInt(file, "Owned", 0);
    INI_WriteString(file, "Owner", "None");
    INI_Close(file);
    format(string, sizeof(string), "House ID: {FFFFFF}%i\n{008000}Owner: {FFFFFF}None\n{008000}Owned: {FFFFFF}No\n{008000}Price: {FFFFFF}%i\n{008000}Size: {FFFFFF}%i", hInfo[i][HouseID], hInfo[i][Price], hInfo[i][Size]);
    Update3DTextLabelText(hInfo[i][HouseLabel], 0x008000C8, string);
    DestroyDynamicPickup(HousePickup[i]);
    HousePickup[i] = CreateDynamicPickup(1273, 1, hInfo[i][posX], hInfo[i][posY], hInfo[i][posZ], GetPlayerVirtualWorld(playerid), 0, -1, 500.0);
    DestroyDynamicMapIcon(HouseIcon[i]);
    HouseIcon[i] = CreateDynamicMapIcon(hInfo[i][posX], hInfo[i][posY], hInfo[i][posZ], 31, -1, GetPlayerVirtualWorld(playerid), -1, -1, 500.0);
    SendClientMessage(playerid, -1, "You sold your house !");
    GivePlayerMoney(playerid, hInfo[i][Price]);
    pInfo[playerid][House] --;
    return 1;
    }
    }
    }
    }
    }
Thanks.
Reply
#2

But, when i had /sellhouse command instead dialog, it worked..
Reply
#3

How are you assigning the house size? mind showing the code?
Reply
#4

pawn Код:
enum HouseInfo
{
    HouseID,
    Owner[24],
    Owned,
    Price,
    Float:posX,
    Float:posY,
    Float:posZ,
    VirtualWorld,
    Text3D:HouseLabel,
    Size,
}
new hInfo[MAX_HOUSES][HouseInfo];
And /makehouse

pawn Код:
CMD:makehouse(playerid,params[])
{
    new HousePrice; new id = HouseCount; new size;
    if(sscanf(params, "ii", HousePrice, size))return SendClientMessage(playerid, -1, "USAGE: /makehouse <Price> <Size>");
    if(size >= 4)return SendClientMessage(playerid, -1, "Max size: 3 | Min size: 1");
    if(size <= 0)return SendClientMessage(playerid, -1, "Max size: 3 | Min size: 1");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    hInfo[id][HouseID] = id;
    hInfo[id][Size] = size;
    hInfo[id][Price] = HousePrice;
    hInfo[id][Owned] = 0;
    hInfo[id][posX] = x;
    hInfo[id][posY] = y;
    hInfo[id][posZ] = z;
    hInfo[id][VirtualWorld] = GetPlayerVirtualWorld(playerid);
    format(hInfo[id][Owner], 24, "None");
    if(hInfo[id][Size] == 1)
    {
    HouseEnter[id] = CreateDynamicCP(x, y, z, 1.5, GetPlayerVirtualWorld(playerid));
    HouseExit[id] = CreateDynamicCP(2307.7524, -1212.8821, 1049.0234, 1.5, GetPlayerVirtualWorld(playerid), 6);
    Create3DTextLabel("Exit the house", 0xFF0000FF, 2307.7524, -1212.8821, 1049.0234, 25.0, GetPlayerVirtualWorld(playerid));
    SendClientMessage(playerid, -1, "Small House created !");
    }
    if(hInfo[id][Size] == 2)
    {
    HouseEnter[id] = CreateDynamicCP(x, y, z, 1.5, GetPlayerVirtualWorld(playerid));
    HouseExit[id] = CreateDynamicCP(2365.2603,-1135.5988,1050.8826, 1.5, GetPlayerVirtualWorld(playerid), 8);
    Create3DTextLabel("Exit the house", 0xFF0000FF, 2365.2603, -1135.5988, 1050.8826, 25.0, GetPlayerVirtualWorld(playerid));
    SendClientMessage(playerid, -1, "Medium House created !");
    }
    if(hInfo[id][Size] == 3)
    {
    HouseEnter[id] = CreateDynamicCP(x, y, z, 1.5, GetPlayerVirtualWorld(playerid));
    HouseExit[id] = CreateDynamicCP(2324.4839, -1149.5469, 1050.7101, 1.5, GetPlayerVirtualWorld(playerid), 12);
    Create3DTextLabel("Exit the house", 0xFF0000FF, 2324.4839, -1149.5469, 1050.7101, 25.0, GetPlayerVirtualWorld(playerid));
    SendClientMessage(playerid, -1, "Big House created !");
    }
    new labelstring[300]; new str[100];
    format(str, sizeof(str), "Red_VS_Blue/Houses/%i.ini", id);
    new INI:file = INI_Open(str);
    INI_SetTag(file, "House's Data");
    INI_WriteInt(file, "HouseID", id);
    INI_WriteInt(file, "Size", size);
    INI_WriteInt(file, "Price", HousePrice);
    INI_WriteInt(file, "Owned", 0);
    INI_WriteInt(file, "VirtualWorld", GetPlayerVirtualWorld(playerid));
    INI_WriteFloat(file, "posX", x);
    INI_WriteFloat(file, "posY", y);
    INI_WriteFloat(file, "posZ", z);
    INI_WriteString(file, "Owner", "None");
    INI_Close(file);
    format(labelstring, sizeof(labelstring), "House ID: {FFFFFF}%i\n{008000}Owner: {FFFFFF}None\n{008000}Owned: {FFFFFF}No\n{008000}Price: {FFFFFF}%i\n{008000}Size: {FFFFFF}%i", HouseCount, HousePrice, size);
    hInfo[id][HouseLabel] = Create3DTextLabel(labelstring, 0x008000C8, x, y, z, 25.0, GetPlayerVirtualWorld(playerid));
    HousePickup[id] = CreateDynamicPickup(1273, 1, x, y, z, GetPlayerVirtualWorld(playerid), 0, -1, 500.0);
    HouseIcon[id] = CreateDynamicMapIcon(x, y, z, 31, -1, GetPlayerVirtualWorld(playerid), -1, -1, 500.0);
    HouseCount ++;
    return 1;
}
Reply
#5

Bump
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)