Jump to content

Question

Posted (edited)

Salut! Sunt incepator in ale pawno si mysql si am descoperit o problema la un sistem de case.
Atunci cand creez casa din joc cu comanda /add totul este in regula. Afiseaza id-ul casei, pretul si clasa acesteia.
Dar cand inchid serverul si casele sunt reincarcate, desi in baza de date apare ca Owner " None" cand dau /buyhouse imi zice ca am deja o casa, desi nu am cumparat-o, si Clasa casei nu mai este afisata deloc.

Multumesc anticipat!

Add command:

Citat

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;
}


LoadHouse

Citat

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;
}


Update house

Citat

UpdateHouse(idx)
{
    DestroyDynamicMapIcon(House[idx][hIcon]);
    DestroyPickup(House[idx][hPickup]);
    DestroyPickup(House[idx][hPickupExit]);
       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]);
    return 1;
}


Pickup

Citat

 format(String, for(new idx = 1; idx <= TOTAL_HOUSES; idx++)
    {
        if(pickupid == House[idx][hPickup])
        {
            SetPVarInt(playerid, "PlayerHouse", idx);
               if(!strcmp(House[idx][hOwner], "None", true))
              {
                format(String, 256, "\
                    House nr. %d\n\n\
                    Price: %d$\n\
                    Class: %s\n\
                    Use /buyhouse if you want to buy this house.", idx, House[idx][hPrice], House[idx][hClass]);
                   return GameTextForPlayer(playerid, String, 3000, 5);
            }
            else
            {256, "\
                    House nr. %d\n\n\
                    Price: %d$\n\
                    Class: %s\n\
                    Use /enter if you want to enter this house.", idx, House[idx][hPrice], House[idx][hClass]);
                   return GameTextForPlayer(playerid, String, 3000, 5);
            }
        }
        if(pickupid == House[idx][hPickupExit])
        {
            SetPVarInt(playerid, "PlayerHouse", idx);
            return Dialog_Show(playerid, ExitHouse, 0, "Exit house", "Do you want to exit your house?", "Yes", "No");
        }
    }
    return 1;
}

 

Edited by bogdanel_hd

9 answers to this question

Recommended Posts

  • 0
Posted

Incearca sa vezi daca ai rent la o casa / ai o casa deja cumparata, din cate am vazut e totul in "regula" n-ar trb sa iti deea aceasta "eroare, ca deja ai o casa"

  • 0
Posted (edited)
Acum 2 ore, Raul Tiganu a spus:

Incearca sa vezi daca ai rent la o casa / ai o casa deja cumparata, din cate am vazut e totul in "regula" n-ar trb sa iti deea aceasta "eroare, ca deja ai o casa"

Nu e implementat ceva de genul asta in gamemode. E bagata doar comanda cu ajutorul careia cumperi casa, atat.

Comanda /buyhouse.

Citat

CMD:buyhouse(playerid, params[])
{
    if(Player[playerid][LoggedIn] == false) return 1;
    new idx = GetPVarInt(playerid, "PlayerHouse");
    if(IsPlayerInRangeOfPoint(playerid,3.0,House[idx][hEntranceX], House[idx][hEntranceY], House[idx][hEntranceZ]) && GetPlayerVirtualWorld(playerid) == 0)
    {
        if(Player[playerid][Money] < House[idx][hPrice]) return SendErrorMessage(playerid, COLOR_GREY, NOT_ENOUGH_MONEY_BANK);
        else
            {
            new house = 0;
            for(new i = 1; i <= TOTAL_HOUSES; i++)
                {
                    if(!strcmp(House[hOwner], pName(playerid), true)) house++;
                }
            if(house != 0) return SendErrorMessage(playerid, COLOR_GREY, YOU_HAVE_A_HOUSE);
            Player[playerid][Money] -= House[idx][hPrice];
            format(String, 32, "You bought a house!");
            GameTextForPlayer(playerid, String, 3000, 5);
            format(String, 256, "You bought a house for %d$! Money left: %d$.", House[idx][hPrice], Player[playerid][Money]);
            SendClientMessage(playerid, -1, String);
            strmid(House[idx][hOwner], pName(playerid), 0, strlen(pName(playerid)), MAX_PLAYER_NAME);
            format(String, 256, "UPDATE `houses` SET Owner = '%s' WHERE ID = '%d' LIMIT 1", House[idx][hOwner], idx);
            mysql_tquery(g_SQL, String, "", "");
               SetPlayerPos(playerid, House[idx][hExitX], House[idx][hExitY], House[idx][hExitZ]);
            SetPlayerInterior(playerid, House[idx][hInterior]);
            SetPlayerVirtualWorld(playerid, House[idx][hWorld]);
            UpdateHouse(idx);
            }
    }        
    return 1;
}

