fuel crashing me..
#7

ah ha i found the problem! its diff now if i go to fast i crash

could it be that it cannot decrease fuel by points? as in 1.3 maybe that part is crashing it i dont want to use a float in the fuel i dont want it to show point decimals(40.3) e.g

pawn Код:
#include <a_samp>
#include <zcmd>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define RED 0xFF0000FF
#define     LIME 0x00FF00FF
forward CheckStatus();
forward Fueldecrease();
forward IsAtFuelStation(playerid);
forward ReFill(playerid);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Booleans
new bool:TextDrawsShown[MAX_PLAYERS];
new bool:VHSCreated[MAX_PLAYERS];
new CarFuel[MAX_VEHICLES] = 0;
//Timer
new CheckStatusTimer;
new FuelDecrease;
new ReFuelTimer;

//4all
new Text:Black0;
new Text:Black1;
new Text:Black2;
new Text:Black3;
new Text:LightBlack;
//4player
new Text:VHS[MAX_PLAYERS];
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public OnFilterScriptInit()
{
    CheckStatusTimer = SetTimer("CheckStatus", 900, 1);
    FuelDecrease = SetTimer("Fueldecrease", 5000, 1);
    for(new v = 0; v < MAX_VEHICLES; v++)
    {
            new randfuel = minrand(25,100);
            CarFuel[v] = randfuel; // This sets the fuel
    }
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public OnFilterScriptExit()
{
    KillTimer(CheckStatusTimer);
    KillTimer(FuelDecrease);
    TextDrawDestroy(Text:Black0);
    TextDrawDestroy(Text:Black1);
    TextDrawDestroy(Text:Black2);
    TextDrawDestroy(Text:Black3);
    TextDrawDestroy(Text:LightBlack);
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        TextDrawDestroy(Text:VHS[i]);
    }
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public OnVehicleSpawn(vehicleid)
{
        CarFuel[vehicleid] = minrand(25,100);
        return 1;
}

public OnPlayerConnect(playerid)
{
    TextDrawsShown[playerid] = false;
    VHSCreated[playerid] = false;
}
stock minrand(min, max) //By Alex "******" Cole
{
    return random(max-min)+min;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CMD:refuel(playerid,params[])
{
    if(IsPlayerConnected(playerid) && IsPlayerInAnyVehicle(playerid))
    {
        if(IsAtFuelStation(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new vehicle = GetPlayerVehicleID(playerid);
            if(CarFuel[vehicle] >= 100)
            {
                SendClientMessage(playerid,RED,".::Error:Your Gas Tank Is Already Full");
            }
            else
            {
                SendClientMessage(playerid,LIME,"Your Gas Is Being ReFueled Right Now! Please Wait");
                ReFuelTimer = SetTimerEx("ReFill", 800, true, "i", playerid);
            }
        }
        else
        {
        SendClientMessage(playerid,RED,".::Error: You Must Be At A Gas Station To Refuel Your Vehicle");
        }
    }
    else
    {
        SendClientMessage(playerid,RED,".::Error: You must Be In A Vehicle To Refuel It Idiot");
    }
    return true;
}

public ReFill(playerid)
{
    new Float:x, Float:y, Float:z;
    new vehicle = GetPlayerVehicleID(playerid);
    if(GetPlayerPos(playerid, x, y, z) != IsAtFuelStation(playerid) || CarFuel[vehicle] >= 100)
    {
        StopRefueling(playerid);
    }
    else
    {
        CarFuel[vehicle] ++;
    }
    return true;
}

stock StopRefueling(playerid)
{
    GivePlayerMoney(playerid, -300);
    SendClientMessage(playerid, LIME,".::FUEL:Your Gas Tank Has Been Filled Up For $300");
    KillTimer(ReFuelTimer);
    return true;
}

public Fueldecrease()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInAnyVehicle(i))
            {
                new vehicle = GetPlayerVehicleID(i);
                new Float:speed;
                speed = GetPlayerSpeed(i, false);
                if(CarFuel[vehicle] >= 1 && CarFuel[vehicle] <= 100)
                {
                    if(speed >= 1 && speed <= 70)
                    {
                        CarFuel[vehicle] -= 1;
                    }
                    if(speed >= 71 && speed <= 130)
                    {
                        CarFuel[vehicle] -= 1.5;
                    }
                    if(speed >= 131 && speed <= 170)
                    {
                        CarFuel[vehicle] -= 1.8;
                    }
                    if(speed >= 171)
                    {
                        CarFuel[vehicle] -= 2.0;
                    }
                }
            }
        }
    }
    return 1;
}


