OnPlayerPickUpPickup problem / House system.
#1

When ever i go onto the icon / pickup, it gives out false stuff.
Here's the code;
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
    {
        //new hid = PlayerInfo[playerid][HouseID];
        new string[98];
        for(new i = 1; i < MAX_HOUSES; i++)
        {
            if(i == pickupid) break;
            {
                if(HouseInfo[i][Owned])
                {
                    if(strcmp(GetName(playerid), HouseInfo[i][Owner], true))
                    {
                        new price = HouseInfo[pickupid][Price];
                        new percent = SELLPERCENT*price/100;
                        SendClientMessage(playerid, COLOR_NOTES, "[INFO] This is your house! You can enter it by pressing 'F'.");
                        format(string, sizeof(string), "[INFO] You can sell this house for %d$.", percent), SendClientMessage(playerid, COLOR_NOTES, string);
                        return 1;
                    }
                    else
                    {
                        format(string, sizeof(string), "[INFO] This house is owned by %s. If it's not locked, you can enter it by pressing 'F'", HouseInfo[i][Owner]);
                        SendClientMessage(playerid, COLOR_NOTES, string);
                        return 1;
                    }
                }
                else
                {
                    format(string, sizeof(string), "[INFO] This house is not owned, you can buy it for %d$, and enter it by pressing 'F'", HouseInfo[i][Price]);
                    SendClientMessage(playerid, COLOR_NOTES, string);
                    return 1;
                }
            }
        }
        return 1;
    }
I've been struggling with this for a quite a while now, and I still haven't figured out a way on how to fix this.
I've tried using the "pickupid", but then it didn't work at all.

It always says "This house is owned by *YourName, or someones else name here* ....", even though the house is not owned ( reloaded fs, created new houses etc.., still says that it's owned by me or someone else.. )
Reply
#2

You must asign ids to your pickups.

Example:
pawn Код:
new HousePickup[MAX_HOUSES];
HousePickup[houseid] = CreatePickup(model, 1, x, y, z);
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    for(new i = 1; i < MAX_HOUSES; i++)
    {
        if(pickupid == HousePickup[i])
        {
            // House id found.
        }
    }
}
Reply
#3

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
You must asign ids to your pickups.

Example:
pawn Код:
new HousePickup[MAX_HOUSES];
HousePickup[houseid] = CreatePickup(model, 1, x, y, z);
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    for(new i = 1; i < MAX_HOUSES; i++)
    {
        if(pickupid == HousePickup[i])
        {
            // House id found.
        }
    }
}
Well, i use this -
pawn Код:
if(HouseInfo[houseid][Owned]) HouseInfo[houseid][PickupID] = CreateDynamicPickup(1272, 23, HouseInfo[houseid][ExitX], HouseInfo[houseid][ExitY], HouseInfo[houseid][ExitZ], 0, 0, -1, 40.0);
else HouseInfo[houseid][PickupID] = CreateDynamicPickup(1273, 23, HouseInfo[houseid][ExitX], HouseInfo[houseid][ExitY], HouseInfo[houseid][ExitZ], 0, 0, -1, 40.0);
Reply
#4

There is no need to save the pickup in the file, but anyways:
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    for(new i = 1; i < MAX_HOUSES; i++)
    {
        if(pickupid == HouseInfo[i][PickupID])
        {
            // House id found.
        }
    }
}
Reply
#5

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
There is no need to save the pickup in the file, but anyways:
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    for(new i = 1; i < MAX_HOUSES; i++)
    {
        if(pickupid == HouseInfo[i][PickupID])
        {
            // House id found.
        }
    }
}
Still the same problem..
Reply
#6

Try this:

pawn Код:
new HousePickup[MAX_HOUSES];
HousePickup[houseid] = CreatePickup(model, 1, x, y, z);
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    for(new i = 1; i < MAX_HOUSES; i++)
    {
        if(pickupid == HousePickup[i])
        {
            // House id found.
        }
    }
}
Reply
#7

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Try this:

pawn Код:
new HousePickup[MAX_HOUSES];
HousePickup[houseid] = CreatePickup(model, 1, x, y, z);
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    for(new i = 1; i < MAX_HOUSES; i++)
    {
        if(pickupid == HousePickup[i])
        {
            // House id found.
        }
    }
}
Wouldn't that kinda be the same thing? :d
Reply
#8

I guess, but my house system works like that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)