02.05.2013, 09:22
As the title says, the whole server crashes when this code is being executed, although there are no problems with compiling it.
Anyone know why this is happening? Maybe because the function is being called too much?
Anyone know why this is happening? Maybe because the function is being called too much?
pawn Код:
if(strcmp(cmd, "/reloadhouses", true) == 0)
{
if(PInfo[playerid][AdminLevel] == 5)
{
for(new i=0;i<MAX_HOUSES;i++)
{
ReloadHouse(i);
}
SendClientMessage(playerid, COLOR_WHITE, "You have reloaded all houses.");
AdminLog(playerid, "/reloadhouses", "Reloaded Houses", "Houses");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator !");
return 1;
}
}
pawn Код:
public ReloadHouse(houseid)
{
new Str[400], string[256];
format(string,sizeof(string),"SELECT * FROM `houses` WHERE `HouseID` = %d LIMIT 1", houseid);
mysql_reconnect();
mysql_query(string);
mysql_store_result();
new hTotal = mysql_num_rows(); //hTotal amount of houses in mysql database
if(hTotal > 0) //1+ house.
{
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"))
{
DestroyDynamicMapIcon(HInfo[HID][hMapIcon]);
DestroyPickup(HInfo[HID][hPickupID]);
Delete3DTextLabel(HInfo[HID][hHouseText]);
HInfo[HID][hMapIcon] = CreateDynamicMapIcon(eX, eY, eZ, 31, 0, 0, 0, 0, 100.0);
HInfo[HID][hPickupID] = CreatePickup(1273, 23, eX, eY, eZ, 0);
format(string,sizeof(string),"House for sale!\n$%d (%d slots)\n/buyhouse to purchase.", DefaultPrice, Slots);
HInfo[HID][hHouseText] = Create3DTextLabel(string, 0x50AAC5FF, eX, eY, eZ, 50.0, 0, 1);
}
else if(ForSale == 1)
{
DestroyDynamicMapIcon(HInfo[HID][hMapIcon]);
DestroyPickup(HInfo[HID][hPickupID]);
Delete3DTextLabel(HInfo[HID][hHouseText]);
HInfo[HID][hMapIcon] = CreateDynamicMapIcon(eX, eY, eZ, 31, 0, 0, 0, 0, 100.0);
HInfo[HID][hPickupID] = CreatePickup(1273, 23, eX, eY, eZ, 0);
format(string,sizeof(string),"Owned by: %s\nFor sale: $%d (%d slots)\n/buyhouse to purchase.", OwnedBy, Price, Slots);
HInfo[HID][hHouseText] = Create3DTextLabel(string, 0x50AAC5FF, eX, eY, eZ, 50.0, 0, 1);
}
else
{
DestroyDynamicMapIcon(HInfo[HID][hMapIcon]);
DestroyPickup(HInfo[HID][hPickupID]);
Delete3DTextLabel(HInfo[HID][hHouseText]);
HInfo[HID][hMapIcon] = CreateDynamicMapIcon(eX, eY, eZ, 32, 0, 0, 0, 0, 100.0);
HInfo[HID][hPickupID] = CreatePickup(1272, 23, eX, eY, eZ, 0);
format(string,sizeof(string),"Owned by: %s\nSlots: %d", OwnedBy, Slots);
HInfo[HID][hHouseText] = Create3DTextLabel(string, 0x50AAC5FF, 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();
}