public CheckStatus()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInAnyVehicle(i))
            {

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if(TextDrawsShown[i] == false)
                {
                    TextDrawsShown[i] = true;
                }

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                new vehicle = GetPlayerVehicleID(i);
                new String[128];
                new Float:X, Float:Y, Float:Z, Float:Speed;
                GetVehicleVelocity(GetPlayerVehicleID(i), X, Y, Z);
                Speed = floatmul(floatsqroot(floatadd(floatadd(floatpower(X, 2), floatpower(Y, 2)),  floatpower(Z, 2))), 200.0); //100.0
                if(CarFuel[vehicle] >= 1 && CarFuel[vehicle] <= 100)
                {
                    format(String,sizeof(String),"~r~Fuel~g~:~p~%d ~r~MPH~g~:~p~%i ~r~KMH~g~:~p~%i",CarFuel[vehicle], floatround(floatdiv(Speed, 1.609344), floatround_floor), floatround(Speed, floatround_floor));
                }
                if(CarFuel[vehicle] == 0)
                {
                    CarFuel[vehicle] = 0;
                    CarFuel[vehicle] --;
                    RemovePlayerFromVehicle(i);
                    GameTextForPlayer(i,"~r~No Fuel In Vehicle",4000,3);
                }
                if(CarFuel[vehicle] == 25)
                {
                    GameTextForPlayer(i,"~r~Warning Low Fuel",4000,3);
                }
                if(CarFuel[vehicle] == 20)
                {
                    GameTextForPlayer(i,"~r~Warning Low Fuel",4000,3);
                }
                if(CarFuel[vehicle] == 15)
                {
                    GameTextForPlayer(i,"~r~Warning Low Fuel",4000,3);
                }
                if(CarFuel[vehicle] == 10)
                {
                    GameTextForPlayer(i,"~r~Warning Low Fuel",4000,3);
                }
                if(CarFuel[vehicle] == 5)
                {
                    GameTextForPlayer(i,"~r~Warning Low Fuel",4000,3);
                }
                if(VHSCreated[i] == true)
                {
                    TextDrawDestroy(VHS[i]);
                }
               
                VHS[i] = TextDrawCreate(285.000000, 431.000000, String);
                TextDrawAlignment(VHS[i], 2);
                TextDrawBackgroundColor(VHS[i], 255);
                TextDrawFont(VHS[i], 2);
                TextDrawLetterSize(VHS[i], 0.360000, 1.000000);
                TextDrawColor(VHS[i], -1);
                TextDrawSetOutline(VHS[i], 1);
                TextDrawSetProportional(VHS[i], 1);
                TextDrawShowForPlayer(i, VHS[i]);
               
                VHSCreated[i] = true;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            }
            else
            {
                if(TextDrawsShown[i] == true)
                {
                    TextDrawHideForPlayer(i, Text:Black0);
                    TextDrawHideForPlayer(i, Text:Black1);
                    TextDrawHideForPlayer(i, Text:Black2);
                    TextDrawHideForPlayer(i, Text:Black3);
                    TextDrawHideForPlayer(i, Text:LightBlack);
                    TextDrawsShown[i] = false;
                }
                TextDrawHideForPlayer(i, Text:VHS[i]);
            }
        }
    }
}

stock GetPlayerSpeed(playerid,bool:kmh)
{
  new Float:Vx,Float:Vy,Float:Vz,Float:rtn;
  if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),Vx,Vy,Vz); else GetPlayerVelocity(playerid,Vx,Vy,Vz);
  rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz,2)));
  return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
}

public IsAtFuelStation(playerid)
{
    if(PlayerToPoint(10,playerid,1595.5406, 2198.0520, 10.3863) || PlayerToPoint(10,playerid,2202.0649, 2472.6697, 10.5677) ||
    PlayerToPoint(10,playerid,2115.1929, 919.9908, 10.5266) || PlayerToPoint(10,playerid,2640.7209, 1105.9565, 10.5274) ||
    PlayerToPoint(10,playerid,608.5971, 1699.6238, 6.9922) || PlayerToPoint(10,playerid,618.4878, 1684.5792, 6.9922) ||
    PlayerToPoint(10,playerid,2146.3467, 2748.2893, 10.5245) || PlayerToPoint(10,playerid,-1679.4595, 412.5129, 6.9973) ||
    PlayerToPoint(10,playerid,-1327.5607, 2677.4316, 49.8093) || PlayerToPoint(10,playerid,-1470.0050, 1863.2375, 32.3521) ||
    PlayerToPoint(10,playerid,-2409.2200, 976.2798, 45.2969) || PlayerToPoint(10,playerid,-2244.1396, -2560.5833, 31.9219) ||
    PlayerToPoint(10,playerid,-1606.0544, -2714.3083, 48.5335) || PlayerToPoint(10,playerid,1937.4293, -1773.1865, 13.3828) ||
    PlayerToPoint(10,playerid,-91.3854, -1169.9175, 2.4213) || PlayerToPoint(10,playerid,1383.4221, 462.5385, 20.1506) ||
    PlayerToPoint(10,playerid,660.4590, -565.0394, 16.3359) || PlayerToPoint(10,playerid,1381.7206, 459.1907, 20.3452) ||
    PlayerToPoint(10,playerid,-1605.7156, -2714.4573, 48.5335))
    { return true; }
    return false;
}

stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    new Float:oldposx, Float:oldposy, Float:oldposz;
    new Float:tempposx, Float:tempposy, Float:tempposz;
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
    tempposx = (oldposx -x);
    tempposy = (oldposy -y);
    tempposz = (oldposz -z);
    if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
    {
        return 1;
    }
    return 0;
}

//EOF/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Reply


Messages In This Thread
fuel crashing me.. - by Kar - 28.07.2010, 14:11
Re: fuel crashing me.. - by Mauzen - 28.07.2010, 15:25
Re: fuel crashing me.. - by Kar - 28.07.2010, 15:42
Re: fuel crashing me.. - by Mauzen - 28.07.2010, 15:47
Re: fuel crashing me.. - by Kar - 28.07.2010, 15:56
Re: fuel crashing me.. - by Mauzen - 28.07.2010, 16:31
Re: fuel crashing me.. - by Kar - 28.07.2010, 16:32
Re: fuel crashing me.. - by selten98 - 28.07.2010, 17:23
Re: fuel crashing me.. - by Kar - 28.07.2010, 17:24
Re: fuel crashing me.. - by DJDhan - 28.07.2010, 17:33

Forum Jump:


Users browsing this thread: 3 Guest(s)