Property Creation Bug
#1

Hey guys. I'm working on a property system I have everything working apart from when I create a property using /createprop it works fine until server restart. When creating a property once the property is finished creating is should display "For Sale: $[Price]" which it is. However after the restart it displays "Owner: " by the icon itself is still green. This explanation is a little bit confusing. Here are two pictures one before restart and after.

BEFORE:


AFTER:


I know the issue is
PHP код:
    INI_WriteString(File"Owner"str2);
    
hInfo[hCount][Owner] = str2
This is in my /createprop command. But I'm just not sure how I'm supposed to fix this.
Here is my whole /createprop command.
PHP код:
CMD:createprop(playeridparams[])
{
    new 
Floatpos[3], string[100], str2[MAX_PLAYER_NAME], price,temp2;
    
GetPlayerPos(playeridpos[0], pos[1], pos[2]);
    if(
PlayerInfo[playerid][pAdmin] < 4) return 0;
    if(
sscanf(params"i"price)) return SendClientMessage(playerid, -1"Usage: /createprop [Price]");
    
format(str2sizeof(str2), "server"); // to avoid array error -- size is MAX_PLAYER_NAME, as is "Owner"
    
IncreasehCount();
    new 
INI:File INI_Open(HousePath(hCount));
    
INI_SetTag(File"House Data");
    
INI_WriteString(File"Owner"str2);
    
hInfo[hCount][Owner] = str2;
    
INI_WriteInt(File"Price"price);
    
hInfo[hCount][Price] = price;
    
INI_WriteInt(File"Bought"0);
    
hInfo[hCount][Bought] = 0;
    
INI_WriteFloat(File"ExtX"pos[0]);
    
hInfo[hCount][ExtX] = pos[0];
    
INI_WriteFloat(File"ExtY"pos[1]);
    
hInfo[hCount][ExtY] = pos[1];
    
INI_WriteFloat(File"ExtZ"pos[2]);
    
hInfo[hCount][ExtZ] = pos[2];
    
INI_WriteFloat(File"IntX"0.0);
    
hInfo[hCount][IntX] = 0.0;
    
INI_WriteFloat(File"IntY"0.0);
    
hInfo[hCount][IntX] = 0.0;
    
INI_WriteFloat(File"IntZ"0.0);
    
hInfo[hCount][IntX] = 0.0;
    
INI_WriteInt(File"IntWorld"2);
    
hInfo[hCount][IntInterior] = 2;
    
INI_WriteInt(File"IntVW"0);
    
hInfo[hCount][IntVirtualW] = random(250);
    
INI_WriteInt(File"VW"GetPlayerVirtualWorld(playerid));
    
hInfo[hCount][World] = GetPlayerVirtualWorld(playerid);
    
INI_WriteInt(File"World"GetPlayerInterior(playerid));
    
hInfo[hCount][Interior] = GetPlayerInterior(playerid);
    
INI_WriteInt(File"Locked"0);
    
hInfo[hCount][Locked] = 0;
    
INI_WriteInt(File"Initialised"0);
    
hInfo[hCount][Initialised] = 0;
    
INI_Close(File);
    
format(stringsizeof(string), "For Sale:\nPrice: $%d",hInfo[hCount][Price]);
    
hInfo[hCount][Label] = Create3DTextLabel(string0xFFFFFFFFpos[0], pos[1], pos[2], 10.0GetPlayerVirtualWorld(playerid), 1);
    
hInfo[hCount][Pickup]=CreatePickup(1273,1,pos[0], pos[1], pos[2],GetPlayerVirtualWorld(playerid));
    
hInfo[hCount][mapIcon]=CreateDynamicMapIcon (hInfo[hCount][ExtX], hInfo[hCount][ExtY], hInfo[hCount][ExtZ],31,0, -10, -1600.0);
    
format(string,sizeof(string),"{You have created a house(%d) at your position! Use /setpropint to set it's interior!",hCount);
    
SendClientMessage(playeridCOLOR_ADMINstring);
    
temp2=CreateDynamicSphere(hInfo[hCount][ExtX], hInfo[hCount][ExtY], hInfo[hCount][ExtZ],1.3,-1,-1,-1);
    
areatype[temp2][0]=AREA_TYPE_PROP;
    
areatype[temp2][1]=hCount;
    
format(string,sizeof(string),"[Admin Log]: %s has created a property(%d)",GetName(playerid),hCount);
    
ABroadCast(COLOR_ADMIN,string,1);
    for (new 
0MAX_PLAYERSi++)
    {
        if (
IsPlayerInRangeOfPoint(i300.0hInfo[hCount][ExtX], hInfo[hCount][ExtY], hInfo[hCount][ExtZ])) Streamer_Update(i);
    }
    
SaveHouses();
    return 
true;

This is what my buy command is just to compare.
PHP код:
CMD:buyprop(playeridparams[])
{
    new 
string[80], name[MAX_PLAYER_NAME],tmp[256];
    
GetPlayerName(playeridnamesizeof(name));
    if (
areatype[playerarea[playerid]][0] != AREA_TYPE_PROP) return SendClientMessage(playeridCOLOR_RED"Error: You must be at a property to buy it!");
    if(
PlayerInfo[playerid][HouseOwner] != 0)
    {
        if (
areatype[playerarea[playerid]][1] == PlayerInfo[playerid][HouseOwner]) SendClientMessage(playeridCOLOR_YELLOW"You already own this property.");
        else 
SendClientMessage(playeridCOLOR_RED"You can only own one property at a time. Sell your current property first!");
        return 
1;
    }
    if (
strcmp(hInfo[areatype[playerarea[playerid]][1]][Owner], "server"false) != 0) return SendClientFormattedMessage(playeridCOLOR_RED"This property belongs to %s and cannot be bought!"hInfo[areatype[playerarea[playerid]][1]][Owner], "");
    if(
PlayerInfo[playerid][pCash] < hInfo[areatype[playerarea[playerid]][1]][Price])
    {
        
format(string128"You don't have $%d and cannot buy this property!"hInfo[areatype[playerarea[playerid]][1]][Price]);
        
SendClientMessage(playeridCOLOR_REDstring);
        return 
1;
    }
    
GivePlayerMoney(playerid, -hInfo[areatype[playerarea[playerid]][1]][Price]);
    
hInfo[areatype[playerarea[playerid]][1]][Owner] = name;
    
hInfo[areatype[playerarea[playerid]][1]][Bought] = 1;
    
PlayerInfo[playerid][HouseOwner] = areatype[playerarea[playerid]][1];
    
DestroyPickup(hInfo[areatype[playerarea[playerid]][1]][Pickup]);
    
DestroyDynamicMapIcon(hInfo[areatype[playerarea[playerid]][1]][mapIcon]);
    
hInfo[areatype[playerarea[playerid]][1]][Pickup] = CreatePickup(12721hInfo[areatype[playerarea[playerid]][1]][ExtX], hInfo[areatype[playerarea[playerid]][1]][ExtY], hInfo[areatype[playerarea[playerid]][1]][ExtZ], -1);
    
hInfo[areatype[playerarea[playerid]][1]][mapIcon] = CreateDynamicMapIcon(hInfo[areatype[playerarea[playerid]][1]][ExtX], hInfo[areatype[playerarea[playerid]][1]][ExtY], hInfo[areatype[playerarea[playerid]][1]][ExtZ], 320, -10, -1600.0);
    
format(tmp32"Owner: %s"name);
    
Update3DTextLabelText(hInfo[areatype[playerarea[playerid]][1]][Label], 0x006699EEtmp);
    for (new 
0MAX_PLAYERSi++)
    {
        if (
IsPlayerInRangeOfPoint(i300.0hInfo[areatype[playerarea[playerid]][1]][ExtX], hInfo[areatype[playerarea[playerid]][1]][ExtY], hInfo[areatype[playerarea[playerid]][1]][ExtZ])) Streamer_Update(i);
    }
    
format(string128"You have bought this property for $%d. Welcome to your new home."hInfo[areatype[playerarea[playerid]][1]][Price]);
    
SendClientMessage(playeridCOLOR_GREENstring);
    
GameTextForPlayer(playerid"~g~~h~~h~Property bought!"50003);
    
SaveHouses();
    return 
true;

I've tried changing
PHP код:
INI_WriteString(File"Owner"str2);
    
hInfo[hCount][Owner] = str2
To equal server however it still goes around says "Owner: server". I think I need to set Owner to 0. However I can't because it's a string? Please advise some help as it's much appreciated.
Reply
#2

Bump
Reply
#3

Are you loading the data correctly? Is the data saved correctly in the file? Adding a few prints across the script will give you more insight in what exactly happens.

I'm sorry, I didn't quite read all the code, but I'm assuming it's you loading the data incorrectly as it only occurs after a server restart (I'm assuming).

Also, if you bump into these kind of problems with such large functions, it's never bad to write comments and add debug messages. It helps you visualize the program's flow. Especially when you've got multidimensional arrays into multidimensional arrays. It's easy to fuck them up.
Reply
#4

Yes. I'm like 95% sure everything loads fine. It's the fact that the server is thinking that the Owner is blank. Rather than for sale.
Reply
#5

Quote:
Originally Posted by Tass007
Посмотреть сообщение
Yes. I'm like 95% sure everything loads fine. It's the fact that the server is thinking that the Owner is blank. Rather than for sale.
Which makes me believe your loading is indeed flawed. Could you show me the code where you load the whole thing?
Reply
#6

Thanks for your offer of help. But I managed to fix it. It was the fact that when Brought was == 0 it displayed owner. Not for sale.
Reply
#7

Quote:
Originally Posted by Tass007
Посмотреть сообщение
Thanks for your offer of help. But I managed to fix it. It was the fact that when Brought was == 0 it displayed owner. Not for sale.
Good on you. Well done!
Reply
#8

Thanks
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)