best way?
#1

I know 1 way for this, but its long script , I think it can be made in a better way?

The thing is:

If vehicle health is > 900 then there will be 100% for turning vehicle on (totally success)
If < 900 && > 600 then there will be 70%
If < 600 then there will be 40%

Thanks!
Reply
#2

pawn Код:
Define this on top: new percent[MAX_PLAYERS];

dcmd_tune(playerid,params[])
{
    new Float:health;
    new veh;
        veh = GetPlayerVehicleID(playerid);
        GetVehicleHealth(veh, health);

    if (veh >= 900)
    {
        percent[playerid] = 1;
    }

    if (veh < 900 && > 600)
    {
        percent[playerid] = 2;
    }

    if (veh <= 600)
    {  
        percent[playerid] = 3;
    }
}
Note: it's just an example now edit your tune menu and make it so if percent is 3 then he will have that etc..

Hope I helped PM me for more information.
Reply
#3

I cant understand o_O
Reply
#4

pawn Код:
new asd = GetVehicleHealth(vehicleid, &Float:health);
if(asd == 100)
{
    //turned on
}
if(600 < asd < 900)
{
    new qwe = random(3);
    if(qwe == 0 || qwe == 1)// 2/3 chance
    {
        //turned on
    }
}
if(asd < 600)
{
    new qwe = random(3);
    if(qwe == 0)// 1/3 chance
    {
        //turned on
    }
}
Reply
#5

This should work?

pawn Код:
forward VehicleEngine(playerid, vehicleid);
public VehicleEngine(playerid, vehicleid)
{
    new bool:Success;
    if(vData[vehicleid][vFuel] == 0) Success = false;
    new Float:Health, Random;
   
    GetVehicleHealth(vehicleid, Health);
    GetVehicleParamsEx(vehicleid, VehicleParams[0], VehicleParams[1], VehicleParams[2], VehicleParams[3], VehicleParams[4], VehicleParams[5], VehicleParams[6]);

    if(Health < 450) Success = false;
    else if(Health > 900) Success = true;
    else if(Health < 900 && Health > 600)
    {
        Random = random(3);
        if(Random == 0 || Random == 1) Success = true;
        else Success = false;
    }
    else if(Health < 600)
    {
        Random = random(3);
        if(Random == 0) Success = true;
        else Success = false;
    }
   
    new Stringas[101];
    switch(Success)
    {
        case true:
        {
            format(Stringas, 99, "{FFFFFF}[ {FFB000}%s {FFFFFF}]: Tr. priemonлs variklis {6EF83C}uюsikuria!", MasinuPavadinimai[GetVehicleModel(vehicleid) - 400]);
            SetVehicleParamsEx(vehicleid, 1, VehicleParams[1], VehicleParams[2], VehicleParams[3], VehicleParams[4], VehicleParams[5], VehicleParams[6]);
            PlayerPlaySound(playerid, 1057, 0, 0, 0);
        }
        default:
        {
            format(Stringas, 101, "{FFFFFF}[ {FFB000}%s {FFFFFF}]: Tr. priemonлs variklis {FF0000}neuюsikuria!", MasinuPavadinimai[GetVehicleModel(vehicleid) - 400]);
            PlayerPlaySound(playerid, 1085, 0, 0, 0);
        }
    }
    SendNearbyMessage(playerid, Stringas);
    pData[playerid][pEngine] = false;
}
Anyways, thanks.
Reply
#6

Ok, thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)