Veh ID mysql problem
#8

Thank you guys i fix that. But now i have another problem with vehicle load. I dont have any errors or warnings but just dont load created cars. I think it is playerid problem. MAX_PLAYERS are defined as 201.

Код:
forward OnVehiclesLoad( playerid, targetid, moneyauc );
public OnVehiclesLoad( playerid, targetid, moneyauc ) {

	new rows, vehicleid;
   	cache_get_row_count(rows);

	if( rows ) {
		for( new i = 0; i < rows; i ++ ){

			cache_get_value_name_int( i, "v_model", VehicleInfo[ i ][ vModel ] );
			cache_get_value_name_float( i, "v_pos_x", VehicleInfo[ i ][ vLokacijaX ] );
			cache_get_value_name_float( i, "v_pos_y", VehicleInfo[ i ][ vLokacijaY ] );
			cache_get_value_name_float( i, "v_pos_z", VehicleInfo[ i ][ vLokacijaZ ] );
			cache_get_value_name_float( i, "v_pos_a", VehicleInfo[ i ][ vLokacijaA ] );
			cache_get_value_name_int( i, "v_color_1", VehicleInfo[ i ][ vColor1 ] );
			cache_get_value_name_int( i, "v_color_2", VehicleInfo[ i ][ vColor2 ] );

			vehicleid = KGEyes_CreateVehicle( VehicleInfo[ i ][ vModel ], VehicleInfo[ i ][ vLokacijaX ], VehicleInfo[ i ][ vLokacijaY ], VehicleInfo[ i ][ vLokacijaZ ]+1.0, VehicleInfo[ i ][ vLokacijaA ], VehicleInfo[ i ][ vColor1 ], VehicleInfo[ i ][ vColor2 ], 300000 );



            cache_get_value_name_int( i, "veh_id", VehicleInfo[ vehicleid ][ vSqlID ] );
			cache_get_value_name_int( i, "owner_sqlID", VehicleInfo[ vehicleid ][ vOwner_sqlID ] );
			strmid( VehicleInfo[ vehicleid ][ vOwner ], ImeIgraca( playerid ), 0, strlen( ImeIgraca( playerid ) ), 24);
			cache_get_value_name_int( i, "v_price", VehicleInfo[ vehicleid ][ vPrice ] );
			cache_get_value_name_int( i, "v_locked", VehicleInfo[ vehicleid ][ vLocked ] );
			cache_get_value_name_float( i, "v_pos_x", VehicleInfo[ vehicleid ][ vLokacijaX ] );
			cache_get_value_name_float( i, "v_pos_y", VehicleInfo[ vehicleid ][ vLokacijaY ] );
			cache_get_value_name_float( i, "v_pos_z", VehicleInfo[ vehicleid ][ vLokacijaZ ] );
			cache_get_value_name_float( i, "v_pos_a", VehicleInfo[ vehicleid ][ vLokacijaA ] );
			cache_get_value_name_int( i, "v_virtualw", VehicleInfo[ vehicleid ][ vVirtualWorld ] );
			cache_get_value_name_int( i, "v_interior", VehicleInfo[ vehicleid ][ vInterior ] );
			cache_get_value_name_int( i, "v_usage", VehicleInfo[ vehicleid ][ vUsage ] );
			cache_get_value_name_int( i, "v_organization", VehicleInfo[ vehicleid ][ vOrganizationSQLID ] );
			VehicleInfo[ vehicleid ][ vOrganization ] = -1;

			if( VehicleInfo[ vehicleid ][ vOrganizationSQLID ] != 0 ) {
                for( new j = 1; j < MAX_ORG; j++) {
			        if( org_info[ j ][ oID ] == VehicleInfo[ vehicleid ][ vOrganizationSQLID ] ) {
			            VehicleInfo[ vehicleid ][ vOrganization ] = j;
			            break;
			        }
			    }
			}

			cache_get_value_name_int( i, "v_job", VehicleInfo[ vehicleid ][ vJob ] );
			cache_get_value_name_int( i, "v_fuel_station", VehicleInfo[ vehicleid ][ vFuelStation ] );
			cache_get_value_name_int( i, "v_color_1", VehicleInfo[ vehicleid ][ vColor1 ] );
			cache_get_value_name_int( i, "v_color_2", VehicleInfo[ vehicleid ][ vColor2 ] );
			cache_get_value_name_int( i, "v_model", VehicleInfo[ vehicleid ][ vModel ] );
			cache_get_value_name_int( i, "v_teh", VehicleInfo[ vehicleid ][ vTeh ] );
			cache_get_value_name_int( i, "v_reg", VehicleInfo[ vehicleid ][ vReg ] );
			cache_get_value_name_int( i, "v_reg_vreme", VehicleInfo[ vehicleid ][ vRegVreme ] );
			cache_get_value_name( i, "v_tablice", VehicleInfo[ vehicleid ][ vTablice ], 16 );
			cache_get_value_name_int( i, "v_gps", VehicleInfo[ vehicleid ][ vGPS ] );
			cache_get_value_name_int( i, "v_insurance", VehicleInfo[ vehicleid ][ vOsiguranje ] );
			cache_get_value_name_int( i, "v_lock", VehicleInfo[ vehicleid ][ vLock ] );
			cache_get_value_name_int( i, "v_alarm", VehicleInfo[ vehicleid ][ vAlarm ] );
			cache_get_value_name_int( i, "v_fuel", VehicleInfo[ vehicleid ][ vFuel ] );
			cache_get_value_name_int( i, "v_fuel_type", VehicleInfo[ vehicleid ][ vFuelType ] );
			cache_get_value_name_int( i, "v_neon", VehicleInfo[ vehicleid ][ vNeon ] );
		    cache_get_value_name_int( i, "v_tuned", VehicleInfo[ vehicleid ][ vTuned ] );
			cache_get_value_name_int( i, "v_imobilizator", VehicleInfo[ vehicleid ][ vImobilizator ] );
			cache_get_value_name_int( i, "v_spoiler", VehicleInfo[ vehicleid ][ vSpoiler ] );
			cache_get_value_name_int( i, "v_hood", VehicleInfo[ vehicleid ][ vHood ] );
			cache_get_value_name_int( i, "v_roof", VehicleInfo[ vehicleid ][ vRoof ] );
			cache_get_value_name_int( i, "v_skirt", VehicleInfo[ vehicleid ][ vSkirt ] );
			cache_get_value_name_int( i, "v_lamps", VehicleInfo[ vehicleid ][ vLamps ] );
			cache_get_value_name_int( i, "v_nitro", VehicleInfo[ vehicleid ][ vNitro ] );
			cache_get_value_name_int( i, "v_exhaust", VehicleInfo[ vehicleid ][ vExhaust ] );
			cache_get_value_name_int( i, "v_wheels", VehicleInfo[ vehicleid ][ vWheels ] );
			cache_get_value_name_int( i, "v_stereo", VehicleInfo[ vehicleid ][ vStereo ] );
			cache_get_value_name_int( i, "v_hydraulics", VehicleInfo[ vehicleid ][ vHydraulics ] );
			cache_get_value_name_int( i, "v_front_bumper", VehicleInfo[ vehicleid ][ vFrontBumper ] );
			cache_get_value_name_int( i, "v_rear_bumper", VehicleInfo[ vehicleid ][ vRearBumper ] );
			cache_get_value_name_int( i, "v_vents", VehicleInfo[ vehicleid ][ vVents ] );
			cache_get_value_name_int( i, "v_paintjob", VehicleInfo[ vehicleid ][ vPaintJob ] );
			cache_get_value_name_int( i, "v_drug_ammount_1", VehicleInfo[ vehicleid ][ vDrugAmmount ][ 0 ] );
			cache_get_value_name_int( i, "v_drug_ammount_2", VehicleInfo[ vehicleid ][ vDrugAmmount ][ 1 ] );
			cache_get_value_name_int( i, "v_drug_ammount_3", VehicleInfo[ vehicleid ][ vDrugAmmount ][ 2 ] );
			cache_get_value_name_int( i, "v_drug_ammount_4", VehicleInfo[ vehicleid ][ vDrugAmmount ][ 3 ] );
			cache_get_value_name_int( i, "v_drug_ammount_5", VehicleInfo[ vehicleid ][ vDrugAmmount ][ 4 ] );
			cache_get_value_name_int( i, "v_drug_ammount_6", VehicleInfo[ vehicleid ][ vDrugAmmount ][ 5 ] );
			cache_get_value_name_int( i, "v_mats", VehicleInfo[ vehicleid ][ vMaterijali ] );
			cache_get_value_name_int( i, "v_weapon_melee", VehicleInfo[ vehicleid ][ vMelee ] );
			cache_get_value_name_int( i, "v_weapon_slot_1", VehicleInfo[ vehicleid ][ vWeap1 ] );
			cache_get_value_name_int( i, "v_weapon_ammo_1", VehicleInfo[ vehicleid ][ vAmmo1 ] );
			cache_get_value_name_int( i, "v_weapon_slot_2", VehicleInfo[ vehicleid ][ vWeap2 ] );
			cache_get_value_name_int( i, "v_weapon_ammo_2", VehicleInfo[ vehicleid ][ vAmmo2 ] );
			cache_get_value_name_int( i, "v_gajbica_slot_1", VehicleInfo[ vehicleid ][ vGajbica ][ 0 ] );
			cache_get_value_name_int( i, "v_gajbica_slot_2", VehicleInfo[ vehicleid ][ vGajbica ][ 1 ] );
			cache_get_value_name_int( i, "v_gajbica_slot_3", VehicleInfo[ vehicleid ][ vGajbica ][ 2 ] );
			cache_get_value_name_int( i, "v_gajbica_slot_4", VehicleInfo[ vehicleid ][ vGajbica ][ 3 ] );
			cache_get_value_name_int( i, "v_gajbica_slot_5", VehicleInfo[ vehicleid ][ vGajbica ][ 4 ] );
			cache_get_value_name_int( i, "v_gajbica_kolicina_1", VehicleInfo[ vehicleid ][ vGajbicaAmmount ][ 0 ] );
			cache_get_value_name_int( i, "v_gajbica_kolicina_2", VehicleInfo[ vehicleid ][ vGajbicaAmmount ][ 1 ] );
			cache_get_value_name_int( i, "v_gajbica_kolicina_3", VehicleInfo[ vehicleid ][ vGajbicaAmmount ][ 2 ] );
			cache_get_value_name_int( i, "v_gajbica_kolicina_4", VehicleInfo[ vehicleid ][ vGajbicaAmmount ][ 3 ] );
			cache_get_value_name_int( i, "v_gajbica_kolicina_5", VehicleInfo[ vehicleid ][ vGajbicaAmmount ][ 4 ] );
			cache_get_value_name_int( i, "v_kilometri", VehicleInfo[ vehicleid ][ vKilometri ] );
			cache_get_value_name_int( i, "v_metri", VehicleInfo[ vehicleid ][ vMetri ] );
			VehicleInfo[ vehicleid ][ v_owner_id ] = -1;

			LinkVehicleToInterior( vehicleid, VehicleInfo[ vehicleid ][ vInterior ] );
	        SetVehicleVirtualWorld( vehicleid, VehicleInfo[ vehicleid ][ vVirtualWorld ] );
			vCanDrive[ vehicleid ] = 1;

           	VehicleInfo[ vehicleid ][ Validv3DText ] = false;
	    	if( VehicleInfo[ vehicleid ][ vFuelType ] == 0 ) {

				if( Diesel( vehicleid ) ) VehicleInfo[ vehicleid ][ vFuelType ] = 1;
				else if( Gasoline( vehicleid ) ) VehicleInfo[ vehicleid ][ vFuelType ] = 2;
				else if( GasOil( vehicleid ) ) VehicleInfo[ vehicleid ][ vFuelType ] = 3;
			}

	        SetVehicleParamsEx( vehicleid, 0, 0, 0, VehicleInfo[ vehicleid ][ vLocked ], 0, 0, 0 );
	        if( IsVehicleBajs( vehicleid ) ) {
				SetVehicleParamsEx( vehicleid, 1, 0, 0, VehicleInfo[ vehicleid ][ vLocked ], 0, 0, 0 );
			}
	        ResetVehicleStatistics( vehicleid );
			VehicleInfo[ vehicleid ][ vFuel ] = getAmountFuel( vehicleid );

	   		if( VehicleInfo[ vehicleid ][ vUsage ] == PRIVATNO_VOZILO ) {
	    	    Fuel[ vehicleid ] = VehicleInfo[ vehicleid ][ vFuel ];
	    	}
			else if( VehicleInfo[ vehicleid ][ vUsage ] == POSLOVNO_VOZILO ) {
			    VehicleInfo[ vehicleid ][ vFuel ] = 100;
			    Fuel[ vehicleid ] = 100;
			}
			else {
			    Fuel[ vehicleid ] = getAmountFuel( vehicleid );
			}

			SetVehicleLabels( vehicleid );

			if( VehicleInfo[ vehicleid ][ vReg ] == 1 ) {
				SetTablice( vehicleid );
			}
			else if( VehicleInfo[ vehicleid ][ vReg ] == 2 ) {
				SetVehicleNumberPlate( vehicleid, VehicleInfo[ vehicleid ][ vTablice ] );
			}
			else  {
				SetVehicleNumberPlate( vehicleid, "NEMA" );
			}

			TuneVehicle( vehicleid );

            if( VehicleInfo[ vehicleid ][ vUsage ] == PUMPA_VOZILO ) {

                new fstationID = VehicleInfo[ vehicleid ][ vFuelStation ];

				if( VehicleInfo[ vehicleid ][ vModel ] == 584 ) {
					FuelStation[ fstationID ][ fsCisternID ] = vehicleid;
				}
				else if( VehicleInfo[ vehicleid ][ vModel ] == 403 ) {
					FuelStation[ fstationID ][ fsTruckID ] = vehicleid;
				}

			}

	        #if ZIMSKI_MOD == 1
			if( VehicleInfo[ vehicleid ][ vUsage ] == POSLOVNO_VOZILO && VehicleInfo[ vehicleid ][ vJob ] == POSAO_KOMUNALAC && VehicleInfo[ vehicleid ][ vModel ] == 455 ) {

		 		SnowObjects[ vehicleid ] = true;

			    SnowObject1[ vehicleid ] = CreateDynamicObject( 19601, 0, 0, 1500, 0, 0, 0 );
				AttachDynamicObjectToVehicle( SnowObject1[ vehicleid ], vehicleid, 0.000000, 4.200001, -1.049999, 13.500000, 0.000000, 180.000 );

				SnowObject2[ vehicleid ] = CreateDynamicObject( 18646, 0, 0, 1500, 0, 0, 0 );
				AttachDynamicObjectToVehicle( SnowObject2[ vehicleid ], vehicleid, 0.749999, 1.575000, 1.725000, 0.000000, 0.000000, 0.000000 );
			}
			#endif

			if( playerid != 201 ) {
			    SendInfoMessage( playerid, "Dodali ste vozilo %s sa aukcije, igracu %s za %d$.", GetVehicleNameEx( VehicleInfo[ vehicleid ][ vModel ] ), ImeIgraca( targetid ), moneyauc );

				new string[ 128 ];
                format( string, sizeof( string ), "AUKCIJA VOZILO SQLID: %d | Prodano igracu %s od admina %s ", VehicleInfo[ vehicleid ][ vSqlID ], ImeIgraca( targetid ), ImeIgraca( playerid ) );
				LogSave( "Ostalo/LogAukcije.log", string );
			}

			if( targetid != 201 && targetid != IPI ) {

			    for( new j = 0; j < MAX_VEH_SLOT; j ++ ){
	                if( (j+1) <= PlayerInfo[ targetid ][ xSlotoviVozila ] && player_veh[ targetid ][ vehicle_id ][ j ] == -1 ) {
						player_veh[ targetid ][ vehicle_id ][ j ] = vehicleid;
						break;
					}
				}

				VehicleInfo[ vehicleid ][ v_owner_id ] = targetid;
				VehicleInfo[ vehicleid ][ vOwner_sqlID ] = PlayerInfo[ targetid ][ xID ];
				strmid( VehicleInfo[ vehicleid ][ vOwner ], ImeIgraca( targetid ), 0, strlen( ImeIgraca( targetid ) ), 32 );

                VehicleInfo[ vehicleid ][ vPrice ] = VehPrice[ VehicleInfo[ vehicleid ][ vModel ]- 400 ][ 1 ];

                new Float:plocx, Float:plocy, Float:plocz, Float:carangle;
				GetPlayerPos( targetid, plocx, plocy, plocz );
				KGEyes_SetVehiclePos( vehicleid, plocx, plocy+4, plocz );
                GetVehicleZAngle( vehicleid, carangle );

                VehicleInfo[ vehicleid ][ vVirtualWorld ] = GetPlayerVirtualWorld( targetid );
				VehicleInfo[ vehicleid ][ vInterior ] = GetPlayerInterior( targetid );

				VehicleInfo[ vehicleid ][ vLokacijaX ] = plocx;
				VehicleInfo[ vehicleid ][ vLokacijaY ] = plocy;
				VehicleInfo[ vehicleid ][ vLokacijaZ ] = plocz;
				VehicleInfo[ vehicleid ][ vLokacijaA ] = carangle;

				LinkVehicleToInterior( vehicleid, VehicleInfo[ vehicleid ][ vInterior ] );
		    	SetVehicleVirtualWorld( vehicleid, VehicleInfo[ vehicleid ][ vVirtualWorld ] );

				new q[ 512 ];
				mysql_format( _dbConnector, q, sizeof(q), "UPDATE `vehicles` SET `owner_sqlID` = '%d', `v_price` = '%d', `v_pos_x` = '%f', `v_pos_y` = '%f', `v_pos_z` = '%f', `v_pos_a` = '%f', `v_virtualw` = '%d', `v_interior` = '%d' WHERE `veh_id` = '%d' LIMIT 1",
										VehicleInfo[ vehicleid ][ vOwner_sqlID ],
										VehicleInfo[ vehicleid ][ vPrice ],
										VehicleInfo[ vehicleid ][ vLokacijaX ],
										VehicleInfo[ vehicleid ][ vLokacijaY ],
										VehicleInfo[ vehicleid ][ vLokacijaZ ],
										VehicleInfo[ vehicleid ][ vLokacijaA ],
										VehicleInfo[ vehicleid ][ vVirtualWorld ],
										VehicleInfo[ vehicleid ][ vInterior ],
										VehicleInfo[ vehicleid ][ vSqlID ] );

				mysql_tquery( _dbConnector, q);

				SendInfoMessage( targetid, "Dobili ste vozilo %s sa aukcije, od admina %s za %d$.", GetVehicleNameEx( VehicleInfo[ vehicleid ][ vModel ] ), ImeIgraca( playerid ), moneyauc );

				if( moneyauc != 0 ) DajIgracuNovac( targetid, -moneyauc );


			}
		}
	}
	else {
		if( playerid != 201 ) {
		    SendInfoMessage( playerid, "Pogresan basesqlID(nepostoji)." );
		}
	}
	return (true);
 }
I call OnVehiclesLoad with this
Код:
	    new qa[ 256 ];
	    mysql_format( _dbConnector, qa, sizeof( qa ), "SELECT * FROM `vehicles` WHERE `v_usage` != '1' ORDER BY veh_id ASC" );
		mysql_pquery( _dbConnector, qa, "OnVehiclesLoad", "iii", 201, 201, 0 );
Reply


Messages In This Thread
Veh ID mysql problem - by expressoboy123 - 18.04.2018, 21:58
Re: Veh ID mysql problem - by arakuta - 19.04.2018, 11:23
Re: Veh ID mysql problem - by jasperschellekens - 19.04.2018, 12:42
Re: Veh ID mysql problem - by expressoboy123 - 19.04.2018, 14:45
Re: Veh ID mysql problem - by UFF - 19.04.2018, 15:01
Re: Veh ID mysql problem - by jasperschellekens - 19.04.2018, 15:18
Re: Veh ID mysql problem - by UFF - 19.04.2018, 15:31
Re: Veh ID mysql problem - by expressoboy123 - 20.04.2018, 22:15

Forum Jump:


Users browsing this thread: 2 Guest(s)