low Vehicle Health.....EJECTED!
#1

Hey all,Yeah it's me AGAIN

I just wanted to know if it's possible to make it so if your vehicle Health is low it automatically ejects you?
If You can,Can you please help me try to script the code?

Thanks for all the help .
Reply
#2

yep run a timer the checks all the cars being used health and if the health is < x removeplayerfromvehicle
Reply
#3

Quote:
Originally Posted by (SF)Noobanatior
yep run a timer the checks all the cars being used health and if the health is < x removeplayerfromvehicle
Okay So I did that and I made it look like this:

public carhealth()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
{
new Float:vHealth;
if (vHealth<100.0)
RemovePlayerFromVehicle();
SetTimer("carhealth",1000,1);
}
}
}


The Ejecting Works!
But it ejects whenever somebody gets in a vehicle....
Reply
#4

This should fix it (I think)
pawn Код:
public carhealth()
{
  for(new i = 0; i < MAX_PLAYERS; i++)
  {
    new car2 = GetPlayerVehicleID(i);
    new Float:Vhealth;
    GetVehicleHealth(car2, Vhealth);
    if(Vhealth < 200)
    {    
     RemovePlayerFromVehicle(i);
     SetTimer("carhealth",1000,1); //maybe you should put the timer ongamemodeinit?
    }
  }
}
Reply
#5

pawn Код:
public carhealth()
{
for(new i = 0; i < MAX_PLAYERS; i++)
  {
  if(!IsPlayerInAnyVehicle(playerid)continue;
  new Float:vHealth;
  GetVehicleHeath(GetPlayerVehicleID(i),vHealth);
  if (vHealth<100.0) RemovePlayerFromVehicle();
  }

}
then just

SetTimer("carhealth",2000,1); on init

something like that
Reply
#6

Quote:
Originally Posted by Fj0rtizFredde
This should fix it (I think)
pawn Код:
public carhealth()
{
  for(new i = 0; i < MAX_PLAYERS; i++)
  {
   new car2 = GetPlayerVehicleID(i);
   new Float:Vhealth;
   GetVehicleHealth(car2, Vhealth);
   if(Vhealth < 200)
   {    
     RemovePlayerFromVehicle(i);
     SetTimer("carhealth",1000,1); //maybe you should put the timer ongamemodeinit?
   }
 }
}
Thanks a Bunch It works!

P.S Im trying to make it SendClientMessage(playerid,COLOR_RED,"Your Vehicle Is Going To Explode,You Have Been Ejected");

But I keep getting this error:

Код:
error 017: undefined symbol "playerid"
Reply
#7

SendClientMessage(i,COLOR_RED,"Your Vehicle Is Going To Explode,You Have Been Ejected");

you var will be a player in a loop like this in this case its "i"

hold on a sec ill do 1 more thing
pawn Код:
public carhealth()
{
for(new i = 0; i < MAX_PLAYERS; i++)
  {
  if(!IsPlayerInAnyVehicle(playerid)continue;
  new Float:vHealth;
  GetVehicleHeath(GetPlayerVehicleID(i),vHealth);
  if (vHealth<100.0) RemovePlayerFromVehicle();
  }

}
use this the other dont check if 1 is in a car
Reply
#8

Quote:
Originally Posted by (SF)Noobanatior
SendClientMessage(i,COLOR_RED,"Your Vehicle Is Going To Explode,You Have Been Ejected");

you var will be a player in a loop like this in this case its "i"

hold on a sec ill do 1 more thing
pawn Код:
public carhealth()
{
for(new i = 0; i < MAX_PLAYERS; i++)
  {
  if(!IsPlayerInAnyVehicle(playerid)continue;
  new Float:vHealth;
  GetVehicleHeath(GetPlayerVehicleID(i),vHealth);
  if (vHealth<100.0) RemovePlayerFromVehicle();
  }

}
use this the other dont check if 1 is in a car
Yes This is all correct but It doesn't know what playerid means :S
Код:
undefined symbol:playerid
Reply
#9

in the function just change playerid to i
Reply
#10

pawn Код:
public carhealth()
{
for(new i = 0; i < MAX_PLAYERS; i++)
  {
  if(!IsPlayerInAnyVehicle(i)continue;
  new Float:vHealth;
  GetVehicleHeath(GetPlayerVehicleID(i),vHealth);
  if (vHealth<100.0) {
    RemovePlayerFromVehicle(GetPlayerVehicleID(i));
    SendClientMessage(i,COLOR_RED,"Your Vehicle Is Going To Explode,You Have Been Ejected");
   }

  }

}
like this
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)