Hey I got problem in my vehicle health code, I cant see it when i'm outside and when I'm inside....
Код:
public OnVehicleSpawn(vehicleid)
{
new newstate;
new playerid;
new oldstate;
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_ONFOOT)
{
new vehicle = GetPlayerVehicleID(playerid);
new model = GetVehicleModel(vehicle);
switch(model)
{
case 541: SetVehicleHealth(vehicle, 1500);
case 596: SetVehicleHealth(vehicle, 2000);
case 560: SetVehicleHealth(vehicle, 1500);
case 402: SetVehicleHealth(vehicle, 1500);
case 427: SetVehicleHealth(vehicle, 10000);
case 428: SetVehicleHealth(vehicle, 5000);
case 528: SetVehicleHealth(vehicle, 5000);
case 599: SetVehicleHealth(vehicle, 2000);
case 601: SetVehicleHealth(vehicle, 4000);
case 490: SetVehicleHealth(vehicle, 2500);
case 433: SetVehicleHealth(vehicle, 4000);
case 470: SetVehicleHealth(vehicle, 2500);
case 432: SetVehicleHealth(vehicle, 20000);
case 497: SetVehicleHealth(vehicle, 2500);
case 487: SetVehicleHealth(vehicle, 1500);
case 592: SetVehicleHealth(vehicle, 2000);
}
}
VehicleStatus{vehicleid} = 0;
new Float:X, Float:Y, Float:Z;
GetObjectPos(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);
new v;
stationidv[vehicleid] = 0;
//VehicleFuel[vehicleid] = 100.0;
foreach(Player, i)
{
v = GetPlayerVehicle(i, vehicleid);
if (v != -1)
{
if(PlayerVehicleInfo[i][v][pvId] == vehicleid && GetVehicleModel(vehicleid) != PlayerVehicleInfo[i][v][pvModelId])
{
DestroyVehicle(vehicleid);
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]);
}
new string[128];
format(string,sizeof(string),"Your %s has been sent to the location at which you last parked it.",GetVehicleName(vehicleid));
SendClientMessageEx(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][pMember] == 8 || PlayerInfo[i][pLeader] == 8)
{
if(PlacedVehicleBomb[i] == vehicleid)
{
VehicleBomb[vehicleid] = 0;
PlacedVehicleBomb[i] = INVALID_VEHICLE_ID;
PickUpC4(i);
PlayerInfo[i][pC4Used] = 0;
PlayerInfo[i][pC4Get] = 1;
}
}
}
}
if(VehicleBomb[vehicleid] == 1)
{
foreach(Player, i)
{
if(VehicleBomb[vehicleid] != PlacedVehicleBomb[i])
{
VehicleBomb[vehicleid] = 0;
}
}
}
arr_Engine{vehicleid} = 0;
TruckContents[vehicleid] = 0;
/*new v;
foreach(Player, i)
{
v = GetPlayerVehicle(i, vehicleid);
if(v != -1)
{
SendClientMessageEx(i, COLOR_GRAD1, " Your vehicle has been spawned.");
new paintjob = PlayerVehicleInfo[i][v][pvPaintJob];
new color1 = PlayerVehicleInfo[i][v][pvColor1];
new color2 = PlayerVehicleInfo[i][v][pvColor2];
ChangeVehiclePaintjob(vehicleid, paintjob);
ChangeVehicleColor(vehicleid, color1, color2);
for(new m = 0; m < MAX_MODS; m++)
{
if (PlayerVehicleInfo[i][v][pvMods][m] >= 1000)
{
AddVehicleComponent(vehicleid, PlayerVehicleInfo[i][v][pvMods][m]);
}
}
}
}*/
// To be fixed
/*if(GetVehicleModel(vehicleid) == 596 || GetVehicleModel(vehicleid) == 597 || GetVehicleModel(vehicleid) == 598) SetVehicleHealth(vehicleid,1500.0);
if(GetVehicleModel(vehicleid) == 407 || GetVehicleModel(vehicleid) == 470) SetVehicleHealth(vehicleid,2000.0);
if(GetVehicleModel(vehicleid) == 428 || GetVehicleModel(vehicleid) == 433 || (vehicleid) == 482) SetVehicleHealth(vehicleid,3000.0);
if(GetVehicleModel(vehicleid) == 601 || GetVehicleModel(vehicleid) == 528) SetVehicleHealth(vehicleid,4000.0);
if(GetVehicleModel(vehicleid) == 432) SetVehicleHealth(vehicleid,5000.0);*/
}
This function check when the player enter the vehicle so i think it will set the vehicle health according to car model , and also it will check if the player passenger !
But this is only when player inside the vehicle, I need him when inside/outside he can see in /dl the health is which defined.
You can see the vehicle's health if /dl is enabled (client command) in every state.