SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 03/08/2019, 06:59 PM   #1
Kript
Little Clucker
 
Join Date: Feb 2017
Posts: 6
Reputation: 0
Default Houses won't load

Hello, i have some problems with house system. This is not loaded in game after restart, but all infos are saved in db.
This is Load Function.
pawn Code:
forward LoadDynamicHouses();
public LoadDynamicHouses()
{
    new rows = cache_num_rows(),
        time = GetTickCount(),
        total,
        query[128];

    if(!rows)
    {
        print("[Houses] Houses Loaded».");
        return 1;
    }

    for(new i; i < rows; i++)
    {
        cache_get_value_name_int(i, "id", HouseInfo[i][hID]);
        cache_get_value_name_float(i, "posx", HouseInfo[i][hPosX]);
        cache_get_value_name_float(i, "posy", HouseInfo[i][hPosY]);
        cache_get_value_name_float(i, "posz", HouseInfo[i][hPosZ]);
        cache_get_value_name_float(i, "exitx", HouseInfo[i][hExitX]);
        cache_get_value_name_float(i, "exity", HouseInfo[i][hExitY]);
        cache_get_value_name_float(i, "exitz", HouseInfo[i][hExitZ]);
        cache_get_value_name(i, "ownername", HouseInfo[i][hOwner]);
        strreplace(HouseInfo[i][hOwner], "_", " ");
        cache_get_value_name_int(i, "owner", HouseInfo[i][hOwnerID]);
        cache_get_value_name_int(i, "locked", HouseInfo[i][hLocked]);
        cache_get_value_name_int(i, "price", HouseInfo[i][hPrice]);
        cache_get_value_name_int(i, "levelbuy", HouseInfo[i][hLevelbuy]);
        cache_get_value_name_int(i, "cash", HouseInfo[i][hCash]);
        cache_get_value_name_int(i, "exitint", HouseInfo[i][hExitInt]);
        cache_get_value_name_int(i, "exitvw", HouseInfo[i][hExitVW] );
        cache_get_value_name_int(i, "posint", HouseInfo[i][hPosInt] );
        cache_get_value_name_int(i, "posvw", HouseInfo[i][hPosVW]);
        cache_get_value_name_float(i, "checkx", HouseInfo[i][hCheckPosX]);
        cache_get_value_name_float(i, "checky", HouseInfo[i][hCheckPosY]);
        cache_get_value_name_float(i, "checkz", HouseInfo[i][hCheckPosZ]);
        cache_get_value_name_int(i, "radio", HouseInfo[i][hRadio] );
        cache_get_value_name_int(i, "lock", HouseInfo[i][hLock]);
        cache_get_value_name_int(i, "alarm", HouseInfo[i][hAlarm]);
        cache_get_value_name_int(i, "door", HouseInfo[i][hDoor]);
        cache_get_value_name_int(i, "ddoor", HouseInfo[i][hDDoor]);
        cache_get_value_name_int(i, "class", HouseInfo[i][hClass]);
        cache_get_value_name_int(i, "heal", HouseInfo[i][hHeal]);
        cache_get_value_name_int(i, "heal_amount", HouseInfo[i][hHealAmount]);
        cache_get_value_name_int(i, "cupboard", HouseInfo[i][hCupboard]);
        cache_get_value_name_float(i, "furniture_radius", HouseInfo[i][hFurnitureRadius]);
        HouseInfo[i][hFurniture] = 0;
        HouseInfo[i][hOutsideFurniture] = 0;
        new str_inv[10];

        for(new a = 0; a < MAX_HOUSE_INVENTORY; a++)
        {
            format(str_inv, sizeof(str_inv), "inv_%i", a+1);
            cache_get_value_name_int(i, str_inv, HouseInfo[i][hInv][a]);
            format(str_inv, sizeof(str_inv), "amount_%i", a+1);
            cache_get_value_name_int(i, str_inv, HouseInfo[i][hInvAmount][a]);
        }

        UpdateHouseText(i);
        UpdateHouseDoor(i);

        HouseInfo[i][hCheckPoint] =
            CreateDynamicCP(HouseInfo[i][hPosX], HouseInfo[i][hPosY], HouseInfo[i][hPosZ], 1.0, HouseInfo[i][hPosVW], HouseInfo[i][hPosInt], -1, 2.0);

        //format(query, sizeof(query), "SELECT * FROM `furnitures` WHERE `houseid`='%i'", HouseInfo[i][hID]);
        //mysql_tquery(dbCon, query, "OnFurnituresLoad", "i", i);

 
        total++;
    }
    printf("[Houses] Case - %i. printif - %i. timp: %i ms.", rows, total, GetTickCount()-time);
    return 1;
}

And in OnGameModeInit i put
pawn Code:
mysql_tquery(dbCon, "SELECT *, (SELECT name FROM users WHERE id = houses.owner) as ownername, (SELECT last_login FROM users WHERE id = houses.owner) as lastlogin FROM `houses`", "LoadDynamicHouses");
LoadDynamicHouses();

Gamemode use MYSQL R41.

Can please help me?
Kript is offline   Reply With Quote
Old 03/08/2019, 08:50 PM   #2
kukboy
Big Clucker
 
kukboy's Avatar
 
Join Date: Nov 2018
Posts: 57
Reputation: 6
Default Re: Houses won't load

Check Mysql Log and look if there are any errors or warnings.
__________________
Paradise City Roleplay

IP: samp.paradisecityroleplay:7777
Discord: https://discord.gg/fC8srfw[/



-----------------------------------
kukboy is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Houses Load nezo2001 Scripting Help 8 14/06/2015 11:23 AM
Load houses maikons Scripting Help 0 25/12/2014 02:49 PM
Load Houses wumpyc Scripting Help 15 17/08/2013 04:28 PM
SQL won't load houses. iGetty Scripting Help 7 17/05/2012 04:27 AM


All times are GMT. The time now is 04:50 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.