- Регистрация
- 13 Июл 2014
- Сообщения
- 74
- Лучшие ответы
- 0
- Репутация
- 3
Не могу понять, почему расход. бензина идет когда двигатель включен, как сделать что бы тратился только при езде?
C++:
stock SpeedVehicle(playerid)
{
new Float:ST[4];
if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 160.3;
return floatround(ST[3]);
}
stock GetPlayerSpeed(playerid)
{
new Float:Coord[4];
GetPlayerVelocity(playerid, Coord[0], Coord[1], Coord[2]);
Coord[3] = floatsqroot(floatpower(floatabs(Coord[0]), 2.0) + floatpower(floatabs(Coord[1]), 2.0) + floatpower(floatabs(Coord[2]), 2.0)) * 213.3;
return floatround(Coord[3]);
}
forward UpdateSpeedometr(playerid);
public UpdateSpeedometr(playerid)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
new Float:X2, Float:Y2, Float:Z2, Float:X, Float:Y, Float:Z;
if(VehicleInfo[vehicleid-1][vDrived] < 1000000)
{
X2 = VehicleInfo[vehicleid-1][vX];
Y2 = VehicleInfo[vehicleid-1][vY];
Z2 = VehicleInfo[vehicleid-1][vZ];
GetVehiclePos(vehicleid, X, Y, Z);
new Float:veloc;
veloc = PointToPoint3D(X2,Y2,Z2,X,Y,Z)/1000;
VehicleInfo[vehicleid-1][vDrived] += veloc;
VehicleInfo[vehicleid-1][vX] = X;
VehicleInfo[vehicleid-1][vY] = Y;
VehicleInfo[vehicleid-1][vZ] = Z;
}
GetVehicleVelocity(vehicleid,X,Y,Z);
new Float:speed = floatsqroot(floatadd(floatadd(floatpower(X, 2), floatpower(Y, 2)), floatpower(Z, 2))) * 160.3;
if(pTemp[playerid][pSLimit])
{
if(speed > pTemp[playerid][pSLimit])
{
new Float:dif = pTemp[playerid][pSLimit] / speed;
SetVehicleVelocity(GetPlayerVehicleID(playerid),X*dif,Y*dif,Z);
speed = pTemp[playerid][pSLimit];
}
}
new str1[12],str6[12],str9[12];
format(str1, sizeof(str1),"~g~~h~~h~%.0f",speed);
if(speed >= 60) format(str1, sizeof(str1),"~y~~h~%.0f",speed);
if(speed >= 110) format(str1, sizeof(str1),"~r~~h~%.0f",speed);
PlayerTextDrawSetString(playerid,SpeedShow[playerid],str1);
format(str6, sizeof(str6),"%.1f",Fuell[vehicleid]);
PlayerTextDrawSetString(playerid,FillShow[playerid],str6);
PlayerTextDrawSetString(playerid,StatusShow[playerid],(IsLocked[vehicleid] == 1) ? ("Lock") : (""));
PlayerTextDrawSetString(playerid,EngineShow[playerid],(zavodis[vehicleid] == 1) ? ("Engine") : (""));
PlayerTextDrawSetString(playerid,LightShow[playerid],(VehicleLight[vehicleid] == 1) ? ("Lights") : (""));
format(str9, sizeof(str9), "%.1f",VehicleInfo[vehicleid-1][vDrived]);
if(VehicleInfo[vehicleid-1][vDrived] > 999999) format(str9, sizeof(str9), "NAN");
PlayerTextDrawSetString(playerid,MileageCount[playerid],str9);
if(zavodis[vehicleid] != 0)
{
if(Fuell[vehicleid] > 0) Fuell[vehicleid] -= SuperGt(vehicleid) ? 0.01 : 0.007;
else
{
Fuell[vehicleid] = 0;
SendClientMessage(playerid, COLOR_REDD, "В автомобиле нет бензина");
SendClientMessage(playerid, 0x62AD50FF, "Используйте телефон {FFFFFF}(( /call )) {62AD50}вызвать механика / таксиста");
SendClientMessage(playerid, 0x62AD50FF, "Вы можете использовать канистру {FFFFFF}(( /fillcar )) {62AD50}если Вы её приобрели ранее");
zavodis[vehicleid] = 0;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,false,lights,alarm,doors,bonnet,boot,objective);
}
}
}
return 1;
}