[POMOC] iskakanje iz vozila

Započeo Fico_Mitnica, Jul 11, 2011, 16:05:27 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

Skripta koju koristim:Edit GF (mislim novi sam a frend mi ovo dao)
Detaljan opis problema: kad se vozi auto i nestane goriva on mi iskoci..kako da napravim da neiskoci nego da samo auto nemoze dalje voziti..tj vozilo
Dio skripte:
#include "a_samp.inc"

#define FUEL_UPDATE_TIME (60)

forward PlayerVehicleFuelUpdate(playerid);

enum E_VEHICLE_INFO { bool:vehicle_processed, Float:vehicle_fuel, FuelUpdateTimer }
new VehicleInfo[MAX_VEHICLES][E_VEHICLE_INFO];

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(VehicleInfo[vehicleid][vehicle_processed] == false)
{
   VehicleInfo[vehicleid][vehicle_processed] = true;
   VehicleInfo[vehicleid][vehicle_fuel] = 100.00;
}
else
{
   if(VehicleInfo[vehicleid][vehicle_fuel] == 0.00)
{
       TogglePlayerControllable(playerid, true);
RemovePlayerFromVehicle(playerid);

GameTextForPlayer(playerid, "~r~Out of fuel!", 100, 4);
}
}

VehicleInfo[vehicleid][FuelUpdateTimer] = SetTimerEx("PlayerVehicleFuelUpdate", FUEL_UPDATE_TIME, 1, "i", playerid);
return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
   if(VehicleInfo[vehicleid][vehicle_fuel] == 0.00)
   {
       TogglePlayerControllable(playerid, true);
RemovePlayerFromVehicle(playerid);
   }

return KillTimer(VehicleInfo[vehicleid][FuelUpdateTimer]);
}

public PlayerVehicleFuelUpdate(playerid)
{
new const vehicleid = GetPlayerVehicleID(playerid);

new Float:memory[3]={0.00,0.00,0.00 }, result_speed=1;
GetVehicleVelocity(vehicleid,memory[0],memory[1],memory[2]);

result_speed = floatround(floatround(floatsqroot(((memory[0]*memory[0])+(memory[1]*memory[1]))+(memory[2]*memory[2]))*(136.666667),floatround_round)*(1.609344));

if(result_speed)
{
   new _random = random(100); while(_random < 50) _random = random(100); new val[4]; format(val, sizeof(val), "0.%i", _random);

if(floatsub(VehicleInfo[vehicleid][vehicle_fuel], floatstr(val)) > 0.00)
{
    VehicleInfo[vehicleid][vehicle_fuel] = floatsub(VehicleInfo[vehicleid][vehicle_fuel], floatstr(val));
}
else
{
   VehicleInfo[vehicleid][vehicle_fuel] = 0.00;

TogglePlayerControllable(playerid, true);
      RemovePlayerFromVehicle(playerid);
   TogglePlayerControllable(playerid, true);

   GameTextForPlayer(playerid, "~r~Out of fuel!", 100, 4);
}
}
return 1;
}

forward Float:GetVehicleFuelData(vehicleid);
public Float:GetVehicleFuelData(vehicleid)
{
return Float:VehicleInfo[vehicleid][vehicle_fuel];
}

Neke slike/video za lakse dobivanje pomoci(neobavezno)://


Moderator:
Koristi
[code ] [ /code]
Poslednja Izmena: Jul 11, 2011, 16:52:18 POSLE PODNE od |β3tα|_eXtreme_

Probaj ovako:

#include "a_samp.inc" 
 
#define FUEL_UPDATE_TIME (60) 
 
forward PlayerVehicleFuelUpdate(playerid); 
 
enum E_VEHICLE_INFO { bool:vehicle_processed, Float:vehicle_fuel, FuelUpdateTimer } 
new VehicleInfo[MAX_VEHICLES][E_VEHICLE_INFO]; 
 
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) 

   if(VehicleInfo[vehicleid][vehicle_processed] == false) 
   { 
       VehicleInfo[vehicleid][vehicle_processed] = true; 
       VehicleInfo[vehicleid][vehicle_fuel] = 100.00; 
   } 
   else 
   { 
       if(VehicleInfo[vehicleid][vehicle_fuel] == 0.00) 
      { 
           TogglePlayerControllable(playerid, 1); 
          GameTextForPlayer(playerid, "~r~Out of fuel!", 100, 4); 
      } 
   } 
 
   VehicleInfo[vehicleid][FuelUpdateTimer] = SetTimerEx("PlayerVehicleFuelUpdate", FUEL_UPDATE_TIME, 1, "i", playerid); 
   return 1; 

 
public OnPlayerExitVehicle(playerid, vehicleid) 

    if(VehicleInfo[vehicleid][vehicle_fuel] == 0.00) 
    { 
        TogglePlayerControllable(playerid, 1); 
    } 
 
   return KillTimer(VehicleInfo[vehicleid][FuelUpdateTimer]); 

 
public PlayerVehicleFuelUpdate(playerid) 

   new const vehicleid = GetPlayerVehicleID(playerid); 
 
   new Float:memory[3]={0.00,0.00,0.00 }, result_speed=1; 
   GetVehicleVelocity(vehicleid,memory[0],memory[1],memory[2]); 
 
   result_speed = floatround(floatround(floatsqroot(((memory[0]*memory[0])+(memory[1]*memory[1]))+(memory[2]*memory[2]))*(136.666667),floatround_round)*(1.609344)); 
 
   if(result_speed) 
   { 
       new _random = random(100); while(_random < 50) _random = random(100); new val[4]; format(val, sizeof(val), "0.%i", _random); 
 
      if(floatsub(VehicleInfo[vehicleid][vehicle_fuel], floatstr(val)) > 0.00) 
      { 
          VehicleInfo[vehicleid][vehicle_fuel] = floatsub(VehicleInfo[vehicleid][vehicle_fuel], floatstr(val)); 
      } 
      else 
      { 
          VehicleInfo[vehicleid][vehicle_fuel] = 0.00; 
          GameTextForPlayer(playerid, "~r~Out of fuel!", 100, 4); 
      } 
   } 
   return 1; 

 
forward Float:GetVehicleFuelData(vehicleid); 
public Float:GetVehicleFuelData(vehicleid) 

   return Float:VehicleInfo[vehicleid][vehicle_fuel];