If vehicle health is lower than 500 set player drunk level.
#1

Okay so this is my code so far:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  new Float:health;
  new veh;
  GetVehicleHealth(veh, health);
  if(health >650)
  SetPlayerDrunkLevel (playerid, 50000);
  return 1;
}
What im trying to accomplish is that when you enter the vehicle that has it's health lower than 650, it will set your drunk level (to simulate bad steering) to 50,000.

But when I enter the vehicle that has less than 650 health, it doesnt set the drunklevel.

I would also like for it to check that it only does it for the driver, and not the passenger.
Reply
#2

pawn Код:
if(health >650)
Should be
pawn Код:
if(health < 650)
You also missed a bracket.
pawn Код:
if(health < 650)
{
SetPlayerDrunkLevel(playerid,50000);
Reply
#3

Try:
Quote:
Originally Posted by Memoryz
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  new Float:health;
  GetVehicleHealth(vehicleid, health);
  if(health < 650) SetPlayerDrunkLevel (playerid, 50000);
  return 1;
}
Reply
#4

Quote:
Originally Posted by Last_Stand_Guardian
Try:
Quote:
Originally Posted by Memoryz
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  new Float:health;
  GetVehicleHealth(vehicleid, health);
  if(health < 650) SetPlayerDrunkLevel (playerid, 50000);
  return 1;
}
This works perfectly, thanks.

How can I check that the if the person is a passenger, it doesn't set their drunklevel to 50,000 ?
Reply
#5

you could do this to make it so your not drunk on exiting the vehicle

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  new Float:health;
  GetVehicleHealth(vehicleid, health);
  if(health < 650) SetPlayerDrunkLevel (playerid, 50000);
  return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    SetPlayerDrunkLevel (playerid, 0);
        return 1;
}
Reply
#6

Quote:
Originally Posted by johnathon956
you could do this to make it so your not drunk on exiting the vehicle

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  new Float:health;
  GetVehicleHealth(vehicleid, health);
  if(health < 650) SetPlayerDrunkLevel (playerid, 50000);
  return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    SetPlayerDrunkLevel (playerid, 0);
        return 1;
}
I already have that.

Quote:
Originally Posted by Me
How can I check that the if the person is a passenger, it doesn't set their drunklevel to 50,000 ?
Reply
#7

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  new Float:health;
  GetVehicleHealth(vehicleid, health);
  if(health < 650) SetPlayerDrunkLevel (playerid, 50000);
  if(ispassenger == 1)
  {
	SetPlayerDrunkLevel(playerid, 0);
  }
  return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	SetPlayerDrunkLevel (playerid, 0);
	return 1;
}
Reply
#8

Quote:
Originally Posted by Silox
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  new Float:health;
  GetVehicleHealth(vehicleid, health);
  if(health < 650) SetPlayerDrunkLevel (playerid, 50000);
  if(ispassenger == 1)
  {
	SetPlayerDrunkLevel(playerid, 0);
  }
  return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	SetPlayerDrunkLevel (playerid, 0);
	return 1;
}
Thank you, it works perfectly.
Reply
#9

no problem
Reply
#10

or this, this is more rp?

if player health is 20hp or lower it set him drunklevel 9000 and when he exit the vehicle 5000, and when he death 0

i have this in my scripts much rp
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)