SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 09/11/2009, 06:03 PM   #1
dioguitosbr
Little Clucker
 
Join Date: Nov 2009
Posts: 9
Reputation: 0
Default [MySQL] samp-server quits when you run query

Code:
stock CarregarVeiculos()
{
	for(new b = 0; b < MAX_VEHICLES; b++) {
	new string[256];
 	format(string, 256, "SELECT * FROM carros WHERE id = %d", b);
 	mysql_query("SELECT * FROM carros WHERE id = 2");
	mysql_store_result();
	new rows = mysql_num_rows();
	if(rows == 1) {
	  new dono[256];
	  new Float:x, Float:y, Float:z, Float:angulo;
	 	new modelo, gasolina;
	 	format(string, 256,"SELECT dono FROM `carros` WHERE id = '%d' LIMIT 1", b);
		mysql_query(string);
		mysql_store_result();
		mysql_fetch_field_row(dono, "dono");
 		format(string, 256,"SELECT p_x FROM `carros` WHERE id = '%d' LIMIT 1", b);
		mysql_query(string);
		mysql_fetch_float(x);
 		format(string, 256,"SELECT p_y FROM `carros` WHERE id = '%d' LIMIT 1", b);
		mysql_query(string);
		mysql_store_result();
		mysql_fetch_float(y);
		format(string, 256,"SELECT p_z FROM `carros` WHERE id = '%d' LIMIT 1", b);
		mysql_query(string);
		mysql_store_result();
		mysql_fetch_float(z);
		format(string, 256,"SELECT angulo FROM `carros` WHERE id = '%d' LIMIT 1", b);
		mysql_query(string);
		mysql_store_result();
		mysql_fetch_float(angulo);
		format(string, 256,"SELECT modelo FROM `carros` WHERE id = '%d' LIMIT 1", b);
		mysql_query(string);
		mysql_store_result();
		modelo = mysql_fetch_int();
		format(string, 256,"SELECT gasolina FROM `carros` WHERE id = '%d' LIMIT 1", 2);
		mysql_query(string);
		mysql_store_result();
		gasolina = mysql_fetch_int();
		printf("Dono = %s", dono);
		printf("X = %f", x);
		printf("Modelo = %d", gasolina);
		}
	}
	return 1;
}

This code and to load my cars that are in the database. However when I run this code the samp-server closes. And when I mention it's the query is normal.

What can this be?
Sorry my bad english. I am brazilian
dioguitosbr is offline  
Old 09/11/2009, 06:55 PM   #2
Marcel
Huge Clucker
 
Join Date: Nov 2007
Posts: 382
Reputation: 2
Default Re: [MySQL] samp-server quits when you run query

Have a look at my code:
pawn Code:
stock LoadVehicles( )
{
    new
        ID ,
        Modelid ,
        Float:Spawn_X ,
        Float:Spawn_Y ,
        Float:Spawn_Z ,
        Float:Angle ,
        Color1 ,
        Color2 ,
        Respawn_delay ,
        line[ 1024 ] ;
    mysql_query( "SELECT * FROM `vehicles`" );
    mysql_store_result( );
    while( mysql_fetch_row_format( line , "|" ) )
    {
        sscanf( line , "p|iiffffiii" , ID , Modelid , Spawn_X , Spawn_Y , Spawn_Z , Angle , Color1 , Color2 , Respawn_delay );
        CreateVehicle( Modelid , Spawn_X , Spawn_Y , Spawn_Z , Angle , Color1 , Color2 , Respawn_delay ) );
    }
    mysql_free_result( );
    return 1;
}
It needs some adjustments here and there for you. But that is up to you!
Marcel is offline  
Old 09/11/2009, 07:03 PM   #3
Streetplaya
Gangsta
 
Join Date: Nov 2007
Posts: 603
Reputation: 1
Default Re: [MySQL] samp-server quits when you run query

Make sure you're connected.
Streetplaya is offline  
 

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
samp server.exe quits? bartje01 Server Support 4 08/02/2010 02:42 PM
server quits after using a cmd that opens a menu bartje01 Server Support 0 08/02/2010 02:31 PM
[MySQL]Need help with a query lauri865 Help Archive 0 19/09/2009 05:36 PM
Server crash after sending query to mysql Vince Help Archive 0 15/07/2009 11:45 AM
mysql query. Think Help Archive 3 11/03/2009 05:27 PM


All times are GMT. The time now is 11:03 AM.


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