Doar asta verifica daca am deja o casa: 

Citat

new house = 0;
            for(new i = 1; i <= TOTAL_HOUSES; i++)
                {
                   if(!strcmp(House[hOwner], pName(playerid), true)) house++;
                }
            if(house != 0) return SendErrorMessage(playerid, COLOR_GREY, YOU_HAVE_A_HOUSE);

In baza de date apare la owner "None" dar cand vreau sa o cumpar chestia asta aparent nu vede nicio diferenta intre None si numele caracterului meu.

Edited by bogdanel_hd
  • 0
Posted

Si eu am tot cu casele din gm cand dau sa creez o casa imi da unknow da nu stiu dk si am pus si alta comanda si tot degeaba poate ma poti ajuta tu uite discordu meu sa vb @costyn#0975 dak ma poti ajuta

  • 0
Posted (edited)

Am tot verificat si nu pot sa ii dau nici cum de cap.  GM acesta este gm-ul pe care lucrez. Desi cel care l-a inceput zice ca nu are niciun bug. Eu cand il deschid si incerc sa rezolv casele ma lovesc de problema de mai sus.

Edited by bogdanel_hd
  • 0
Posted

@bogdanel_hd, pune tot ce e de pus de la acel mesaj. Unde spune ca ai deja casa. Sunt pe tel acum, n-am stat sa verific eu, dar uita-te tu....daca, in acel moment cand creezi casa nu ti-o trece ca si cum ai detine-o.

  • 0
Posted (edited)

Aceasta este dialogul de Addhouse:

Citat

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;
}

Doar asta afecteaza variabila Owner strmid(House[TOTAL_HOUSES][hOwner], "None", 0, strlen("None"), MAX_PLAYER_NAME); 

Ceea ce si verifica cand o cumperi:

for(new i = 1; i <= TOTAL_HOUSES; i++) 
            {
                if(!strcmp(House[hOwner], pName(playerid), true)) house++;
            }
            if(house != 0) return SendErrorMessage(playerid, COLOR_GREY, YOU_HAVE_A_HOUSE);

In baza de date apare la Owner: "None" dar se pare ca if-ul asta nu vede nicio diferenta intre "None" si Numele caracterului meu.

Daca o cumpar imediat dupa ce am creat-o atunci tot e ok, dar daca de cand o creez pana o cumpar dau un restart, imi zice ca am deja o casa.

 

Dialog de buyhouse: 

Citat

Dialog:BuyHouse(playerid, response, listitem, inputtext[]) {
    if(response) {
        new idx = GetPVarInt(playerid, "PlayerHouse");
           if(Player[playerid][BankMoney] < House[idx][hPrice]) return SendErrorMessage(playerid, COLOR_GREY, NOT_ENOUGH_MONEY_BANK);
        else 
        {
            new house = 0;
            for(new i = 1; i <= TOTAL_HOUSES; i++) 
            {
                if(!strcmp(House[hOwner], pName(playerid), true)) house++;
            }
            if(house != 0) return SendErrorMessage(playerid, COLOR_GREY, YOU_HAVE_A_HOUSE);
            Player[playerid][BankMoney] -= House[idx][hPrice];
            format(String, 32, "You bought a house!");
            GameTextForPlayer(playerid, String, 3000, 5);
            format(String, 256, "You bought a house for %d$! Money left in bank: %d$.", House[idx][hPrice], Player[playerid][BankMoney]);
            SendClientMessage(playerid, -1, String);
            strmid(House[idx][hOwner], pName(playerid), 0, strlen(pName(playerid)), MAX_PLAYER_NAME);
            format(String, 256, "UPDATE `houses` SET Owner = '%s' WHERE ID = '%d' LIMIT 1", House[idx][hOwner], idx);
            mysql_tquery(g_SQL, String, "", "");
            
            SetPlayerPos(playerid, House[idx][hExitX], House[idx][hExitY], House[idx][hExitZ]);
            SetPlayerInterior(playerid, House[idx][hInterior]);
            SetPlayerVirtualWorld(playerid, House[idx][hWorld]);
            UpdateHouse(idx);
            return true;
        }
    }
    return 1;
}

 

Edited by bogdanel_hd

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.