MySQL Help please - 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 Help please (
/showthread.php?tid=111216)
MySQL Help please -
Cem - 30.11.2009
i need it so that it read the feilds as its all set in the MySQL database, i just need it to read them and create the vehicle, i'm new with MySQL so help would be so great.
pawn Код:
stock LoadPlayerVehicles()
{
samp_mysql_query("SELECT * FROM Vehicles");
samp_mysql_store_result();
if(samp_mysql_num_rows())
{
new Car,result[256];
while(samp_mysql_fetch_row(result))
{
sscanf(result,"p|d",Car);
sscanf(result,"p|dffffddssddd",VehInfo[Car][cModel],VehInfo[Car][cLocationx],VehInfo[Car][cLocationy],VehInfo[Car][cLocationz],VehInfo[Car][cAngle],VehInfo[Car][cColorOne],VehInfo[Car][cColorTwo],VehInfo[Car][cOwner],VehInfo[Car][cDescription],VehInfo[Car][cValue],VehInfo[Car][cOwned],VehInfo[Car][cLock]);
AddStaticVehicleEx(VehInfo[Car][cModel],VehInfo[Car][cLocationx],VehInfo[Car][cLocationy],VehInfo[Car][cLocationz]+1.0,VehInfo[Car][cAngle],VehInfo[Car][cColorOne],VehInfo[Car][cColorTwo],-1);
printf( "Car Spawned");
}
}
}
if you could show me how it should be done thanks so much to those who help!
Re: MySQL Help please -
Cem - 30.11.2009
will someone help me then please?
Re: MySQL Help please -
Cem - 01.12.2009
BUMP* please help.
Re: MySQL Help please -
Marcel - 01.12.2009
This is my (working) code to load vehicles:
pawn Код:
stock LoadVehicles( )
{
MySQLCheck( );
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 );
Itter_Add(Vehicle, CreateVehicle( Modelid , Spawn_X , Spawn_Y , Spawn_Z , Angle , Color1 , Color2 , Respawn_delay ) );
}
mysql_free_result( );
return 1;
}