Need a hand (or two)
#1

I'm editing a script, this one: https://sampforum.blast.hk/showthread.php?tid=641235
I want to make it where if you spawn/buy a vehicle the vehicle ID of said vehicle gets saved in the mySQL
for buying vehicles it works fine, but when I create a new personal vehicle (spawning one in) it does not work. For some reason it does not recognize the [ID] on the "LoadPirvateVehicle" Query but it does work on the "OnPlayerVehiclePurchase" Query. I hope I'm making any sense because I do not quite know how to explain this.
Thanks in advance!

Here it does not work:
( PlayerInfo[playerid][pOwnedVehiclesID][id] = vehicleid; >> undefined symbol "id" )
PHP код:
function:Query_LoadPrivateVehicle(playerid)
{
    if(!
cache_num_rows())
        return 
SendErrorMessage(playerid"An error occurred while loading your vehicle.");
    new 
rowsfieldscache_get_data(rowsfieldsourConnection);
    new 
str[128], vehicleid INVALID_VEHICLE_ID;
    for (new 
0rows && MAX_VEHICLESi++)
    {
        
vehicleid CreateVehicle(cache_get_field_content_int(i"VehicleModel"ourConnection),
            
cache_get_field_content_float(i"VehicleParkPosX"ourConnection),
            
cache_get_field_content_float(i"VehicleParkPosY"ourConnection),
            
cache_get_field_content_float(i"VehicleParkPosZ"ourConnection),
            
cache_get_field_content_float(i"VehicleParkPosA"ourConnection),
            
cache_get_field_content_int(i"VehicleColor1"ourConnection),
            
cache_get_field_content_int(i"VehicleColor2"ourConnection),
            -
1,
            
0);
        if(
vehicleid != INVALID_VEHICLE_ID)
        {
            
VehicleInfo[vehicleid][eVehicleExists] = true;
            
VehicleInfo[vehicleid][eVehicleDBID] = cache_get_field_content_int(i"VehicleDBID"ourConnection);
            
VehicleInfo[vehicleid][eVehicleOwnerDBID] = cache_get_field_content_int(i"VehicleOwnerDBID"ourConnection);
            
VehicleInfo[vehicleid][eVehicleFaction] = cache_get_field_content_int(i"VehicleFaction"ourConnection);
            
VehicleInfo[vehicleid][eVehicleModel] = cache_get_field_content_int(i"VehicleModel"ourConnection);
            
VehicleInfo[vehicleid][eVehicleColor1] = cache_get_field_content_int(i"VehicleColor1"ourConnection);
            
VehicleInfo[vehicleid][eVehicleColor2] = cache_get_field_content_int(i"VehicleColor2"ourConnection);
            
VehicleInfo[vehicleid][eVehicleParkPos][0] = cache_get_field_content_float(i"VehicleParkPosX"ourConnection);
            
VehicleInfo[vehicleid][eVehicleParkPos][1] = cache_get_field_content_float(i"VehicleParkPosY"ourConnection);
            
VehicleInfo[vehicleid][eVehicleParkPos][2] = cache_get_field_content_float(i"VehicleParkPosZ"ourConnection);
            
VehicleInfo[vehicleid][eVehicleParkPos][3] = cache_get_field_content_float(i"VehicleParkPosA"ourConnection);
            
VehicleInfo[vehicleid][eVehicleParkInterior] = cache_get_field_content_int(i"VehicleParkInterior"ourConnection);
            
VehicleInfo[vehicleid][eVehicleParkWorld] = cache_get_field_content_int(i"VehicleParkWorld"ourConnection);
            
cache_get_field_content(i"VehiclePlates"VehicleInfo[vehicleid][eVehiclePlates], ourConnection32);
            
VehicleInfo[vehicleid][eVehicleLocked] = bool:cache_get_field_content_int(i"VehicleLocked"ourConnection);
            
VehicleInfo[vehicleid][eVehicleImpounded] = bool:cache_get_field_content_int(i"VehicleImpounded"ourConnection);
            
VehicleInfo[vehicleid][eVehicleImpoundPos][0] = cache_get_field_content_float(i"VehicleImpoundPosX"ourConnection);
            
VehicleInfo[vehicleid][eVehicleImpoundPos][1] = cache_get_field_content_float(i"VehicleImpoundPosY"ourConnection);
            
VehicleInfo[vehicleid][eVehicleImpoundPos][2] = cache_get_field_content_float(i"VehicleImpoundPosZ"ourConnection);
            
VehicleInfo[vehicleid][eVehicleImpoundPos][3] = cache_get_field_content_float(i"VehicleImpoundPosA"ourConnection);
            
VehicleInfo[vehicleid][eVehicleFuel] = cache_get_field_content_int(i"VehicleFuel"ourConnection);
            
VehicleInfo[vehicleid][eVehicleHasXMR] = bool:cache_get_field_content_int(i"VehicleXMR"ourConnection);
            
VehicleInfo[vehicleid][eVehicleTimesDestroyed] = cache_get_field_content_int(i"VehicleTimesDestroyed"ourConnection);
            
VehicleInfo[vehicleid][eVehicleEngine] = cache_get_field_content_float(i"VehicleEngine"ourConnection);
            
VehicleInfo[vehicleid][eVehicleBattery] = cache_get_field_content_float(i"VehicleBattery"ourConnection);
            
VehicleInfo[vehicleid][eVehicleAlarmLevel] = cache_get_field_content_int(i"VehicleAlarmLevel"ourConnection);
            
VehicleInfo[vehicleid][eVehicleLockLevel] = cache_get_field_content_int(i"VehicleLockLevel"ourConnection);
            
VehicleInfo[vehicleid][eVehicleImmobLevel] = cache_get_field_content_int(i"VehicleImmobLevel"ourConnection);
            for(new 
16j++)
            {
                
format(strsizeof(str), "VehicleWeapons%d"j);
                
VehicleInfo[vehicleid][eVehicleWeapons][j] = cache_get_field_content_int(istrourConnection);
                
format(strsizeof(str), "VehicleWeaponsAmmo%d"j);
                
VehicleInfo[vehicleid][eVehicleWeaponsAmmo][j] = cache_get_field_content_int(istrourConnection);
            }
            for(new 
15d++)
            {
                
format(strsizeof(str), "VehicleLastDrivers%d"d);
                
VehicleInfo[vehicleid][eVehicleLastDrivers][d] = cache_get_field_content_int(istrourConnection);
                
format(strsizeof(str), "VehicleLastPassengers%d"d);
                
VehicleInfo[vehicleid][eVehicleLastPassengers][d] = cache_get_field_content_int(istrourConnection);
            }
            if(
VehicleInfo[vehicleid][eVehicleParkInterior] != 0)
            {
                
LinkVehicleToInterior(vehicleidVehicleInfo[vehicleid][eVehicleParkInterior]);
                
SetVehicleVirtualWorld(vehicleidVehicleInfo[vehicleid][eVehicleParkWorld]);
            }
            if(!
isnull(VehicleInfo[vehicleid][eVehiclePlates]))
            {
                
SetVehicleNumberPlate(vehicleidVehicleInfo[vehicleid][eVehiclePlates]);
                
SetVehicleToRespawn(vehicleid);
            }
            if(
VehicleInfo[vehicleid][eVehicleImpounded] == true)
            {
                
SetVehiclePos(vehicleidVehicleInfo[vehicleid][eVehicleImpoundPos][0], VehicleInfo[vehicleid][eVehicleImpoundPos][1], VehicleInfo[vehicleid][eVehicleImpoundPos][2]);
                
SetVehicleZAngle(vehicleidVehicleInfo[vehicleid][eVehicleImpoundPos][3]);
            }
            if(
VehicleInfo[vehicleid][eVehicleLocked] == false)
                
SetVehicleParamsEx(vehicleid0000000);
            else 
SetVehicleParamsEx(vehicleid0001000);
            
VehicleInfo[vehicleid][eVehicleAdminSpawn] = false;
            if(
HasNoEngine(playerid))
                
ToggleVehicleEngine(vehicleidtrue);
        }
    }
    
PlayerInfo[playerid][pVehicleSpawnedID] = vehicleid;
    
PlayerInfo[playerid][pOwnedVehiclesID][id] = vehicleid;
    
SendClientMessageEx(playeridCOLOR_DARKGREEN"%s has been spawned at its parking place."ReturnVehicleName(vehicleid));
    
SendClientMessageEx(playeridCOLOR_WHITE"Lifespan: Engine Life[%.2f], Battery Life[%.2f], Times Destroyed[%d]"VehicleInfo[vehicleid][eVehicleEngine], VehicleInfo[vehicleid][eVehicleBattery], VehicleInfo[vehicleid][eVehicleTimesDestroyed]);
    if(
VehicleInfo[vehicleid][eVehicleImpounded]) SendClientMessage(playeridCOLOR_RED"Your vehicle is impounded.");
    
SendClientMessage(playerid0xFF00FFFF"Hint: Follow the red marker to your parking place.");
    
SetPlayerCheckpoint(playeridVehicleInfo[vehicleid][eVehicleParkPos][0], VehicleInfo[vehicleid][eVehicleParkPos][1], VehicleInfo[vehicleid][eVehicleParkPos][2], 3.0);
    
PlayerCheckpoint[playerid] = 1;
    
SaveCharacter(playerid);
    return 
1;

Here it does work:
( PlayerInfo[playerid][pOwnedVehiclesID][id] = vehicleid; >> Saves the vehicle ID in the mySQL under pOwnedVehiclesID[1 or 2 or 3 or 4 or 5] )
PHP код:
function:OnPlayerVehiclePurchase(playerididplates[], Float:xFloat:yFloat:zFloat:a)
{
    new
        
vehicleid INVALID_VEHICLE_ID
    
;
    
    
DestroyVehicle(DealershipPlayerCar[playerid]);
    
    
vehicleid 
        
CreateVehicle(g_aDealershipData[SubDealershipHolder[playerid]][eDealershipModelID], xyzaDealershipCarColors[playerid][0], DealershipCarColors[playerid][1], -1);  
        
    
SetVehicleNumberPlate(vehicleidplates); 
    
SetVehicleToRespawn(vehicleid); 
    
    
PutPlayerInVehicle(playeridvehicleid0); 
     
PlayerInfo[playerid][pOwnedVehicles][id] = cache_insert_id();
     
PlayerInfo[playerid][pOwnedVehiclesID][id] = vehicleid;
    
    if(
vehicleid != INVALID_VEHICLE_ID)
    {
        
VehicleInfo[vehicleid][eVehicleDBID] = cache_insert_id();
        
VehicleInfo[vehicleid][eVehicleOwnerDBID] = PlayerInfo[playerid][pDBID]; 
        
        
VehicleInfo[vehicleid][eVehicleModel] = g_aDealershipData[SubDealershipHolder[playerid]][eDealershipModelID];
        
        
VehicleInfo[vehicleid][eVehicleColor1] = DealershipCarColors[playerid][0];
        
VehicleInfo[vehicleid][eVehicleColor2] = DealershipCarColors[playerid][1];
        
        
VehicleInfo[vehicleid][eVehiclePaintjob] = -1;
        
        
VehicleInfo[vehicleid][eVehicleParkPos][0] = x;
        
VehicleInfo[vehicleid][eVehicleParkPos][1] = y;
        
VehicleInfo[vehicleid][eVehicleParkPos][2] = z;
        
VehicleInfo[vehicleid][eVehicleParkPos][3] = a;
        
        
format(VehicleInfo[vehicleid][eVehiclePlates], 32"%s"plates); 
        
        
VehicleInfo[vehicleid][eVehicleLocked] = false;
        
VehicleInfo[vehicleid][eVehicleEngineStatus] = false;
        
        
VehicleInfo[vehicleid][eVehicleFuel] = 50
        
        
VehicleInfo[vehicleid][eVehicleBattery] = 100.0;
        
VehicleInfo[vehicleid][eVehicleEngine] = 100.0
        
        
VehicleInfo[vehicleid][eVehicleHasXMR] = bool:DealershipXMR[playerid];
        
VehicleInfo[vehicleid][eVehicleTimesDestroyed] = 0;
        
        
VehicleInfo[vehicleid][eVehicleAlarmLevel] = DealershipAlarmLevel[playerid];
        
VehicleInfo[vehicleid][eVehicleLockLevel] = DealershipLockLevel[playerid]; 
        
VehicleInfo[vehicleid][eVehicleImmobLevel] = DealershipImmobLevel[playerid]; 
        
        for(new 
1i6i++)
        {
            
VehicleInfo[vehicleid][eVehicleWeapons][i] = 0;
            
VehicleInfo[vehicleid][eVehicleWeaponsAmmo][i] = 0
        }
        
        
SaveVehicle(vehicleid);
    }
    
SendClientMessageEx(playerid0xB9E35EFF"PROCESSED: You successfully bought a %s for $%s."ReturnVehicleName(vehicleid), MoneyFormat(DealershipTotalCost[playerid]));
    
cmd_v(playerid"stats");
    
    
PlayerPurchasingVehicle[playerid] = false;
    
ResetDealershipVars(playerid); 
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)