MySQL Help please
#1

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!
Reply
#2

will someone help me then please?
Reply
#3

BUMP* please help.
Reply
#4

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)