CMD:createhouse(playerid, params[])
{
new price;
new HouseID = HouseCount;
new Location[35];
new string[256];
new AddressID;
if(sscanf(params, "i", price))
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /createhouse [Price]");
return 1;
}
else
{
if(pInfo[playerid][Admin] >= 4)
{
GetPlayer2DZone(playerid, Location, 28);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
hInfo[HouseID][Owned] = false;
strmid(hInfo[HouseID][HouseOwner], "None", 0, strlen("None"), strlen("None"));
hInfo[HouseID][HouseX] = x;
hInfo[HouseID][HouseY] = y;
hInfo[HouseID][HouseZ] = z;
hInfo[HouseID][Price] = price;
hInfo[HouseID][Locked] = true;
hInfo[HouseID][HousePickup] = true;
zInfo[GetPlayer2DZoneID(playerid)][HousesInZone]++;
AddressID = zInfo[GetPlayer2DZoneID(playerid)][HousesInZone];
format(string, sizeof(string), "%d %s", AddressID, Location);
strmid(hInfo[HouseID][HouseAddress], string, 0, strlen(string), strlen(string));
hInfo[HouseID][DoorPickup] = CreateDynamicPickup(1273, 1, x, y, z, -1, 0);
format(string, sizeof(string), "{00FF00}House for Sale\n{00FFFF}$%d\nAddress: %s", price, hInfo[HouseID][HouseAddress]);
hInfo[HouseID][DoorTextID] = CreateDynamic3DTextLabel(string, 0x008080FF, x, y, z + 0.5, 50.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1);
Iter_Add(Houses, HouseID);
format(string, sizeof(string), "-| House ID %d created! |-", HouseID);
SendClientMessage(playerid, COLOR_GREEN, string);
hInfo[HouseID][Buyable] = true;
HouseFileCreate(HouseID);
HouseCount++;
}
else
{
SendClientMessage(playerid, COLOR_RED, "ERROR: You are not a high enough level to use this command.");
}
}
return 1;
}
CMD:delhouse(playerid, params[])
{
new string[128];
new HouseID;
if(pInfo[playerid][Admin] >= 4)
{
foreach(new h : Houses)
{
if(IsValidDynamicPickup(hInfo[h][DoorPickup]))
{
if(IsPlayerInRangeOfPoint(playerid, 2.5, hInfo[h][HouseX], hInfo[h][HouseY], hInfo[h][HouseZ]))
{
format(string, sizeof(string), "-| House ID %d deleted. |-", h);
SendClientMessage(playerid, COLOR_RED, string);
hInfo[h][Owned] = false;
strmid(hInfo[HouseID][HouseName], "Deleted", 0, strlen("Deleted"), strlen("Deleted"));
DestroyDynamicPickup(hInfo[h][DoorPickup]);
HouseFileRemove(h);
DestroyDynamic3DTextLabel(hInfo[h][DoorTextID]);
hInfo[h][Buyable] = false;
Iter_Remove(Houses, h);
zInfo[GetPlayer2DZoneID(playerid)][HousesInZone]--;
return 1;
}
}
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "ERROR: You are not a high enough level to use this command.");
}
return 1;
}
enum HouseInfo
{
HouseAddress[256]//try increasing the size if you add more text or hex code
}
hInfo[MAX_HOUSES][HouseInfo];
hInfo[HouseID][HouseAddress]
Are you sure that all variables for example "HouseAddress" are in the right size?
|
pawn Код:
|
Anyway you are using that https://sampwiki.blast.hk/wiki/Strmid try check this out https://sampwiki.blast.hk/wiki/Strcat maybe fit more your needs
|
Your probably corrected the issue, but the file it writes to store the house in is still probably wrong. Either delete the house, and re-create it, or edit the file manually.
|
I've recreated the house dozens of times. Doesn't work. And there isn't a house load file, and none of the data loads from a file.
|
There is this function in your code -> HouseFileCreate(HouseID);
Which I would guess writes a file with the house details so when your server restarts it can re-load the house. The only other I thing I see is that when you get the 2D zone the string is only 28 bits long. You declared Location as 35 bits so try changing GetPlayer2DZone(playerid, Location, 2 ![]() |
CMD:createhouse(playerid, params[])
{
new price;
new HouseID = HouseCount;
new Location[28];
new string[128];
new AddressID;
if(sscanf(params, "i", price))
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /createhouse [Price]");
return 1;
}
else
{
if(pInfo[playerid][Admin] >= 4)
{
GetPlayer2DZone(playerid, Location, 28);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
hInfo[HouseID][Owned] = false;
format(hInfo[HouseID][HouseOwner], MAX_PLAYER_NAME, "None %d", HouseID);
hInfo[HouseID][HouseX] = x;
hInfo[HouseID][HouseY] = y;
hInfo[HouseID][HouseZ] = z;
hInfo[HouseID][Price] = price;
hInfo[HouseID][Locked] = true;
hInfo[HouseID][HousePickup] = true;
zInfo[GetPlayer2DZoneID(playerid)][HousesInZone]++;
AddressID = zInfo[GetPlayer2DZoneID(playerid)][HousesInZone];
format(hInfo[HouseID][HouseAddress], 48, "%d %s", AddressID, Location);
hInfo[HouseID][DoorPickup] = CreateDynamicPickup(1273, 1, x, y, z, 0);
format(string, sizeof(string), "{00FF00}House for Sale\n{00FFFF}$%d\nAddress: %s", price, hInfo[HouseID][HouseAddress]);
hInfo[HouseID][DoorTextID] = CreateDynamic3DTextLabel(string, 0x008080FF, x, y, z + 0.7, 50.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1);
Iter_Add(Houses, HouseID);
format(string, sizeof(string), "-| House ID %d created! |-", HouseID);
SendClientMessage(playerid, COLOR_GREEN, string);
hInfo[HouseID][Buyable] = true;
HouseFileCreate(HouseID);
HouseCount++;
}
else
{
SendClientMessage(playerid, COLOR_RED, "ERROR: You are not a high enough level to use this command.");
}
}
return 1;
}