[Cueball's Zone System] House Pickup text not displaying full string
#1

I am using Cueball's Zone System, and the text above a house pickup (I made the house system) says (well, part of it says) "1 Blueberr" when it should say something like "1 Blueberry".

Here is a screenshot:


The script has no errors and no warnings.

Here is the part of the code that has the house system:
pawn Код:
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;
}
Any help?
Reply
#2

Are you sure that all variables for example "HouseAddress" are in the right size?
Reply
#3

pawn Код:
enum HouseInfo
{
    HouseAddress[256]//try increasing the size if you add more text or hex code
}
hInfo[MAX_HOUSES][HouseInfo];


hInfo[HouseID][HouseAddress]
Reply
#4

(This is to both of you) I'm going to try increasing the string limit for HouseAddress. 40 was the original limit.

(Off topic: btw PDS, why haven't you accepted me on Skype?)

EDIT: Didn't work, still says "Blueberr"
Reply
#5

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
Reply
#6

Quote:
Originally Posted by iJumbo
Посмотреть сообщение
Are you sure that all variables for example "HouseAddress" are in the right size?
Quote:
Originally Posted by pds2k12
Посмотреть сообщение
pawn Код:
enum HouseInfo
{
    HouseAddress[256]//try increasing the size if you add more text or hex code
}
hInfo[MAX_HOUSES][HouseInfo];


hInfo[HouseID][HouseAddress]
Quote:
Originally Posted by iJumbo
Посмотреть сообщение
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
That was kind of off-topic, but none of these solutions are working.
Reply
#7

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.
Reply
#8

Quote:
Originally Posted by DeStunter
Посмотреть сообщение
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.
Reply
#9

Quote:
Originally Posted by stormchaser206
Посмотреть сообщение
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; to GetPlayer2DZone(playerid, Location, 35); or GetPlayer2DZone(playerid, Location, sizeof(Location));
Reply
#10

Quote:
Originally Posted by DeStunter
Посмотреть сообщение
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; to GetPlayer2DZone(playerid, Location, 35); or GetPlayer2DZone(playerid, Location, sizeof(Location));
1. There is no load function, it just saves the house to file. I haven't added a load system yet.
2. I changed that to 35 after I figured out it wasn't working. They were originally both 28. But I can still try, as I haven't used that combination yet.

Edit: I figured the bug out myself, it was with strmid. I just changed it to format. But while doing that, I created another bug in the process. The pickup doesn't show, but the text label (fixed) does.

New code:
pawn Код:
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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)