Server crash when loading houses
#1

Since this is a more appropriate location to post script problems, I've decided to post it here.

Anyways! After using this script for a long time now, it suddenly crashes which makes no sense at all.
Code:
pawn Code:
stock AddHousesFromSQL()
{
    new Str[300], string[128];
    mysql_query("SELECT * FROM houses");
    mysql_store_result();
    new hTotal = mysql_num_rows(); //hTotal amount of houses in mysql database
    if(hTotal > 0) //1+ house.
    {
        while(mysql_fetch_row(Str))
        {
            new HID,Float:eX,Float:eY,Float:eZ,Float:iX,Float:iY,Float:iZ,OwnedBy[24],Location[128],Price,Interior,Slots,ForSale,Locked,DefaultPrice;
            sscanf(Str, "p<|>ds[24]s[128]dddffffffddd", HID,OwnedBy,Location,DefaultPrice,Price,Interior,iX,iY,iZ,eX,eY,eZ,Slots,ForSale,Locked);
            if(!strcmp(OwnedBy, "None"))
            {
                HInfo[HID][hMapIcon] = CreateDynamicMapIcon(eX, eY, eZ, 31, 0);
                HInfo[HID][hPickupID] = CreatePickup(1273, 23, eX, eY, eZ, 0);
                format(string,sizeof(string),"House Value: "WHITE"$%d\n"MAIN_COLOR"Vehicle Slots: "WHITE"%d\n/buyhouse to purchase.", DefaultPrice, Slots);
                HInfo[HID][hHouseText] = Create3DTextLabel(string, COLOR_MAIN, eX, eY, eZ, 50.0, 0, 1);
            }
            else if(ForSale == 1)
            {
                HInfo[HID][hMapIcon] = CreateDynamicMapIcon(eX, eY, eZ, 31, 0);
                HInfo[HID][hPickupID] = CreatePickup(1273, 23, eX, eY, eZ, 0);
                format(string,sizeof(string),"For Sale:\n"MAIN_COLOR"%s's"WHITE" House\n"MAIN_COLOR"Value:"WHITE"$%d\n"MAIN_COLOR"Asking Price: "WHITE"%d\n"MAIN_COLOR"Vehicle Slots:"WHITE" %d\n/buyhouse to purchase.", OwnedBy, DefaultPrice, Price, Slots);
                HInfo[HID][hHouseText] = Create3DTextLabel(string, COLOR_MAIN, eX, eY, eZ, 50.0, 0, 1);
            }
            else
            {
                HInfo[HID][hMapIcon] = CreateDynamicMapIcon(eX, eY, eZ, 32, 0);
                HInfo[HID][hPickupID] = CreatePickup(1272, 23, eX, eY, eZ, 0);
                format(string,sizeof(string),"Location: "WHITE"%s\n"MAIN_COLOR"Owner: "WHITE"%s\n"MAIN_COLOR"Vehicle Slots: "WHITE"%d", Location, OwnedBy, Slots);
                HInfo[HID][hHouseText] = Create3DTextLabel(string, COLOR_MAIN, eX, eY, eZ, 50.0, 0, 1);
            }
            format(string,sizeof(string),"%s",OwnedBy);
            strmid(HInfo[HID][hOwnedBy], string, 0, strlen(string), 128);
            format(string,sizeof(string),"%s",Location);
            strmid(HInfo[HID][hLocation], string, 0, strlen(string), 128); //PASSWORD
            HInfo[HID][hPrice] = Price;
            HInfo[HID][hInterior] = Interior;
            HInfo[HID][hiX] = iX;
            HInfo[HID][hiY] = iY;
            HInfo[HID][hiZ] = iZ;
            HInfo[HID][heX] = eX;
            HInfo[HID][heY] = eY;
            HInfo[HID][heZ] = eZ;
            HInfo[HID][hSlots] = Slots;
            HInfo[HID][hForSale] = ForSale;
            HInfo[HID][hLocked] = Locked;
            HInfo[HID][hDefaultPrice] = DefaultPrice;
            HInfo[HID][hHouseID] = HID;
        }
    }
    mysql_free_result();
}
Reply


Messages In This Thread
Server crash when loading houses - by Jimmy0wns - 11.10.2014, 20:29
Re: Server crash when loading houses - by Jimmy0wns - 11.10.2014, 21:24
Re: Server crash when loading houses - by ThePhenix - 11.10.2014, 21:33

Forum Jump:


Users browsing this thread: 1 Guest(s)