[MySQL] samp-server quits when you run query - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [MySQL] samp-server quits when you run query (
/showthread.php?tid=107404)
[MySQL] samp-server quits when you run query -
dioguitosbr - 09.11.2009
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
Re: [MySQL] samp-server quits when you run query -
Marcel - 09.11.2009
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!
Re: [MySQL] samp-server quits when you run query -
Streetplaya - 09.11.2009
Make sure you're connected.