SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 23/07/2013, 10:11 PM   #1
Ld Est Ld
Big Clucker
 
Ld Est Ld's Avatar
 
Join Date: Nov 2011
Posts: 99
Reputation: 2
Default Loading houses MySQL R7 plugin

Hello, I have a problem loading all houses from database.

The function only loads 1 last row from houses table.

Code in OnGameModeInit:
PHP Code:
format(szQueryInputsizeof(szQueryInput), "SELECT * FROM houses");
    
mysql_function_query(connectionszQueryInputtrue"loadHouses"""); 
loadHouses:

PHP Code:
public loadHouses() {
    new 
rowsfields;
    
cache_get_data(rowsfields);
    
    if(
rows) {
        for(new 
0rowsx++) {
            
cache_get_row(x0szQueryOutput); // HouseID
            
strval(szQueryOutput);
            
cache_get_row(x1szQueryOutput); 
            
houseVariables[x][hHouseOwned] = strval(szQueryOutput);
            
cache_get_field_content(x"houseOwner"szQueryOutput);
            
format(houseVariables[x][hHouseOwner],sizeof(szQueryOutput),szQueryOutput);
            
cache_get_field_content(x"houseName"szQueryOutput);
            
format(houseVariables[x][hHouseName],sizeof(szQueryOutput),szQueryOutput);
            
cache_get_row(x4szQueryOutput); 
            
houseVariables[x][hHouseExt][0] = floatstr(szQueryOutput);
            
cache_get_row(x5szQueryOutput); 
            
houseVariables[x][hHouseExt][1] = floatstr(szQueryOutput);
            
cache_get_row(x6szQueryOutput); 
            
houseVariables[x][hHouseExt][2] = floatstr(szQueryOutput);
            
cache_get_row(x7szQueryOutput);
            
houseVariables[x][hHouseInt][0] = floatstr(szQueryOutput);
            
cache_get_row(x8szQueryOutput); 
            
houseVariables[x][hHouseInt][1] = floatstr(szQueryOutput);
            
cache_get_row(x9szQueryOutput);
            
houseVariables[x][hHouseInt][2] = floatstr(szQueryOutput);
            if(
houseVariables[x][hHouseOwned] > 0) {
                switch(
houseVariables[x][hHouseLocked]) {
                    case 
1: {
                        
format(szStringsizeof(szString), "%s\nOwner: %s\nLocked"houseVariables[x][hHouseName], houseVariables[x][hHouseOwner]);
                        
houseVariables[x][hLabelID] = CreateDynamic3DTextLabel(szStringCOLOR_CADETBLUEhouseVariables[x][hHouseExt][0], houseVariables[x][hHouseExt][1], houseVariables[x][hHouseExt][2], 100INVALID_PLAYER_IDINVALID_VEHICLE_ID0, -1, -1, -110.0);
                    }
                    case 
2: {
                        
format(szStringsizeof(szString), "%s\nOwner: %s\nLocked"houseVariables[x][hHouseName], houseVariables[x][hHouseOwner]);
                        
houseVariables[x][hLabelID] = CreateDynamic3DTextLabel(szStringCOLOR_CADETBLUEhouseVariables[x][hHouseExt][0], houseVariables[x][hHouseExt][1], houseVariables[x][hHouseExt][2], 100INVALID_PLAYER_IDINVALID_VEHICLE_ID0, -1, -1, -110.0);
                    }
                    default: {
                        
format(szStringsizeof(szString), "%s\nOwner: %s\Openedn"houseVariables[x][hHouseName], houseVariables[x][hHouseOwner]);
                        
houseVariables[x][hLabelID] = CreateDynamic3DTextLabel(szStringCOLOR_CADETBLUEhouseVariables[x][hHouseExt][0], houseVariables[x][hHouseExt][1], houseVariables[x][hHouseExt][2], 100INVALID_PLAYER_IDINVALID_VEHICLE_ID0, -1, -1, -110.0);
                    }
                }
                
houseVariables[x][hPickupID] = CreateDynamicPickup(127223houseVariables[x][hHouseExt][0], houseVariables[x][hHouseExt][1], houseVariables[x][hHouseExt][2], 00, -1250);
            }
        }
    }

What I'm doing WRONG?
Ld Est Ld is offline   Reply With Quote
Old 24/07/2013, 08:21 AM   #2
Ld Est Ld
Big Clucker
 
Ld Est Ld's Avatar
 
Join Date: Nov 2011
Posts: 99
Reputation: 2
Default Re: Loading houses MySQL R7 plugin

Fixed:
For everyone who searching houses in loop for MySQL R7:

Change:
PHP Code:
cache_get_row(x0szQueryOutput); // HouseID
            
strval(szQueryOutput); 
to
PHP Code:
cache_get_row(x0szQueryOutput); // HouseID
            
houseVariables[x][hHouseID] = strval(szQueryOutput); 
Ld Est Ld 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
BlueG's Mysql Plugin Not loading San1 Scripting Help 1 19/06/2013 08:22 PM
Loading mysql plugin Dan. Server Support 6 07/08/2012 02:16 PM
mySQL loading houses (pretty close) jesse237 Scripting Help 4 01/09/2011 04:07 PM
mysql plugin. loading plugin failed ikkentim Help Archive 2 10/02/2011 02:32 PM
loading houses from mysql. Think Help Archive 9 04/04/2009 11:48 AM


All times are GMT. The time now is 08:14 AM.


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