vehicle health and engine command
#1

hello guys. I have an engine command which starts or stops the engine and i tried to get a damage system like if cehicle is too much damaged, player maybe will not be able to start the engine. I know its nothing unique but i tried to do it myself. My problem is whatever health vehicle has, it always starts the engine no matter what. Any help is appreciated.

Код:
CMD:engine(playerid,params[])
{
	if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid,COLOR_RED,"You have to be in your vehicle to use this command.");
	new engine,lights,alarm,doors,bonnet,boot,objective,Float:carhp,number,vid,strr[128];
	vid = GetPlayerVehicleID(playerid);
	if(strcmp(GetName(playerid),vInfo[vid][vOwner])==0)
	{
	    if(!vInfo[vid][engin])
	    {
	    	number = random(100);
			GetVehicleHealth(vid,carhp);
			if(carhp>=65)
			{
			    GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
				SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
				vInfo[vid][engin]=true;
				format(strr,sizeof(strr),"%s has started the vehicle's engine.",GetName(playerid));
				ProxDetector(23.0,playerid,strr,COLOR_MEDIUMPURPLE);
				return 1;
   			}
			if(55<carhp<65)
			{
			    if(number<40)
			    {
			        return SCM(playerid,COLOR_RED,"Engine couldn't start due to damage.");
			    }
			    else
			    {
					GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
					SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
					vInfo[vid][engin]=true;
					format(strr,sizeof(strr),"%s has started the vehicle's engine.",GetName(playerid));
					ProxDetector(23.0,playerid,strr,COLOR_MEDIUMPURPLE);
					return 1;
			    }
			}
			if(carhp<56)
			{
			    if(number<80)
			    {
			        return SCM(playerid,COLOR_RED,"Engine couldn't start due to the damage.");
			    }
			    else
			    {
					GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
					SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
					vInfo[vid][engin]=true;
					format(strr,sizeof(strr),"%s has started the vehicle's engine.",GetName(playerid));
					ProxDetector(23.0,playerid,strr,COLOR_MEDIUMPURPLE);
					return 1;
			    }
			}
			return 1;
		}
		if(vInfo[vid][engin])
		{
			GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
			SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
			vInfo[vid][engin]=false;
			format(strr,sizeof(strr),"%s has stopped the vehicle's engine.",GetName(playerid));
			ProxDetector(23.0,playerid,strr,COLOR_MEDIUMPURPLE);
			return 1;
		}
	}
	else
	{
		return SCM(playerid,COLOR_RED,"You don't have keys to this vehicle.");
	}
	return 1;
}
Reply
#2

maybe try checking if its > as well?

Sort of like this

Код:
if(carhp<56)
{
// do stuff
}
if(carhp>56)
{
// do stuff
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)