Help my my mysql addhouse script [New problem, need to fix this fast]
#1

EDIT: I fixed the tag mismtach prob, now i'm getting different. I edited the opening post.

Okay so I finished my mysql addhouse script. But I'm having problems.

Variables:
pawn Код:
new HousePickup[MAX_HOUSES];

enum HouseData
{
    Name[24],
    Rentable,
    RentCost,
    Cost,
    Sell,
    Interior,
    VirtualWorld,
    Locked,
    Float:InteriorX,
    Float:InteriorY,
    Float:InteriorZ,
    Float:IconX,
    Float:IconY,
    Float:IconZ
}
new HouseInfo[MAX_HOUSES][HouseData];
The one addhouse line I'm using currently.
pawn Код:
AddHouse(1,1258.4746,-785.3508,92.0302,1263.0800,-785.3090,1091.9063, 100, 100, 5, 1);
The actual function
pawn Код:
AddHouse(houseid, Float:iconX, Float:iconY, Float:iconZ, Float:interiorX, Float:interiorY, Float:interiorZ, cost, sell, interior, virtualworld)
{
    new query[128];
    format(query, sizeof(query), "SELECT * FROM houses WHERE houseid = %d", houseid);
    mysql_query(query);
    mysql_store_result();

    if(mysql_num_rows() == 0)
    {
      new query2[1024];
    format(query2, sizeof(query2), "INSERT INTO houses (houseid, name, rentable, rentcost, cost, sell, interior, virtualworld, locked, X, Y, Z) VALUES (%d, 'ForSale', 0, 0, %d, %d, %d, %d, 1, %f, %f, %f)", houseid, cost, sell, interior, virtualworld, interiorX, interiorY, interiorZ);
        mysql_query(query);
        format(HouseInfo[houseid][Name], 24, "ForSale");
        HouseInfo[houseid][Rentable] = 0;
        HouseInfo[houseid][RentCost] = 0;
        HouseInfo[houseid][Cost] = cost;
        HouseInfo[houseid][Sell] = sell;
        HouseInfo[houseid][Interior] = interior;
        HouseInfo[houseid][VirtualWorld] = virtualworld;
        HouseInfo[houseid][Locked] = 1;
        HouseInfo[houseid][InteriorX] = interiorX;
        HouseInfo[houseid][InteriorY] = interiorY;
        HouseInfo[houseid][InteriorZ] = interiorZ;
    }
    if(mysql_num_rows() == 1)
    {
        new row[1024], name[24], rentable[2], rentcost[6], locked[2];
        mysql_fetch_row(row);
        mysql_fetch_field_row(name, "name");
        format(HouseInfo[houseid][Name], 24, "%s", name);
        mysql_fetch_field_row(rentable, "rentable");
        HouseInfo[houseid][Rentable] = strval(rentable);
        mysql_fetch_field_row(rentcost, "rentcost");
        HouseInfo[houseid][RentCost] = strval(rentcost);
        HouseInfo[houseid][Cost] = cost;
        HouseInfo[houseid][Sell] = sell;
        HouseInfo[houseid][Interior] = interior;
        HouseInfo[houseid][VirtualWorld] = virtualworld;
        mysql_fetch_field_row(locked, "locked");
        HouseInfo[houseid][Locked] = strval(locked);
        HouseInfo[houseid][InteriorX] = interiorX;
        HouseInfo[houseid][InteriorY] = interiorY;
        HouseInfo[houseid][InteriorZ] = interiorZ;
    }
    HouseInfo[houseid][IconX] = iconX;
    HouseInfo[houseid][IconY] = iconY;
    HouseInfo[houseid][IconZ] = iconZ;
    if(strcmp(HouseInfo[houseid][Name],"ForSale",true)==0)
    {
        HousePickup[houseid] = CreatePickup(1273, 2, iconX, iconY, iconZ);
    }
    else
    {
        HousePickup[houseid] = CreatePickup(1272, 2, iconX, iconY, iconZ);
    }
}
Ugh. This is really starting to make me pissed off. lol. Somehow the variables seem to have really messed up values. I try debugging by making a function HouseDebug and put it under onplayerpickuppickup instead of the normal functions so I could debug it.

