best way? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: best way? (
/showthread.php?tid=271798)
best way? -
Gh0sT_ - 25.07.2011
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!
Re: best way? - Guest3598475934857938411 - 25.07.2011
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.
Re: best way? -
Gh0sT_ - 26.07.2011
I cant understand o_O
Re: best way? -
=WoR=Varth - 26.07.2011
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
}
}
Re: best way? -
Gh0sT_ - 26.07.2011
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.
Re: best way? -
Gh0sT_ - 26.07.2011
Ok, thanks!