Coordinates bug
#1

I tried to make a biz and house system but when ever i create a biz or house the and i restart the gamemode it moves the house to blueberry acre (Bug) not this is my coding for saving the house
PHP код:
stock SaveHouses()
{
    if(!
fexist("ODA/houses.cfg")) fcreate("ODA/houses.cfg");
    new 
idx 1File:file;
    new 
string[256];
    while(
idx MAX_HOUSES)
    {
        
format(stringsizeof(string), "%d || %d || %d || %s || %f || %f || %f || %d ||\r\n",HouseInfo[idx][hLevel],HouseInfo[idx][hPrice],HouseInfo[idx][hStatus],HouseInfo[idx][hOwner],HouseInfo[idx][hX],HouseInfo[idx][hY],HouseInfo[idx][hZ],HouseInfo[idx][hMoney]);
        if(
idx == 1)
        {
            
file fopen("ODA/houses.cfg"io_write);
        }
        else
        {
            
file fopen("ODA/houses.cfg"io_append);
        }
        
fwrite(filestring);
        
fclose(file);
        
idx++;
    }
    print(
"Houses saved successfully.");

PHP код:
2347.128662 || -1264.981079 || 27.976562 //This is the bugged coordinates that it gives
//and this is the coordinate i created the biz at
2347.1917,-1265.0759,27.9766 //this is where the biz should be create when i restart the server. 
Now as you can see its a bit similar to the correct spot but i want to know why its giving me this. I will be online and waiting for replies and ask for any piece of coding i will post it immediately
Reply
#2

what about posting your house load script ?

and that pace which saves HouseInfo[idx][hX] Y & Z
Reply
#3

I'm not sure what to say, first of, who even uses this method to save and load shit dynamically anymore? I'm sorry but please update your system to atlest something like SQL.
Reply
#4

PHP код:
stock LoadHouses()
{
    new 
hinfo[21][32];
    new 
string[256];
    new 
File:file fopen("ODA/houses.cfg"io_read);
    if(
file)
    {
        new 
idx 1;
        while(
idx MAX_HOUSES)
        {
            
fread(filestring);
            
split(stringhinfo'|');
            
HouseInfo[idx][hLevel] = strval(hinfo[0]);
            
HouseInfo[idx][hPrice] = strval(hinfo[1]);
            
HouseInfo[idx][hStatus] = strval(hinfo[2]);
            
format(HouseInfo[idx][hOwner], 32"%s"hinfo[3]);
            
HouseInfo[idx][hX] = floatstr(hinfo[4]);
            
HouseInfo[idx][hY] = floatstr(hinfo[5]);
            
HouseInfo[idx][hZ] = floatstr(hinfo[6]);
            
HouseInfo[idx][hMoney] = strval(hinfo[7]);
            if(
HouseInfo[idx][hLevel])
            {
                
HouseInfo[idx][hPickup] = CreateDynamicPickup(12731HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ], 0);
                if(!
strcmp("The State"HouseInfo[idx][hOwner])) format(stringsizeof(string), "[House ID: %d, House (Lvl: %d)]\n Owner: %s\n Status: For Sale\n$%d"idxHouseInfo[idx][hLevel], HouseInfo[idx][hOwner], HouseInfo[idx][hPrice]);
                else 
format(stringsizeof(string), "[House ID: %d, House (Lvl: %d)]\n Owner: %s\n Status: %s"idxHouseInfo[idx][hLevel], HouseInfo[idx][hOwner], RHS(idx));
                
HouseInfo[idx][hText] = CreateDynamic3DTextLabel(string, -1HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]+0.315);

            }
            
idx++;
        }
    }
    print(
"Houses loaded successfully.");
    return 
1;

@Meller
Well sorry to inform you but i use what i can manage... Doesn't make sense for me to be posting for help everyday cause i dont know shit about SQL
Reply
#5

The problem is that the hinfo variable have to be a float variable.

Create a sperate variable for the coordinates anderen load them seperatly.
Reply
#6

Quote:
Originally Posted by GangstaSunny.
Посмотреть сообщение
The problem is that the hinfo variable have to be a float variable.

Create a sperate variable for the coordinates anderen load them seperatly.
I dont understand what you mean could you show me an example
Reply
#7

Quote:
Originally Posted by GangstaSunny.
Посмотреть сообщение
The problem is that the hinfo variable have to be a float variable.

Create a sperate variable for the coordinates anderen load them seperatly.
oh a pro scripter is here ohhhhaaa faul digga wasssssss
Reply
#8

Quote:
Originally Posted by 1fret
Посмотреть сообщение
I dont understand what you mean could you show me an example
give us that enumation you use for Hause info >> HouseInfo[idx][hZ]

you have to set them as Float:hZ
Reply
#9

Well your question why the value of the variable is different to your​ saved position is easy.

Use %.2f to have only 2 decimal values in your var.

Just to answer your question btw.
Reply
#10

I think your problem is that you save everything with two slashes "a || b || c"
But load with one slash, resulting in hInfo[][] = {"a ", "", " b ", "", " c"} (every even index is empty)
It's just a guess but you could print you the values of hInfo to check
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)