02.08.2016, 06:53
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
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.
This is what my buy command is just to compare.
I've tried changing
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.
BEFORE:
AFTER:
I know the issue is
PHP код:
INI_WriteString(File, "Owner", str2);
hInfo[hCount][Owner] = str2;
Here is my whole /createprop command.
PHP код:
CMD:createprop(playerid, params[])
{
new Float: pos[3], string[100], str2[MAX_PLAYER_NAME], price,temp2;
GetPlayerPos(playerid, pos[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(str2, sizeof(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(string, sizeof(string), "For Sale:\nPrice: $%d",hInfo[hCount][Price]);
hInfo[hCount][Label] = Create3DTextLabel(string, 0xFFFFFFFF, pos[0], pos[1], pos[2], 10.0, GetPlayerVirtualWorld(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, -1, 0, -1, 600.0);
format(string,sizeof(string),"{You have created a house(%d) at your position! Use /setpropint to set it's interior!",hCount);
SendClientMessage(playerid, COLOR_ADMIN, string);
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 i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerInRangeOfPoint(i, 300.0, hInfo[hCount][ExtX], hInfo[hCount][ExtY], hInfo[hCount][ExtZ])) Streamer_Update(i);
}
SaveHouses();
return true;
}
PHP код:
CMD:buyprop(playerid, params[])
{
new string[80], name[MAX_PLAYER_NAME],tmp[256];
GetPlayerName(playerid, name, sizeof(name));
if (areatype[playerarea[playerid]][0] != AREA_TYPE_PROP) return SendClientMessage(playerid, COLOR_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(playerid, COLOR_YELLOW, "You already own this property.");
else SendClientMessage(playerid, COLOR_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(playerid, COLOR_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(string, 128, "You don't have $%d and cannot buy this property!", hInfo[areatype[playerarea[playerid]][1]][Price]);
SendClientMessage(playerid, COLOR_RED, string);
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(1272, 1, hInfo[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], 32, 0, -1, 0, -1, 600.0);
format(tmp, 32, "Owner: %s", name);
Update3DTextLabelText(hInfo[areatype[playerarea[playerid]][1]][Label], 0x006699EE, tmp);
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerInRangeOfPoint(i, 300.0, hInfo[areatype[playerarea[playerid]][1]][ExtX], hInfo[areatype[playerarea[playerid]][1]][ExtY], hInfo[areatype[playerarea[playerid]][1]][ExtZ])) Streamer_Update(i);
}
format(string, 128, "You have bought this property for $%d. Welcome to your new home.", hInfo[areatype[playerarea[playerid]][1]][Price]);
SendClientMessage(playerid, COLOR_GREEN, string);
GameTextForPlayer(playerid, "~g~~h~~h~Property bought!", 5000, 3);
SaveHouses();
return true;
}
PHP код:
INI_WriteString(File, "Owner", str2);
hInfo[hCount][Owner] = str2;