SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 24/05/2019, 09:40 PM   #1
MadeInLatviaV2
Little Clucker
 
Join Date: Nov 2017
Posts: 2
Reputation: 0
Default Database only receives one row.

Hello.
I am making enter/exit system but the database only receives one row of the database.

Code:
forward public LoadInteriors();
public LoadInteriors()
{
    new Cache:result = mysql_query(Database, "SELECT * FROM enters");

    new rows;
    if(!cache_get_row_count(rows))
    {
    	print("No interior found!");
        return true;
	}
	
	for(new i; i < rows; i++)
	{
	
			//cache_set_active(bInfo[i][Enters_Cache]);
            cache_insert_id();
			
			mysql_fetch_row(query);
			
			cache_get_value_float(0, "ENTER_X", bInfo[i][ENTER_X]);
			cache_get_value_float(0, "ENTER_Y", bInfo[i][ENTER_Y]);
			cache_get_value_float(0, "ENTER_Z", bInfo[i][ENTER_Z]);
			cache_get_value_float(0, "EXIT_X", bInfo[i][EXIT_X]);
			cache_get_value_float(0, "EXIT_Y", bInfo[i][EXIT_Y]);
			cache_get_value_float(0, "EXIT_Z", bInfo[i][EXIT_Z]);
			cache_get_value_int(0, "ENTER_INTERIOR", bInfo[i][ENTER_INTERIOR]);
			cache_get_value_int(0, "ENTER_WORLD", bInfo[i][ENTER_WORLD]);
			cache_get_value_int(0, "EXIT_INTERIOR", bInfo[i][EXIT_INTERIOR]);
			cache_get_value_int(0, "EXIT_WORLD", bInfo[i][EXIT_WORLD]);
			
			printf("ENTER PICKUP %f | %f | %f",bInfo[i][ENTER_X],bInfo[i][ENTER_Y],bInfo[i][ENTER_Z]);
			printf("ENTER PICKUP %f | %f | %f",bInfo[i][EXIT_X],bInfo[i][EXIT_Y],bInfo[i][EXIT_Z]);
			
			CreatePickup(1318,1,bInfo[i][ENTER_X],bInfo[i][ENTER_Y],bInfo[i][ENTER_Z]);
			CreatePickup(1318,1,bInfo[i][EXIT_X],bInfo[i][EXIT_Y],bInfo[i][EXIT_Z]);

			
			printf("SEIT %i", i);
			
			HouseID++;

	}
	cache_delete(result);
    printf("> %d loaded. Rows %i", HouseID, rows);
	
    return 1;
}
Console result

Code:
ENTER PICKUP 1.000000 | 1.000000 | 1.000000
ENTER PICKUP 1.000000 | 1.000000 | 1.000000
SEIT 0
ENTER PICKUP 1.000000 | 1.000000 | 1.000000
ENTER PICKUP 1.000000 | 1.000000 | 1.000000
SEIT 1
ENTER PICKUP 1.000000 | 1.000000 | 1.000000
ENTER PICKUP 1.000000 | 1.000000 | 1.000000
SEIT 2
ENTER PICKUP 1.000000 | 1.000000 | 1.000000
ENTER PICKUP 1.000000 | 1.000000 | 1.000000
SEIT 3

Database

MadeInLatviaV2 is offline   Reply With Quote
Old 24/05/2019, 09:56 PM   #2
Plastikmensch
Big Clucker
 
Join Date: Aug 2016
Posts: 142
Reputation: 8
Default Re: Database only receives one row.

You only do cache_get_value for the first row.
Code:
cache_get_value_float(0, "ENTER_X", bInfo[i][ENTER_X]);
Should be
Code:
cache_get_value_float(i, "ENTER_X", bInfo[i][ENTER_X]);
first parameter is the row you want to get the value from.
Plastikmensch is online now   Reply With Quote
Old 25/05/2019, 07:19 AM   #3
MadeInLatviaV2
Little Clucker
 
Join Date: Nov 2017
Posts: 2
Reputation: 0
Default Re: Database only receives one row.

Quote:
Originally Posted by Plastikmensch View Post
You only do cache_get_value for the first row.
Code:
cache_get_value_float(0, "ENTER_X", bInfo[i][ENTER_X]);
Should be
Code:
cache_get_value_float(i, "ENTER_X", bInfo[i][ENTER_X]);
first parameter is the row you want to get the value from.
Lol, thanks.
MadeInLatviaV2 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
receives score when playerid dies in the vehicle per killerid (OnPlayerDeath) PaulCrouseVS Scripting Help 1 05/06/2018 01:47 AM
The United States receives terrorist attack. RiChArD_A Everything and Nothing 433 21/04/2013 08:35 PM
Bug -No player receives the message when kicked jonathan_scripter Bug Reports 1 12/02/2013 06:50 AM


All times are GMT. The time now is 12:49 AM.


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