25.11.2016, 18:11
Okay this might be a big problem but i can't find solution so I tought you could help me..
That is /createhouse command.. Problem is when I create first house as type 5 (Villa) it will be created as villa.. but every other house will be created as camp house.. Any ideas why is this happening??
But it is saved in mysql table as villa.. WTF..
Here are functions
PHP код:
CMD:createhouse(playerid, params[])
{
if(PlayerInfo[playerid][Admin] < 5)
{
ERROR(playerid, "You are not allowed to use this command");
return 1;
}
new type, level, price;
if(sscanf(params, "iii", type, level, price))
{
USAGE(playerid, "/createhouse [Type] [Level] [Price]");
INFO(playerid, "Type | 1 - Camp House | 2 - Small House | 3 - Medium House");
INFO(playerid, "Type | 4 - Big House | 5 - Villa");
return 1;
}
if(type < 1 || type > 5)
{
ERROR(playerid, "Type can't be higher than 5 and lower than 1");
return 1;
}
if(level < 1 || level > 100)
{
ERROR(playerid, "Level can't be higher than 100 and lower than 1");
return 1;
}
if(price < 1)
{
ERROR(playerid, "Price can't be lower than 1$");
return 1;
}
new house;
if(HouseInfo[house][hID] > MAX_HOUSES)
{
ERROR(playerid, "Max houses reached!");
return 1;
}
if(type == 1)
{
HouseInfo[hID][hExitX] = 327.4407;
HouseInfo[hID][hExitY] = 1766.7507;
HouseInfo[hID][hExitZ] = 4.9849;
HouseInfo[hID][hType] = TYPE_CAMP;
strmid(HouseInfo[hID][hDescription],"Description",0,strlen("Description"),255);
HouseInfo[hID][hInt] = 2;
}
else if(type == 2)
{
HouseInfo[hID][hExitX] = 2308.7529;
HouseInfo[hID][hExitY] = -1212.5588;
HouseInfo[hID][hExitZ] = 1049.0234;
HouseInfo[hID][hType] = TYPE_SMALL;
strmid(HouseInfo[hID][hDescription], "Description",0,strlen("Description"),255);
HouseInfo[hID][hInt] = 6;
}
else if(type == 3)
{
HouseInfo[hID][hExitX] = 318.6055;
HouseInfo[hID][hExitY] = 1114.9292;
HouseInfo[hID][hExitZ] = 1083.8828;
HouseInfo[hID][hType] = TYPE_MEDIUM;
strmid(HouseInfo[hID][hDescription],"Description",0,strlen("Description"),255);
HouseInfo[hID][hInt] = 5;
}
else if(type == 4)
{
HouseInfo[hID][hExitX] = 386.6623;
HouseInfo[hID][hExitY] = 1471.7719;
HouseInfo[hID][hExitZ] = 1080.1875;
HouseInfo[hID][hType] = TYPE_BIG;
strmid(HouseInfo[hID][hDescription],"Description",0,strlen("Description"),255);
HouseInfo[hID][hInt] = 15;
}
else if(type == 5)
{
HouseInfo[hID][hExitX] = 2324.3840;
HouseInfo[hID][hExitY] = -1149.0188;
HouseInfo[hID][hExitZ] = 1050.7101;
HouseInfo[hID][hType] = TYPE_VILLA;
strmid(HouseInfo[hID][hDescription],"Description",0,strlen("Description"),255);
HouseInfo[hID][hInt] = 12;
}
new Float:X, Float:Y, Float:Z;
house = Iter_Free(i_Houses);
GetPlayerPos(playerid, X, Y, Z);
HouseInfo[house][hID] = house;
HouseInfo[house][hVW] = house;
HouseInfo[house][hOwnerCheck] = 0;
strmid(HouseInfo[house][hOwnerName], "Noone", 0, strlen("Noone"), 255);
HouseInfo[house][hEnterX] = X;
HouseInfo[house][hEnterY] = Y;
HouseInfo[house][hEnterZ] = Z;
HouseInfo[house][hLevel] = level;
HouseInfo[house][hPrice] = price;
HouseInfo[house][hMoney] = 0;
HouseInfo[house][hLocked] = 1;
HouseInfo[house][hWeapons] = -1;
HouseInfo[house][hAmmo] = 0;
HouseInfo[house][hRent]= 0;
HouseInfo[house][hRentPrice] = 20;
HouseInfo[house][hBell] = 0;
HouseInfo[house][hDrugs] = 0;
HouseInfo[house][HouseExist] = true;
Iter_Add(i_Houses, house);
CreateHouses(house);
new query[600];
mysql_format(g_SQL, query, sizeof(query), "INSERT INTO `houses` (`ID`,`OwnerCheck`, `OwnerName`, `Description`, `Type`, `EnterX`, `EnterY`, `EnterZ`, `ExitX`, `ExitY`, `ExitZ`, `Level`, `Price`, `Money`, `Interior`, `VW`, `Locked`, `Rent`, `RentPrice`, `Weapons`, `Ammo`, `Bell`, `Drugs`)\
VALUES (%d, %d, '%s', '%s', %d, %f, %f, %f, %f, %f, %f, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",
HouseInfo[house][hID], HouseInfo[house][hOwnerCheck], HouseInfo[house][hOwnerName], HouseInfo[house][hDescription], HouseInfo[house][hType], HouseInfo[house][hEnterX], HouseInfo[house][hEnterY], HouseInfo[house][hEnterZ], HouseInfo[house][hExitX], HouseInfo[house][hExitY], HouseInfo[house][hExitZ], HouseInfo[house][hLevel], HouseInfo[house][hPrice], HouseInfo[house][hMoney], HouseInfo[house][hInt], HouseInfo[house][hVW], HouseInfo[house][hLocked], HouseInfo[house][hRent],
HouseInfo[house][hRentPrice], HouseInfo[house][hWeapons], HouseInfo[house][hAmmo], HouseInfo[house][hBell], HouseInfo[house][hDrugs]);
mysql_tquery(g_SQL, query);
return 1;
}
But it is saved in mysql table as villa.. WTF..
Here are functions
PHP код:
HouseType(id)
{
new string[17];
switch(id)
{
case TYPE_CAMP: string = "Camp House";
case TYPE_SMALL: string = "Small House";
case TYPE_MEDIUM: string = "Medium House";
case TYPE_BIG: string = "Big House";
case TYPE_VILLA: string = "Villa";
default: string = "Unknown";
}
return string;
}
CreateHouses(id)
{
if(HouseInfo[id][hOwnerCheck] == 0)
{
new string[320];
format(string, sizeof(string), ""SERVERBLUE"House on sale\n"SERVERBLUE"Type: "WHITE"%s\n"SERVERBLUE"Price: "WHITE"%d\n"SERVERBLUE"Level: "WHITE"%d\n"SERVERBLUE"To buy house type /buyhouse", HouseType(HouseInfo[id][hType]), HouseInfo[id][hPrice], HouseInfo[id][hLevel]);
HouseLabel[id] = CreateDynamic3DTextLabel(string, 0x1D9F00AA, HouseInfo[id][hEnterX], HouseInfo[id][hEnterY], HouseInfo[id][hEnterZ]+0.1, 25.0, _, _, _, 0, 0, _, _);
HousePickup[id] = CreateDynamicPickup(1273, 1, HouseInfo[id][hEnterX], HouseInfo[id][hEnterY], HouseInfo[id][hEnterZ]);
}
else if(HouseInfo[id][hOwnerCheck] == 1)
{
new string[320], string2[220], string3[540];
if(HouseInfo[id][hRent] == 0)
{
format(string, sizeof(string), ""SERVERBLUE"[ "WHITE"%s "SERVERBLUE"]\n"SERVERBLUE"Owner: "WHITE"%s\b"SERVERBLUE"Type: "WHITE"%d\n", HouseInfo[id][hDescription], HouseInfo[id][hOwnerName], HouseInfo[id][hType]);
format(string2, sizeof(string2), ""SERVERBLUE"Level: "WHITE"%d\n"SERVERBLUE"Price: "WHITE"%d\n"SERVERBLUE"To enter press 'F' or 'ENTER'", HouseInfo[id][hLevel], HouseInfo[id][hPrice]);
format(string3, sizeof(string3), "%s%s", string, string2);
HouseLabel[id] = CreateDynamic3DTextLabel(string3, 0x1D9F00AA, HouseInfo[id][hEnterX], HouseInfo[id][hEnterY], HouseInfo[id][hEnterZ]+0.1, 25.0, _, _, _, 0, 0, _, _);
HousePickup[id] = CreateDynamicPickup(1273, 1, HouseInfo[id][hEnterX], HouseInfo[id][hEnterY], HouseInfo[id][hEnterZ]);
}
else if(HouseInfo[id][hRent] == 1)
{
format(string, sizeof(string), ""SERVERBLUE"[ "WHITE"%s "SERVERBLUE"]\n"SERVERBLUE"Owner: "WHITE"%s\b"SERVERBLUE"Type: "WHITE"%d\n"SERVERBLUE"Rent: "WHITE"%d$(/renthouse)", HouseInfo[id][hDescription], HouseInfo[id][hOwnerName], HouseInfo[id][hType], HouseInfo[id][hRentPrice]);
format(string2, sizeof(string2), ""SERVERBLUE"Level: "WHITE"%d\n"SERVERBLUE"Price: "WHITE"%d\n"SERVERBLUE"To enter press 'F' or 'ENTER'", HouseInfo[id][hLevel], HouseInfo[id][hPrice]);
format(string3, sizeof(string3), "%s%s", string, string2);
HouseLabel[id] = CreateDynamic3DTextLabel(string3, 0x1D9F00AA, HouseInfo[id][hEnterX], HouseInfo[id][hEnterY], HouseInfo[id][hEnterZ]+0.1, 25.0, _, _, _, 0, 0, _, _);
HousePickup[id] = CreateDynamicPickup(1273, 1, HouseInfo[id][hEnterX], HouseInfo[id][hEnterY], HouseInfo[id][hEnterZ]);
}
}
return 1;
}