05.06.2015, 09:24
This is my OnVehicleSpawn code
Code:
public OnVehicleSpawn(vehicleid) { VehicleStatus{vehicleid} = 0; TruckContents[vehicleid] = 0; VehicleRadioStation[vehicleid] = 0; new Float:X, Float:Y, Float:Z; GetDynamicObjectPos(Carrier[0], X, Y, Z); if(vehicleid == NGVehicles[0]) SetVehiclePos(vehicleid, (X-40.586371), (Y-5.692918), 11.5239); else if(vehicleid == NGVehicles[1]) SetVehiclePos(vehicleid, (X-50.758971), (Y-5.817918), 11.5200); else if(vehicleid == NGVehicles[2]) SetVehiclePos(vehicleid, (X-60.754871), (Y-5.590818), 11.5239); else if(vehicleid == NGVehicles[3]) SetVehiclePos(vehicleid, (X-89.337771), (Y-8.558118) ,-0.6940); else if(vehicleid == NGVehicles[4]) SetVehiclePos(vehicleid, (X-88.546371), (Y-3.55761), -0.7851); else if(vehicleid == NGVehicles[5]) SetVehiclePos(vehicleid, (X-83.861371), (Y+9.010282),0.2197); else if(vehicleid == NGVehicles[6]) SetVehiclePos(vehicleid, (X-83.788371), (Y+3.149882), -0.2992); else if(vehicleid == NGVehicles[7]) SetVehiclePos(vehicleid, (X-66.975571), (Y+2.436018), 2.8996); else if(vehicleid == NGVehicles[8]) SetVehiclePos(vehicleid, (X-66.928571), (Y+8.720218), 2.9000); else if(vehicleid == NGVehicles[9]) SetVehiclePos(vehicleid, (X-37.527971), (Y-5.000518), 19.5374); else if(vehicleid == NGVehicles[10]) SetVehiclePos(vehicleid, (X-49.288871), (Y-4.466818), 19.5374); else if(vehicleid == NGVehicles[11]) SetVehiclePos(vehicleid, (X-61.408771), (Y-4.106418), 19.5374); else if(vehicleid == NGVehicles[12]) SetVehiclePos(vehicleid, (X+50.462929), (Y-7.469218), 19.5374); else if(vehicleid == NGVehicles[13]) SetVehiclePos(vehicleid, (X+62.036429), (Y-7.419918), 19.5374); else if(vehicleid == NGVehicles[14]) SetVehiclePos(vehicleid, (X+73.444929), (Y-7.391618), 19.5374); else if(vehicleid == NGVehicles[15]) SetVehiclePos(vehicleid, (X+84.864529), (Y-7.157718), 19.5374); else if(vehicleid == NGVehicles[16]) SetVehiclePos(vehicleid, (X-75.592971), (Y-7.861318), 20.4642); else if(vehicleid == NGVehicles[17]) SetVehiclePos(vehicleid, (X+95.951729), (Y-7.315918), 19.3947); else if(vehicleid == NGVehicles[18]) SetVehiclePos(vehicleid, (X+62.937929), (Y+7.680682), 12.5242); else if(vehicleid == NGVehicles[19]) SetVehiclePos(vehicleid, (X+62.937929), (Y-2.632818), 12.5242); else if(vehicleid == NGVehicles[20]) SetVehiclePos(vehicleid, (X+18.567629), (Y-6.059118), 11.3398); else if(vehicleid == NGVehicles[21]) SetVehiclePos(vehicleid, (X+18.567629), (Y-8.597918), 11.3398); else if(vehicleid == NGVehicles[22]) SetVehiclePos(vehicleid, (X+18.567629), (Y-11.244118), 11.3398); for(new i = 0; i < sizeof(FamilyInfo); i++) { for(new d = 0 ; d < MAX_GANG_VEHICLES; d++) { if(FamilyVehicleInfo[i][d][fvLocked] != 0 && FamilyVehicleInfo[i][d][fvLock] > 0) { LockGangVehicle(i, FamilyVehicleInfo[i][d][fvId], FamilyVehicleInfo[i][d][fvLock]); } } } switch(GetVehicleModel(vehicleid)) { case 427, 428, 432, 601, 528: SetTimerEx("DelayedVehHealth", 1000, false, "d", vehicleid); } new v; foreach(Player, i) { v = GetPlayerVehicle(i, vehicleid); if(v != -1) { if(PlayerVehicleInfo[i][v][pvId] == vehicleid && GetVehicleModel(vehicleid) != PlayerVehicleInfo[i][v][pvModelId]) { DestroyVehicle(vehicleid); VehicleRadioStation[vehicleid] = 0; PlayerVehicleInfo[i][v][pvId] = CreateVehicle(PlayerVehicleInfo[i][v][pvModelId], PlayerVehicleInfo[i][v][pvPosX], PlayerVehicleInfo[i][v][pvPosY], PlayerVehicleInfo[i][v][pvPosZ], PlayerVehicleInfo[i][v][pvPosAngle],PlayerVehicleInfo[i][v][pvColor1], PlayerVehicleInfo[i][v][pvColor2], -1); if(PlayerVehicleInfo[i][v][pvLocked] == 1) LockPlayerVehicle(i, PlayerVehicleInfo[i][v][pvId], PlayerVehicleInfo[i][v][pvLock]); ChangeVehiclePaintjob(PlayerVehicleInfo[i][v][pvId], PlayerVehicleInfo[i][v][pvPaintJob]); ChangeVehicleColor(PlayerVehicleInfo[i][v][pvId], PlayerVehicleInfo[i][v][pvColor1], PlayerVehicleInfo[i][v][pvColor2]); for(new m = 0; m < MAX_MODS; m++) { if(PlayerVehicleInfo[i][v][pvMods][m] >= 1000 && PlayerVehicleInfo[i][v][pvMods][m] <= 1193) { if(InvalidModCheck(GetVehicleModel(vehicleid), PlayerVehicleInfo[i][v][pvMods][m])) { AddVehicleComponent(PlayerVehicleInfo[i][v][pvId], PlayerVehicleInfo[i][v][pvMods][m]); } else { //printf("Removing invalid mod %d from %d of %s", PlayerVehicleInfo[i][v][pvMods][m], GetVehicleModel(vehicleid), GetPlayerNameEx(i)); PlayerVehicleInfo[i][v][pvMods][m] = 0; } } } } else { ChangeVehiclePaintjob(vehicleid, PlayerVehicleInfo[i][v][pvPaintJob]); ChangeVehicleColor(vehicleid, PlayerVehicleInfo[i][v][pvColor1], PlayerVehicleInfo[i][v][pvColor2]); for(new m = 0; m < MAX_MODS; m++) { if(PlayerVehicleInfo[i][v][pvMods][m] >= 1000 && PlayerVehicleInfo[i][v][pvMods][m] <= 1193) { if(InvalidModCheck(GetVehicleModel(vehicleid), PlayerVehicleInfo[i][v][pvMods][m])) { AddVehicleComponent(PlayerVehicleInfo[i][v][pvId], PlayerVehicleInfo[i][v][pvMods][m]); } else { //printf("Removing invalid mod %d from %d of %s", PlayerVehicleInfo[i][v][pvMods][m], GetVehicleModel(vehicleid), GetPlayerNameEx(i)); PlayerVehicleInfo[i][v][pvMods][m] = 0; } } } if(PlayerVehicleInfo[i][v][pvLocked] == 1) LockPlayerVehicle(i, PlayerVehicleInfo[i][v][pvId], PlayerVehicleInfo[i][v][pvLock]); } if(IsATruckerCar(vehicleid)) { TruckPackages[vehicleid] = -1; } new string[128]; format(string,sizeof(string),"Your %s has been sent to the location at which you last parked it.",GetVehicleName(vehicleid)); SCM(i, COLOR_GRAD1, string); } } if(LockStatus[vehicleid]) { foreach(Player, i) { if(PlayerInfo[i][pLockCar] == vehicleid) { PlayerInfo[i][pLockCar] = INVALID_VEHICLE_ID; } } } if(VehicleBomb{vehicleid} == 1) { foreach(Player, i) { if(PlayerInfo[i][pFaction] == 4 || PlayerInfo[i][pLeader] == 4) { if(PlacedVehicleBomb[i] == vehicleid) { VehicleBomb{vehicleid} = 0; PlacedVehicleBomb[i] = INVALID_VEHICLE_ID; PickUpC4(i); PlayerInfo[i][pC4Used] = 0; PlayerInfo[i][pC4Get] = 1; } } } } return 1; }