Hello! I am a beginner in pawno and mysql and i`ve got a problem on a house system.
When i create the house in game is alright. But when I close and reopen the server something is wrong.
It says that I already have a house and the Class of the house is not displayed.
pawn Code:
Dialog:AddHouse(playerid, response, listitem, inputtext[]) {
if(!response) return Dialog_Show(playerid, AddMenu, DIALOG_STYLE_LIST, "Add menu", "\
Add house\n\
Add bussiness", "OK", "Cancel");
new price, type, Float: X, Float: Y, Float: Z;
if(sscanf(inputtext,"p<,>ii", price, type))
{
new String1[1000];
strcat(String1,"\
Syntax: price, number\n\n\
Sample: 24000, 19\n\n");
strcat(String1,"1. [Class: A]\t12. [Class: C]\t23. [Class: C]\t34. [Class: C]\n");
strcat(String1,"2. [Class: C]\t13. [Class: C]\t24. [Class: B]\t35. [Class: C]\n");
strcat(String1,"3. [Class: B]\t14. [Class: B]\t25. [Class: B]\n");
strcat(String1,"4. [Class: D]\t15. [Class: C]\t26. [Class: D]\n");
strcat(String1,"5. [Class: B]\t16. [Class: B]\t27. [Class: D]\n");
strcat(String1,"6. [Class: B]\t17. [Class: B]\t28. [Class: D]\n");
strcat(String1,"7. [Class: D]\t18. [Class: A]\t29. [Class: C]\n");
strcat(String1,"8. [Class: B]\t19. [Class: C]\t30. [Class: A]\n");
strcat(String1,"9. [Class: A]\t20. [Class: D]\t31. [Class: C]\n");
strcat(String1,"10. [Class: B]\t21. [Class: A]\t32. [Class: C]\n");
strcat(String1,"11. [Class: C]\t22. [Class: B]\t33. [Class: D]\n");
return Dialog_Show(playerid, AddHouse, 1, "Add house", String1, "Add", "Back");
}
TOTAL_HOUSES++;
GetPlayerPos(playerid, X, Y, Z);
House[TOTAL_HOUSES][hEntranceX] = X;
House[TOTAL_HOUSES][hEntranceY] = Y;
House[TOTAL_HOUSES][hEntranceZ] = Z;
switch(type)
{
case 1: format(String, 90, "435.4139, 1315.7772, 1615.5118, A, 5");
case 2: format(String, 90, "-376.3782, 1026.7642, 1713.0265, C, 9");
case 3: format(String, 90, "2163.3025, 2821.6401, 1716.2335, B, 6");
case 4: format(String, 90, "-1181.7406, 2080.4648, 2741.2014, D, 15");
case 5: format(String, 90, "2237.5413, -1081.1516, 1049.04, B, 2");
case 6: format(String, 90, "24.0716, 1340.1615, 1084.3750, B, 10");
case 7: format(String, 90, "2259.5068, -1135.9337, 1050.6328, D, 10");
case 8: format(String, 90, "2196.8469, -1204.3524, 1049.0234, B, 6");
case 9: format(String, 90, "2317.7983, -1026.7651, 1050.2178, A, 9");
case 10: format(String, 90, "2365.3345, -1135.5907, 1050.8826, B, 8");
case 11: format(String, 90, "2282.8831, -1140.0713, 1050.8984, C, 11");
case 12: format(String, 90, "2218.3875, -1076.1580, 1050.4844, C, 1");
case 13: format(String, 90, "-68.8411, 1351.3397, 1080.2109, C, 6");
case 14: format(String, 90, "-283.6001, 1471.2211, 1084.3750, B, 15");
case 15: format(String, 90, "-42.5525, 1405.6432, 1084.4297, C, 8");
case 16: format(String, 90, "83.0791, 1322.2808, 1083.8662, B, 9");
case 17: format(String, 90, "447.2238, 1397.2926, 1084.3047, B, 2");
case 18: format(String, 90, "235.2748, 1186.6809, 1080.2578, A, 3");
case 19: format(String, 90, "226.4436, 1239.9277, 1082.1406, C, 2");
case 20: format(String, 90, "244.0883, 305.0291, 999.1484, D, 1");
case 21: format(String, 90, "226.2956, 1114.1615, 1080.9929, A, 5");
case 22: format(String, 90, "295.2479, 1472.2650, 1080.2578, B, 15");
case 23: format(String, 90, "261.1874, 1284.2982, 1080.2578, C, 4");
case 24: format(String, 90, "-260.4934, 1456.8430, 1084.3672, B, 4");
case 25: format(String, 90, "22.9848, 1403.3345, 1084.4370, B, 5");
case 26: format(String, 90, "2468.2080, -1698.2988, 1013.5078, D, 2");
case 27: format(String, 90, "266.9498, 304.9866, 999.1484, D, 2");
case 28: format(String, 90, "422.3438, 2536.4980, 10.0000, D, 10");
case 29: format(String, 90, "443.4504, 509.2181, 1001.4195, C, 12");
case 30: format(String, 90, "2324.3977, -1149.0601, 1050.7101, A, 12");
case 31: format(String, 90, "2807.6919, -1174.2933, 1025.5703, C, 8");
case 32: format(String, 90, "2233.6965, -1115.1270, 1050.8828, C, 5");
case 33: format(String, 90, "221.7789, 1140.1970, 1082.6094, D, 4");
case 34: format(String, 90, "387.1313, 1471.7137, 1080.1949, C, 15");
case 35: format(String, 90, "377.1231, 1417.3163, 1081.3281, C, 15"); // [???????? 4 ??????????](????) int 4
}
sscanf(String,"p<,>fffsi",
House[TOTAL_HOUSES][hExitX],
House[TOTAL_HOUSES][hExitY],
House[TOTAL_HOUSES][hExitZ],
House[TOTAL_HOUSES][hClass],
House[TOTAL_HOUSES][hInterior]);
House[TOTAL_HOUSES][hWorld] = TOTAL_HOUSES;
House[TOTAL_HOUSES][hPrice] = price;
strmid(House[TOTAL_HOUSES][hOwner], "None", 0, strlen("None"), MAX_PLAYER_NAME);
House[TOTAL_HOUSES][hIcon] = CreateDynamicMapIcon(House[TOTAL_HOUSES][hEntranceX], House[TOTAL_HOUSES][hEntranceY], House[TOTAL_HOUSES][hEntranceZ], 31, 0, -1, -1, -1, 200.0);
House[TOTAL_HOUSES][hPickup] = CreatePickup(1273,1, House[TOTAL_HOUSES][hEntranceX], House[TOTAL_HOUSES][hEntranceY], House[TOTAL_HOUSES][hEntranceZ]);
House[TOTAL_HOUSES][hPickupExit] = CreatePickup(19134, 1, House[TOTAL_HOUSES][hExitX], House[TOTAL_HOUSES][hExitY], House[TOTAL_HOUSES][hExitZ], House[TOTAL_HOUSES][hWorld]);
format(String, 512, "INSERT INTO `houses` (ID, EntranceX, EntranceY, EntranceZ, ExitX, ExitY, ExitZ, Class, Price, Interior, World)\
VALUES (%d, '%f', '%f', '%f', '%f', '%f', '%f', '%s', %d, %d, %d)",
TOTAL_HOUSES,
House[TOTAL_HOUSES][hEntranceX],
House[TOTAL_HOUSES][hEntranceY],
House[TOTAL_HOUSES][hEntranceZ],
House[TOTAL_HOUSES][hExitX],
House[TOTAL_HOUSES][hExitY],
House[TOTAL_HOUSES][hExitZ],
House[TOTAL_HOUSES][hClass],
House[TOTAL_HOUSES][hPrice],
House[TOTAL_HOUSES][hInterior],
House[TOTAL_HOUSES][hWorld]);
mysql_tquery(g_SQL, String, "", "");
format(String, 64, "House nr. %d created", TOTAL_HOUSES);
SendClientMessage(playerid, COLOR_ORANGE, String);
return 1;
}
pawn Code:
public LoadHouses()
{
static rows;
cache_get_row_count(rows);
if(rows)
{
for(new idx = 1; idx <= rows; idx++)
{
cache_get_value_name_int(idx-1, "ID", House[idx][hID]);
cache_get_value_name_float(idx-1, "EntranceX", House[idx][hEntranceX]);
cache_get_value_name_float(idx-1, "EntranceY", House[idx][hEntranceY]);
cache_get_value_name_float(idx-1, "EntranceZ", House[idx][hEntranceZ]);
cache_get_value_name_float(idx-1, "ExitX", House[idx][hExitX]);
cache_get_value_name_float(idx-1, "ExitY", House[idx][hExitY]);
cache_get_value_name_float(idx-1, "ExitZ", House[idx][hExitZ]);
cache_get_value_name(idx-1, "Owner", House[idx][hOwner]);
cache_get_value_name(idx-1, "Class", House[idx][hClass]);
cache_get_value_name_int(idx-1, "Interior", House[idx][hInterior]);
cache_get_value_name_int(idx-1, "World", House[idx][hWorld]);
cache_get_value_name_int(idx-1, "Price", House[idx][hPrice]);
if(!strcmp(House[idx][hOwner], "None", true))
{
House[idx][hIcon] = CreateDynamicMapIcon(House[idx][hEntranceX], House[idx][hEntranceY], House[idx][hEntranceZ], 31, 0, -1, -1, -1, 200.0);
House[idx][hPickup] = CreatePickup(1273, 1, House[idx][hEntranceX], House[idx][hEntranceY], House[idx][hEntranceZ]);
}
else
{
House[idx][hIcon] = CreateDynamicMapIcon(House[idx][hEntranceX], House[idx][hEntranceY], House[idx][hEntranceZ], 32, 0, -1, -1, -1, 200.0);
House[idx][hPickup] = CreatePickup(1272, 1, House[idx][hEntranceX], House[idx][hEntranceY], House[idx][hEntranceZ]);
}
House[idx][hPickupExit] = CreatePickup(19134, 1, House[idx][hExitX], House[idx][hExitY], House[idx][hExitZ], House[idx][hWorld]);
TOTAL_HOUSES++;
}
}
printf( "Loaded %d houses", TOTAL_HOUSES);
return 1;
}