Here is my function
pawn Код:
HouseDebug(playerid, pickupid)
{
  for(new i=0;i<MAX_HOUSES;i++)
    {
      if(HousePickup[i] == pickupid)
      {
            new s1[32], s2[32], s3[32], s4[32], s5[32], s6[32], s7[32], s8[32];
            format(s1, 32, "%d", i);
            format(s2, 32, "%s", HouseInfo[i][Name]);
            format(s3, 32, "%d", HouseInfo[i][Cost]);
            format(s4, 32, "%d", HouseInfo[i][Rentable]);
            format(s5, 32, "%d", HouseInfo[i][RentCost]);
            format(s6, 32, "%d", HouseInfo[i][Sell]);
            format(s7, 32, "%f", HouseInfo[i][IconX]);
            format(s8, 32, "%f", HouseInfo[i][InteriorX]);
            SendClientMessage(playerid, RED, s1);
            SendClientMessage(playerid, RED, s2);
            SendClientMessage(playerid, RED, s3);
            SendClientMessage(playerid, RED, s4);
            SendClientMessage(playerid, RED, s5);
            SendClientMessage(playerid, RED, s6);
            SendClientMessage(playerid, RED, s7);
            SendClientMessage(playerid, RED, s8);
        }
    }
    return 1;
}
The output is crazy..

I grab the pickup and my chat gets flooded like..

100
0
0
0
0
9
0
0
3
0
0
etc.. It doesn't go on and on, it stops within a second and I can see it does contain the values that the variables are suppose to have ex. 100 for the house cost but something is really messed up.

Same code is used as the first post + that is the debug function

I'm really in need of help..

PS. Everything in the mysql db looks like it gets inserted fine. All the data looks good and I made sure all my datatypes for structure are good.
Reply
#2

Quote:
Originally Posted by Seif_ [adream-rp.com
]
It's not "float:" it's "Float:", capitalize the F.
Thanks that fixed the warnings.

Now I'm having a different problem though.. It doesn't insert anything into the mysql DB. The query works fine because I tested it by copy and pasting it into phpmyadmin, I dunno what is wrong.. Anybody have any ideas?

EDIT: Nevermind I think I figured it out.
Reply
#3

Ugh. This is really starting to make me pissed off. lol. Somehow the variables seem to have really messed up values. I try debugging by making a function HouseDebug and put it under onplayerpickuppickup instead of the normal functions so I could debug it.

Here is my function
pawn Код:
HouseDebug(playerid, pickupid)
{
  for(new i=0;i<MAX_HOUSES;i++)
    {
      if(HousePickup[i] == pickupid)
      {
            new s1[32], s2[32], s3[32], s4[32], s5[32], s6[32], s7[32], s8[32];
            format(s1, 32, "%d", i);
            format(s2, 32, "%s", HouseInfo[i][Name]);
            format(s3, 32, "%d", HouseInfo[i][Cost]);
            format(s4, 32, "%d", HouseInfo[i][Rentable]);
            format(s5, 32, "%d", HouseInfo[i][RentCost]);
            format(s6, 32, "%d", HouseInfo[i][Sell]);
            format(s7, 32, "%f", HouseInfo[i][IconX]);
            format(s8, 32, "%f", HouseInfo[i][InteriorX]);
            SendClientMessage(playerid, RED, s1);
            SendClientMessage(playerid, RED, s2);
            SendClientMessage(playerid, RED, s3);
            SendClientMessage(playerid, RED, s4);
            SendClientMessage(playerid, RED, s5);
            SendClientMessage(playerid, RED, s6);
            SendClientMessage(playerid, RED, s7);
            SendClientMessage(playerid, RED, s8);
        }
    }
    return 1;
}
The output is crazy..

I grab the pickup and my chat gets flooded like..

100
0
0
0
0
9
0
0
3
0
0
etc.. It doesn't go on and on, it stops within a second and I can see it does contain the values that the variables are suppose to have ex. 100 for the house cost but something is really messed up.

Same code is used as the first post + that is the debug function

I'm really in need of help..
Reply
#4

bump.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)