Veh ID mysql problem -
expressoboy123 - 18.04.2018
Hello guys, i use dynamic vehicle system and when i create vehicle the veh_id is always 0.. Not 1,2,3 but only 0. I check in logs error or warnings but nothing is there. Here is the part of the createing the vehicle. I am using r 41-4 mysql. Here is the pic from base
http://prntscr.com/j73sv1
Код:
if( ServerInfo[ BrojKreiranihVozila ] > MaxBrojKreiranih ) return SCM( playerid, ANTICHEAT, "[ANTICHEAT]"col_white" Nemoguce je trenutno kreirati vozilo, limit vozila na serveru je dosegnut.");
new idauta, Float:PozX, Float:PozY, Float:PozZ, Float:PozA, boja1, boja2;
GetPlayerPos( playerid, PozX, PozY, PozZ );
GetPlayerFacingAngle( playerid, PozA );
if(carspawntimer == 1)
{
SendClientMessageEx( playerid, ANTICHEAT, "[ANTICHEAT]"col_white"Netko je spawnao/parkirao vozilo pre vas. Pokusajte za 3 sekunde. (Anticrash)");
return 1;
}
if( sscanf( inputtext, "iii", idauta, boja1, boja2 ) ) return SPD( playerid, dialog_RVCREATE, DSI, D_NASLOV, "Unesite id zeljenog auta za rent vozilo, id boje1, id boje2.", D_ODABERI, D_NAZAD );
if( idauta < 400 || idauta > 611 ) return SPD( playerid, dialog_RVCREATE, DSI, D_NASLOV, "Unesite id zeljenog auta za rent vozilo, id boje1, id boje2.", D_ODABERI, D_NAZAD );
if( boja1 < 0 || boja1 > 255 ) return SendErrorMessage( playerid, "Prva boja ne moze biti manja od 0 ili veca od 255.");
if( boja2 < 0 || boja2 > 255 ) return SendErrorMessage( playerid, "Druga boja ne moze biti manja od 0 ili veca od 255.");
sql_create_vehicle( idauta, RENTANO_VOZILO, -1, -1, -1, PozX, PozY, PozZ, PozA, boja1, boja2 );
SendInfoMessage( playerid, "Uspesno ste kreirali rent vozilo: ID Auta: %d",idauta );
Function sql_create_vehicle:
Код:
stock sql_create_vehicle( veh_model, veh_usage, veh_org = -1, veh_job = -1, veh_fs = -1, Float:veh_pos_x, Float:veh_pos_y, Float:veh_pos_z, Float:veh_pos_a, veh_col_1, veh_col_2 ) {
if( veh_model < 400 || veh_model > 611 ) return (true);
new i = INVALID_VEHICLE_ID;
i = KGEyes_CreateVehicle( veh_model, veh_pos_x, veh_pos_y, veh_pos_z+1.0, veh_pos_a, veh_col_1, veh_col_2, 300000 );
if( i == INVALID_VEHICLE_ID ) return (true);
VehicleInfo[ i ][ vSqlID ] = 0;
VehicleInfo[ i ][ vOwner_sqlID ] = 0;
VehicleInfo[ i ][ vKilometri ] = 0;
VehicleInfo[ i ][ vMetri ] = 0;
VehicleInfo[ i ][ vPrice ] = VehPrice[ veh_model-400 ][ 1 ];
strmid( VehicleInfo[ i ][ vOwner ], "Drzava", 0, strlen("Drzava"), 32);
VehicleInfo[ i ][ vLocked ] = 0;
VehicleInfo[ i ][ vLokacijaX ] = veh_pos_x;
VehicleInfo[ i ][ vLokacijaY ] = veh_pos_y;
VehicleInfo[ i ][ vLokacijaZ ] = veh_pos_z;
VehicleInfo[ i ][ vLokacijaA ] = veh_pos_a;
VehicleInfo[ i ][ vVirtualWorld ] = 0;
VehicleInfo[ i ][ vInterior ] = 0;
VehicleInfo[ i ][ vUsage ] = veh_usage;
VehicleInfo[ i ][ vJob ] = veh_job;
VehicleInfo[ i ][ vOrganization ] = veh_org;
if( veh_org != -1 ) VehicleInfo[ i ][ vOrganizationSQLID ] = org_info[ veh_org ][ oID ];
else VehicleInfo[ i ][ vOrganizationSQLID ] = 0;
VehicleInfo[ i ][ vFuelStation ] = veh_fs;
VehicleInfo[ i ][ vColor1 ] = veh_col_1;
VehicleInfo[ i ][ vColor2 ] = veh_col_2;
VehicleInfo[ i ][ vModel ] = veh_model;
VehicleInfo[ i ][ vReg ] = 1;
VehicleInfo[ i ][ vRegVreme ] = 0;
VehicleInfo[ i ][ vTeh ] = 1;
VehicleInfo[ i ][ vGPS ] = 0;
VehicleInfo[ i ][ vOsiguranje ] = 5;
VehicleInfo[ i ][ v_owner_id ] = -1;
if( veh_usage == PRIVATNO_VOZILO ) {
VehicleInfo[ i ][ vLock ] = 0;
VehicleInfo[ i ][ vAlarm ] = 0;
VehicleInfo[ i ][ vImobilizator ] = 0;
}
else {
VehicleInfo[ i ][ vLock ] = 5;
VehicleInfo[ i ][ vAlarm ] = 4;
VehicleInfo[ i ][ vImobilizator ] = 5;
}
VehicleInfo[ i ][ vNeon ] = 0;
VehicleInfo[ i ][ vTuned ] = 0;
VehicleInfo[ i ][ vSpoiler ] = 0;
VehicleInfo[ i ][ vHood ] = 0;
VehicleInfo[ i ][ vRoof ] = 0;
VehicleInfo[ i ][ vSkirt ] = 0;
VehicleInfo[ i ][ vLamps ] = 0;
VehicleInfo[ i ][ vNitro ] = 0;
VehicleInfo[ i ][ vExhaust ] = 0;
VehicleInfo[ i ][ vWheels ] = 0;
VehicleInfo[ i ][ vStereo ] = 0;
VehicleInfo[ i ][ vHydraulics ] = 0;
VehicleInfo[ i ][ vFrontBumper ] = 0;
VehicleInfo[ i ][ vRearBumper ] = 0;
VehicleInfo[ i ][ vVents ] = 0;
VehicleInfo[ i ][ vPaintJob ] = 255;
VehicleInfo[ i ][ vMaterijali ] = 0;
VehicleInfo[ i ][ vDrugAmmount ][ 0 ] = 0; VehicleInfo[ i ][ vDrugAmmount ][ 1 ] = 0; VehicleInfo[ i ][ vDrugAmmount ][ 2 ] = 0; VehicleInfo[ i ][ vDrugAmmount ][ 3 ] = 0; VehicleInfo[ i ][ vDrugAmmount ][ 4 ] = 0; VehicleInfo[ i ][ vDrugAmmount ][ 5 ] = 0;
VehicleInfo[ i ][ vMelee ] = 0; VehicleInfo[ i ][ vWeap1 ] = 0; VehicleInfo[ i ][ vAmmo1 ] = 0; VehicleInfo[ i ][ vWeap2 ] = 0; VehicleInfo[ i ][ vAmmo2 ] = 0;
VehicleInfo[ i ][ vGajbica ][ 0 ] = -1; VehicleInfo[ i ][ vGajbica ][ 1 ] = -1; VehicleInfo[ i ][ vGajbica ][ 2 ] = -1; VehicleInfo[ i ][ vGajbica ][ 3 ] = -1; VehicleInfo[ i ][ vGajbica ][ 4 ] = -1;
VehicleInfo[ i ][ vGajbicaAmmount ][ 0 ] = 0; VehicleInfo[ i ][ vGajbicaAmmount ][ 1 ] = 0; VehicleInfo[ i ][ vGajbicaAmmount ][ 2 ] = 0; VehicleInfo[ i ][ vGajbicaAmmount ][ 3 ] = 0; VehicleInfo[ i ][ vGajbicaAmmount ][ 4 ] = 0;
LinkVehicleToInterior( i, VehicleInfo[ i ][ vInterior ] );
SetVehicleVirtualWorld( i, VehicleInfo[ i ][ vVirtualWorld ] );
VehicleInfo[ i ][ vFuel ] = getAmountFuel( i ); vCanDrive[ i ] = 1; Fuel[ i ] = getAmountFuel( i );
UnLockCar( i ); ResetVehicleStatistics( i );
SetVehicleLabels( i );
if( veh_usage == PRIVATNO_VOZILO ) SetVehicleNumberPlate( i, "NEMA" );
else SetTablice( i );
carspawntimer = 1;
SetTimer("AntiSpawnCrash", 3000, 0);
SetVehicleParamsEx( i, 0, 0, 0, VehicleInfo[ i ][ vLocked ], 0, 0, 0 );
if( IsVehicleBajs( i ) ) {
SetVehicleParamsEx( i, 1, 0, 0, VehicleInfo[ i ][ vLocked ], 0, 0, 0 );
}
if( Diesel( i ) ) VehicleInfo[ i ][ vFuelType ] = 1;
else if( Gasoline( i ) ) VehicleInfo[ i ][ vFuelType ] = 2;
else if( GasOil( i ) ) VehicleInfo[ i ][ vFuelType ] = 3;
#if ZIMSKI_MOD == 1
if( veh_usage == POSLOVNO_VOZILO && veh_job == POSAO_KOMUNALAC && veh_model == 455 ) {
SnowObjects[ i ] = true;
SnowObject1[ i ] = CreateDynamicObject( 19601, 0, 0, 1500, 0, 0, 0 );
AttachDynamicObjectToVehicle( SnowObject1[ i ], i, 0.000000, 4.200001, -1.049999, 13.500000, 0.000000, 180.000 );
SnowObject2[ i ] = CreateDynamicObject( 18646, 0, 0, 1500, 0, 0, 0 );
AttachDynamicObjectToVehicle( SnowObject2[ i ], i, 0.749999, 1.575000, 1.725000, 0.000000, 0.000000, 0.000000 );
}
#endif
new query[ 512 ];
mysql_format( _dbConnector, query, sizeof( query ), "INSERT INTO `vehicles` (v_price, v_pos_x, v_pos_y, v_pos_z, v_pos_a, v_virtualw, v_interior, v_usage, v_organization, v_job, v_fuel_station, v_color_1, v_color_2, v_model) \
VALUES( '%d', '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d' )",
VehicleInfo[ i ][ vPrice ], VehicleInfo[ i ][ vLokacijaX ], VehicleInfo[ i ][ vLokacijaY ], VehicleInfo[ i ][ vLokacijaZ ],
VehicleInfo[ i ][ vLokacijaA ], VehicleInfo[ i ][ vVirtualWorld ], VehicleInfo[ i ][ vInterior ],
VehicleInfo[ i ][ vUsage ], VehicleInfo[ i ][ vOrganizationSQLID ], VehicleInfo[ i ][ vJob ], VehicleInfo[ i ][ vFuelStation ],
VehicleInfo[ i ][ vColor1 ], VehicleInfo[ i ][ vColor2 ], VehicleInfo[ i ][ vModel ] );
mysql_pquery( _dbConnector, query, "OnVehicleCreate", "i", i);
return i;
}
forward OnVehicleCreate( vehicleid );
public OnVehicleCreate( vehicleid ){
VehicleInfo[ vehicleid ][ vSqlID ] = cache_insert_id();
return true;
}
Re: Veh ID mysql problem -
arakuta - 19.04.2018
Make veh_id the primary key of the table.
PHP код:
ALTER TABLE table ALTER COLUMN veh_id INT NOT NULL
ALTER TABLE table ADD PRIMARY KEY (veh_id);
Re: Veh ID mysql problem -
jasperschellekens - 19.04.2018
Use auto increment
Re: Veh ID mysql problem -
expressoboy123 - 19.04.2018
Already done all of that... @Arakuta @jasperschellekens
Re: Veh ID mysql problem -
UFF - 19.04.2018
actually, you don't even use veh_id to store in db in the script. then how it will make 1, 2 ,3.
Re: Veh ID mysql problem -
jasperschellekens - 19.04.2018
Quote:
Originally Posted by expressoboy123
Already done all of that... @Arakuta @jasperschellekens
|
Impossible, If you did then your database will automatically count the number up.
Show your table structure
Re: Veh ID mysql problem -
UFF - 19.04.2018
Код:
VehicleInfo[ i ][ vSqlID ] = cache_insert_id();
new query[ 512 ];
mysql_format( _dbConnector, query, sizeof( query ), "INSERT INTO `vehicles` (v_price, v_pos_x, v_pos_y, v_pos_z, v_pos_a, v_virtualw, v_interior, v_usage, v_organization, v_job, v_fuel_station, v_color_1, v_color_2, v_model, vSqlID) \
VALUES( '%d', '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d','%d' )",
VehicleInfo[ i ][ vPrice ], VehicleInfo[ i ][ vLokacijaX ], VehicleInfo[ i ][ vLokacijaY ], VehicleInfo[ i ][ vLokacijaZ ],
VehicleInfo[ i ][ vLokacijaA ], VehicleInfo[ i ][ vVirtualWorld ], VehicleInfo[ i ][ vInterior ],
VehicleInfo[ i ][ vUsage ], VehicleInfo[ i ][ vOrganizationSQLID ], VehicleInfo[ i ][ vJob ], VehicleInfo[ i ][ vFuelStation ],
VehicleInfo[ i ][ vColor1 ], VehicleInfo[ i ][ vColor2 ], VehicleInfo[ i ][ vModel ],VehicleInfo[i][vSqlID]);
MySQL_updateQuery(query);
idk, How your defines are.. just check this...!
Re: Veh ID mysql problem -
expressoboy123 - 20.04.2018
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 );