20.01.2015, 18:12
Hello !
I tried your code, I modified it a bit to suit my gamemode.
However, it does not work.
I'm doing everything Los Santos, none liter has withdrawn.
= 1 for Landstalker. (Exemple)
I tried your code, I modified it a bit to suit my gamemode.
However, it does not work.
I'm doing everything Los Santos, none liter has withdrawn.
pawn Код:
VehicleParams[VehInfo[vid][ModelID]-400][CONSO]
pawn Код:
PlayerTimer1000(playerid)
{
CheckSpeed(playerid);
// Setup local variables
new Query[128];
new engine, lights, alarm, doors, bonnet, boot, objective;
new FuelStatus[30], Float:VehicleHealth, TextDrawMsg[50];
new Msg[128];
// Obtenir le model + l'id du veh
new vid = GetPlayerVehicleID(playerid);
if(vid != 0)
{
new vModel = GetVehicleModel(vid);
}
// Joueur а l'intйrieur d'un veh
if(vid != 0)
{
// Si le joueur est conducteur
if(GetPlayerVehicleSeat(playerid) == 0)
{
// Si le veh n'est pas un vйlo
if(!IsABike(vid))
{
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
// Moteur = 1
if (engine == 1)
{
// Check if the speed is above 10 kph and if the vehicle didn't run out of fuel
if((VitessePl[playerid] > 10) && (VehInfo[vid][Essence] > 0))
{
new Float:Conso = VehicleParams[VehInfo[vid][ModelID]-400][CONSO] * (VitessePl[playerid]/100.0) * 1.0;
}
else
{ // En dessous de 10 KM/H
new Float:Conso = VehicleParams[VehInfo[vid][ModelID]-400][CONSO] * 0.05 * 1.0;
// Consume fuel
VehInfo[vid][Essence] = VehInfo[vid][Essence] - Conso;
}
// Panne d'essence
if(VehInfo[vid][Essence] <= 0.0)
{
VehInfo[vid][Essence] = 0.0;
SetVehicleParamsEx(vid, 0, 0, alarm, doors, bonnet, boot, objective);
}
}
}
if(VehicleParams[VehInfo[vid][ModelID]-400][CONSO] != 0)
{
format(string, sizeof(string), "%d", VehInfo[vid][Essence]);
PlayerTextDrawSetString(playerid, Textdraw5[playerid], string);
}
}
}
stock CheckSpeed(playerid)
{
new vid = GetPlayerVehicleID(playerid),
Float:Vitesse[3];
if (vid != 0)
{
GetVehicleVelocity(vid, Vitesse[0], Vitesse[1], Vitesse[2]);
}
else
{
GetPlayerVelocity(playerid, Vitesse[0], Vitesse[1], Vitesse[2]);
}
// Calculate speed of the player in kph
SpeedFloat = floatsqroot(((Vitesse[0] * Vitesse[0]) + (Vitesse[1] * Vitesse[1])) + (Vitesse[2] * Vitesse[2])) * 179.0; // kph
// Convert the float value to an int value, also calculate the speed in mph
SpeedKph = floatround(SpeedFloat, floatround_round);
// Also save the speed for the player
VitessePl[playerid] = SpeedKph;
}