[HELP] Loading House Map Icon/Pickup
#1

I'm using Kwarde's House System tutorial.
I decide to create a stock function CreateHouse because Kwarde
has some mistake in some part of his tutorial so i decide to modify it.

How do i load the map icon/pickup? when i go to the place where the green pickup should be in the pos, there is nothing. I use streamer.

pawn Code:
LoadHouse(houseid)
{
    new fstring[120];
    format(fstring, 10, "Clan/Houses/%d", houseid);
    if(!dini_Exists(fstring)) return 0;
    HouseInfo[houseid][hEnterX] = dini_Float(fstring, "EnterX");
    HouseInfo[houseid][hEnterY] = dini_Float(fstring, "EnterY");
    HouseInfo[houseid][hEnterZ] = dini_Float(fstring, "EnterZ");
    HouseInfo[houseid][hExitX] = dini_Float(fstring, "ExitX");
    HouseInfo[houseid][hExitY] = dini_Float(fstring, "ExitY");
    HouseInfo[houseid][hExitZ] = dini_Float(fstring, "ExitZ");
    HouseInfo[houseid][hInsideInt] = dini_Int(fstring, "InsideInt");
    HouseInfo[houseid][hInsideVir] = dini_Int(fstring, "InsideVir");
    HouseInfo[houseid][hOutsideInt] = dini_Int(fstring, "OutsideInt");
    HouseInfo[houseid][hOutsideVir] = dini_Int(fstring, "OutsideVir");
    HouseInfo[houseid][hOwned] = dini_Bool(fstring, "Owned") ? true : false;
    strmid(HouseInfo[houseid][hOwner], dini_Get(fstring, "Owner"), 0, false, strlen(dini_Get(fstring, "Owner")));
    HouseInfo[houseid][hPrice] = dini_Int(fstring, "Price");
    return 1;
}

LoadHouseVisual(houseid, bool:reload = false)
{
    if(reload)
    {
        DestroyDynamicMapIcon(HouseInfo[houseid][hIcon]);
        DestroyDynamicPickup(HouseInfo[houseid][hPickup]);
    }
}

CreateHouse(houseid, Float:EnterX, Float:EnterY, Float:EnterZ, Float:ExitX, Float:ExitY, Float:ExitZ, InsideInt, InsideVir, OutsideInt, OutVir, bool:Owned, Owner[], Price)
{
    new fstring[120];
    format(fstring, sizeof(fstring), "Clan/Houses/%d.ini", houseid);
    dini_Create(fstring);
    dini_FloatSet(fstring, "EnterX", EnterX);
    dini_FloatSet(fstring, "EnterY", EnterY);
    dini_FloatSet(fstring, "EnterZ", EnterZ);
    dini_FloatSet(fstring, "ExitX", ExitX);
    dini_FloatSet(fstring, "ExitY", ExitY);
    dini_FloatSet(fstring, "ExitZ", ExitZ);
    dini_IntSet(fstring, "InsideInt", InsideInt);
    dini_IntSet(fstring, "InsideVir", InsideVir);
    dini_IntSet(fstring, "OutsideInt", OutsideInt);
    dini_IntSet(fstring, "OutsideVir", OutVir);
    dini_BoolSet(fstring, "Owned", Owned);
    dini_Set(fstring, "Owner", Owner);
    dini_IntSet(fstring, "Price", Price);
}

SaveHouse(houseid)
{
    new fstring[120];
    format(fstring, sizeof(fstring), "Clan/Houses/%d.ini", houseid);
    dini_FloatSet(fstring, "EnterX", HouseInfo[houseid][hEnterX]);
    dini_FloatSet(fstring, "EnterY", HouseInfo[houseid][hEnterY]);
    dini_FloatSet(fstring, "EnterZ", HouseInfo[houseid][hEnterZ]);
    dini_FloatSet(fstring, "ExitX", HouseInfo[houseid][hExitX]);
    dini_FloatSet(fstring, "ExitY", HouseInfo[houseid][hExitY]);
    dini_FloatSet(fstring, "ExitZ", HouseInfo[houseid][hExitZ]);
    dini_IntSet(fstring, "InsideInt", HouseInfo[houseid][hInsideInt]);
    dini_IntSet(fstring, "InsideVir", HouseInfo[houseid][hInsideVir]);
    dini_IntSet(fstring, "OutsideInt", HouseInfo[houseid][hOutsideInt]);
    dini_IntSet(fstring, "OutsideVir", HouseInfo[houseid][hOutsideVir]);
    dini_BoolSet(fstring, "Owned", HouseInfo[houseid][hOwned]);
    dini_Get(fstring, "Owner");
    dini_IntSet(fstring, "Price", HouseInfo[houseid][hPrice]);
}
pawn Code:
public OnGameModeInit()
{
    CreateHouse(0, 2495.2742,-1688.7939,14.0285, 2496.1145,-1694.5383,1014.7422, 3, 3, 0, 0, false, "For Sale", 570500);
    for(new i = 0; i < MAX_HOUSES; i++)
    {
        LoadHouse(i);
        LoadHouseVisual(i, false);
    }
    SetTimer("UpdatePlayersHouseInfo", 1000, true);
    return 1;
}

