Won't load mysql data.
#1

Hey guys, can you please look through this code and see if anything is wrong?


PHP код:
stock LoadPVehicles()
{
    new
        
Query[1028],
        
vModel2,
        
vC[2],
        
vPrice2,
        
vOwner2[MAX_PLAYER_NAME],
        
Float:Pos[4],
        
vID,
        
PlateNum[32],
        
vPaint_Job,
        
vModsToLoad[12],
        
vLock;
    
mysql_query("SELECT * FROM `vehicles` WHERE `vID` < "#MAX_BUYABLE_VEH" ORDER BY vID");
    
mysql_store_result();
    if(
mysql_num_rows() > 0)
    {
        while(
mysql_fetch_row(Query))
        {
            
sscanf(Query"p<|>iiiiis[24]ffffs[32]iiiiiiiiiiiiii",
            
vIDvModel2vC[0], vC[1], vPrice2vOwner2Pos[0], Pos[1], Pos[2], Pos[3], PlateNumvPaint_Job,
            
vModsToLoad[0], vModsToLoad[1], vModsToLoad[2], vModsToLoad[3], vModsToLoad[4], vModsToLoad[5],
            
vModsToLoad[6], vModsToLoad[7], vModsToLoad[8], vModsToLoad[9], vModsToLoad[10], vModsToLoad[11], vLock);
            
vInfo[vID][vModel] = vModel2;                        //    printf("Model:\t\t%i", vModel2);
            
vInfo[vID][vColor1] = vC[0];                        //    printf("Color 1:\t%i", vC[0]);
            
vInfo[vID][vColor2] = vC[1];                        //    printf("Color 2:\t%i", vC[1]);
            
vInfo[vID][vPrice] = vPrice2;                        //    printf("Price:\t\t$%i", vPrice2);
            
strmid(vInfo[vID][vOwner], vOwner202424);     //    printf("Owner:\t\t%s", vOwner2);
            
vInfo[vID][vPosX] = Pos[0];                         //    printf("Spawn X:\t%f", Pos[0]);
            
vInfo[vID][vPosY] = Pos[1];                         //    printf("Spawn Y:\t%f", Pos[1]);
            
vInfo[vID][vPosZ] = Pos[2];                         //    printf("Spawn Z:\t%f", Pos[2]);
            
vInfo[vID][vPosA] = Pos[3];                         //    printf("Spawn A:\t%f", Pos[3]);
            
strmid(vInfo[vID][vPlate], PlateNum03232);     //    printf("Plate:\t\t%s", PlateNum);
            
vInfo[vID][vPaintJ] = vPaint_Job;                     //    printf("PaintJ:\t\t%i", vPaint_Job);
            
vInfo[vID][vLocked] = vLock;                         //    printf("Locked:\t\t%i", vLock);
            
vMods[vID][0] = vModsToLoad[0];                     //    printf("Mod 1:\t\t%i", vModsToLoad[0]);
            
vMods[vID][1] = vModsToLoad[1];                     //    printf("Mod 2:\t\t%i", vModsToLoad[1]);
            
vMods[vID][2] = vModsToLoad[2];                     //    printf("Mod 3:\t\t%i", vModsToLoad[2]);
            
vMods[vID][3] = vModsToLoad[3];                     //    printf("Mod 4:\t\t%i", vModsToLoad[3]);
            
vMods[vID][4] = vModsToLoad[4];                     //    printf("Mod 5:\t\t%i", vModsToLoad[4]);
            
vMods[vID][5] = vModsToLoad[5];                     //    printf("Mod 6:\t\t%i", vModsToLoad[5]);
            
vMods[vID][6] = vModsToLoad[6];                     //    printf("Mod 7:\t\t%i", vModsToLoad[6]);
            
vMods[vID][7] = vModsToLoad[7];                     //    printf("Mod 8:\t\t%i", vModsToLoad[7]);
            
vMods[vID][8] = vModsToLoad[8];                     //    printf("Mod 9:\t\t%i", vModsToLoad[8]);
            
vMods[vID][9] = vModsToLoad[9];                     //    printf("Mod 10:\t\t%i", vModsToLoad[9]);
            
vMods[vID][10] = vModsToLoad[10];                     //    printf("Mod 11:\t\t%i", vModsToLoad[10]);
            
vMods[vID][11] = vModsToLoad[11];                     //    printf("Mod 12:\t\t%i", vModsToLoad[11]);
            
new
                
vCarID CreateVehicle(vInfo[vID][vModel], vInfo[vID][vPosX], vInfo[vID][vPosY], vInfo[vID][vPosZ], vInfo[vID][vPosA], vInfo[vID][vColor1], vInfo[vID][vColor2], 500000);
            
SetVehicleNumberPlate(vCarIDvInfo[vID][vPlate]);
            
ChangeVehiclePaintjob(vCarIDvInfo[vID][vPaintJ]);
            for(new 
iMod 0iMod MAX_VEH_MODS; ++iMod)
            {
                if(
vMods[vCarID][iMod] > 0)
                {
                    
AddVehicleComponent(vCarIDvMods[vCarID][iMod]);
                }
            }
            
OwnedVeh(vCarID) = vID;
            ++ 
Total_Veh_Created;
        }
    }
    
mysql_free_result();
    
printf("** %i\t<->\tVehicles Loaded From\t<->\tMySQL\t\t   **"Total_Veh_Created);
    return 
Total_Veh_Created;

Reply
#2

pawn Код:
while(mysql_fetch_row(Query))
Change that to:

pawn Код:
while(mysql_fetch_row(Query,"|"))
Reply
#3

Didn't work
Reply
#4

I used this script somewhere, let me find it..

pawn Код:
stock LoadPVehicles()
{
    new
        Query[512],
        vModel2,
        vC[2],
        vPrice2,
        vOwner2[MAX_PLAYER_NAME],
        Float:Pos[4],
        vID,
        PlateNum[32],
        vPaint_Job,
        vLockedd,
        vOwnedd,
        vLevell,
        vTypee,
        vModsToLoad[17];

    mysql_query("SELECT * FROM `privateveh` WHERE `vID` < "#MAX_BUYABLE_VEH);
    mysql_store_result();

    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row_format(Query))
        {
            sscanf(Query, "p<|>iiiiis[24]ffffs[32]iiiiiiiiiiiiiiiiiiiiii", vID, vModel2, vC[0], vC[1], vPrice2, vOwner2, Pos[0], Pos[1], Pos[2], Pos[3], PlateNum, vPaint_Job,
            vModsToLoad[0], vModsToLoad[1], vModsToLoad[2], vModsToLoad[3], vModsToLoad[4], vModsToLoad[5], vModsToLoad[6], vModsToLoad[7], vModsToLoad[8], vModsToLoad[9], vModsToLoad[10], vModsToLoad[11],vModsToLoad[12],vModsToLoad[13],vModsToLoad[14],vModsToLoad[15],vModsToLoad[16],vLockedd,vOwnedd,vLevell,vTypee);
            vInfo[vID][vModel] = vModel2;
            vInfo[vID][vColor1] = vC[0];
            vInfo[vID][vColor2] = vC[1];
            vInfo[vID][vPrice] = vPrice2;
            strmid(vInfo[vID][vOwner], vOwner2, 0, 24, 24);
            vInfo[vID][vPosX] = Pos[0];
            vInfo[vID][vPosY] = Pos[1];
            vInfo[vID][vPosZ] = Pos[2];
            vInfo[vID][vPosA] = Pos[3];
            strmid(vInfo[vID][vPlate], PlateNum, 0, 32, 32);
            vInfo[vID][vPaintJ] = vPaint_Job;
            vMods[vID][0] = vModsToLoad[0];
            vMods[vID][1] = vModsToLoad[1];
            vMods[vID][2] = vModsToLoad[2];
            vMods[vID][3] = vModsToLoad[3];
            vMods[vID][4] = vModsToLoad[4];
            vMods[vID][5] = vModsToLoad[5];
            vMods[vID][6] = vModsToLoad[6];
            vMods[vID][7] = vModsToLoad[7];
            vMods[vID][8] = vModsToLoad[8];
            vMods[vID][9] = vModsToLoad[9];
            vMods[vID][10] = vModsToLoad[10];
            vMods[vID][11] = vModsToLoad[11];
            vMods[vID][12] = vModsToLoad[12];
            vMods[vID][13] = vModsToLoad[13];
            vMods[vID][14] = vModsToLoad[14];
            vMods[vID][15] = vModsToLoad[15];
            vMods[vID][16] = vModsToLoad[16];
            vInfo[vID][vLocked] = vLockedd;
            vInfo[vID][vOwned] = vOwnedd;
            vInfo[vID][vLevel] = vLevell;
            vInfo[vID][vType] = vTypee;
            if(vInfo[vID][vModel] != 0)
            {
                new
                 vCarID = CreateVehicle(vModel2, Pos[0], Pos[1], Pos[2], Pos[3], vC[0], vC[1], 500000);
                SetVehicleNumberPlate(vCarID, PlateNum);
                ChangeVehiclePaintjob(vCarID, vPaint_Job);
                Engine[vCarID] = 0;
                if(vInfo[vID][vOwned] == 0)
                {
                    vInfo[vID][vLocked] = 0;
                }
                new engine,lights,alarm,doors,bonnet,boot,objective;
                GetVehicleParamsEx(vCarID,engine,lights,alarm,doors,bonnet,boot,objective);
                if(vInfo[vID][vLocked] == 1)
                {
                    SetVehicleParamsEx(vCarID,engine,lights,alarm,1,bonnet,boot,objective);
                }
                else
                {
                    SetVehicleParamsEx(vCarID,engine,lights,alarm,0,bonnet,boot,objective);
                }
                Spawned[vCarID] = 0;
                for(new i = 0; i < MAX_VEH_MODS; i++)
                {
                    if(vMods[vCarID][i] > 0)
                    {
                        AddVehicleComponent(vCarID, vMods[vCarID][i]);
                    }
                }
                OwnedVeh(vCarID) = vID;
                RealID[vID] = vCarID;
                ++ Total_Veh_Created;
            }
        }
    }
    mysql_free_result();
    printf("** A total of: \"%i\" vehicle(s) were loaded!", vID);

    print("\n==============================================================");
    print("Car sys loaded.");
    print("==============================================================\n");
    return 1;
}
Change where necessary, and rep me !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)