CMD:buyhouse(playerid, params[])
{
    foreach(Player, i)
    {
        if(IsPlayerInRangeOfPoint(playerid, 1.5, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]) && GetPlayerInterior(playerid) == HouseInfo[i][hOutsideInt] && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hOutsideVir])
        {
            if(HouseInfo[i][hOwned]) return SendClientMessage(playerid, COLOR_RED, "*** This house is already owned! ***");
            if(GetPlayerMoney(playerid) < HouseInfo[i][hPrice]) return SendClientMessage(playerid, COLOR_RED, "*** You do not have enough money to buy this house! ***");
            HouseInfo[i][hOwned] = true;
            strmid(HouseInfo[i][hOwner], GetpName(playerid), 0, false, strlen(GetpName(playerid)));
            GivePlayerMoney(playerid, -HouseInfo[i][hPrice]);
            SendClientMessage(playerid, COLOR_LIGHTGREEN, "*** House bought! ***");
            SaveHouse(i);
            LoadHouseVisual(i, true);
        }
    }
    return 1;
}

CMD:sellhouse(playerid, params[])
{
    for(new i = 0; i < MAX_HOUSES; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 1.5, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]) && GetPlayerInterior(playerid) == HouseInfo[i][hOutsideInt] && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hOutsideVir])
        {
            if(!strcmp(HouseInfo[i][hOwner], GetpName(playerid), false))
            {
                strmid(HouseInfo[i][hOwner], "For Sale", 0, false, 8);
                HouseInfo[i][hOwned] = false;
                GivePlayerMoney(playerid, HouseInfo[i][hPrice]/2);
                SendClientMessage(playerid, COLOR_LIGHTGREEN, "*** House sold! ***");
                SaveHouse(i);
                LoadHouseVisual(i, true);
                return 1;
            }
        }
    }
    return 1;
}
and one more question why everytime when i join i always get

Code:
House for sale
Price: $(The Price)
before spawning.

here is the code

pawn Code:
public UpdatePlayersHouseInfo()
{
    new str[100];
    foreach(Player, i)
    {
        for(new j = 0; j < MAX_HOUSES; j++)
        {
            if(IsPlayerInRangeOfPoint(j, 1.0, HouseInfo[j][hEnterX], HouseInfo[j][hEnterY], HouseInfo[j][hEnterZ]) && GetPlayerInterior(i) == HouseInfo[j][hOutsideInt] && GetPlayerVirtualWorld(i) == HouseInfo[j][hOutsideVir]) //You already know this! If you don't know it, do step 3 again!
            {
                if(HouseInfo[j][hOwned])
                    format(str, sizeof(str), "~w~House owned by: ~r~%s", HouseInfo[j][hOwner]);
                else
                    format(str, sizeof(str), "~g~House for sale!~n~~w~Price: ~g~$%d", HouseInfo[j][hPrice]);
                GameTextForPlayer(i, str, 3000, 3);
            }
        }
    }
    return 1;
}
Reply
#2

BUMP
Reply
#3

Okay the pickups are destroyed here.
pawn Code:
LoadHouseVisual(houseid, bool:reload = false)
{
    if(reload)
    {
        DestroyDynamicMapIcon(HouseInfo[houseid][hIcon]);
        DestroyDynamicPickup(HouseInfo[houseid][hPickup]);
    }
}

But where are the pickups created You're missing that i guess. Let me rethink over this.
Reply
#4

BUMP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)