how to make that when a player bump with a car he loose health?
#1

Hey guys i'm posting to ask how can i make so when a player is driver/passenger and the car bumps into something, he loose health? like example:

A car colide with a wall so the driver and passengers loose health.

and is it possible to make depending on the car's speed the amount of damage they can get? Like if someone bumping in a wall at 5/kmh will loose 1 of health and if he bumps at 120/kmh he loose 75 health? I'm just wondering if it would bug with some other collisions, like if they hit like a player or anything light the poeple in the car could die or loose health :\....

Thanks for answers scripters!
Reply
#2

OnPlayerVehicleDamage right?
Reply
#3

yea i think it's that, well i'll try to look at it l8. But does anyone know if what im asking on first post is possible?
Reply
#4

You might be able to add onplayerupdate
if veh health is a certain thing then they die. it's possible.
Reply
#5

http://forum.sa-mp.com/index.php?topic=85402.0 - I found that. I could also swear that a filterscript for this was released, but this topic will get you working code.
Reply
#6

Quote:
Originally Posted by TheOneThatOwnZ
You might be able to add onplayerupdate
if veh health is a certain thing then they die. it's possible.
yea but the problem with that is that if a player would enter a car intensely damaged, he would instantly die :S

it must be like when a car bumps a wall or an other car, then the player would loose health, depending on speed but not when they bump players or poles, or any kind of light stuff... I don't think it's possible, but it would freaking great

thanks for the link burridge, i'll take a look at it.
Reply
#7

i found on the link two usefull scripts i think:
Quote:
Originally Posted by Pixels^
I have this snippet in one of my gamemodes. Read the comments carefully, if you use this snippet, make sure you give credits to their rightful owners.
Код:
//Credits to Pixels^ and only Pixels^, and maybe some to Peter.
enum SavePlayerPosEnum //Peter's Speedo Code
{
  Float:LastX, //Peter's Speedo Code
  Float:LastY, //Peter's Speedo Code
  Float:LastZ //Peter's Speedo Code
} //Peter's Speedo Code
new SavePlayerPos[MAX_PLAYERS][SavePlayerPosEnum]; //Peter's Speedo Code

new lSpeed[MAX_PLAYERS]; //create an array that will store lastspeed.
new cSpeed[MAX_PLAYERS]; //create an array that will store currentspeed.
forward SpeedSystem(); //forward our public

public SpeedSystem()
{
  new Float:x, Float:y, Float:z, distance;
  for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i))
  {
    if(GetPlayerState(i) == 3 || GetPlayerState(i) == 2)
    {
      lSpeed[i] = cSpeed[i]; //set last speed to current speed.
      // Peter's speedo code
      distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2));
      // Peter's speedo code
      cSpeed[i] = floatround(distance * 5.4); //Set cSpeed to his current speed.
      SavePlayerPos[i][LastX] = x; // Peter's speedo code
      SavePlayerPos[i][LastY] = y; // Peter's speedo code
      SavePlayerPos[i][LastZ] = z; // Peter's speedo code
      if(lSpeed[i] <= 10 && (cSpeed[i] - lSpeed[i]) >= 20) //Check if the last speed is very low
      { //and the difference between currentspeed and lastspeed is really great.
        //Do the damage here
        //Of course you need to check if player is using the brake key
        //I'll let you do that yourself!
      }
    }
  }
}
and:
Quote:
Originally Posted by °ғαιιοцт°
here's my code

Код:
new Float:CarHealth[MAX_PLAYERS];

public OnPlayerUpdate(playerid)
{
	if(IsPlayerInAnyVehicle(playerid) == 1)
	{
		new Float:TempCarHealth;
		GetVehicleHealth(GetPlayerVehicleID(playerid), TempCarHealth);
		new Float:Difference = floatsub(CarHealth[playerid], TempCarHealth);
		if((floatcmp(CarHealth[playerid], TempCarHealth) == 1) && (floatcmp(Difference,100.0) == 1))
		{
		  Difference = floatdiv(Difference, 10.0);
		  new Float:OldHealth;
		  GetPlayerHealth(playerid, OldHealth);
		  SetPlayerHealth(playerid, floatsub(OldHealth, Difference));
		}
		CarHealth[playerid] = TempCarHealth;
	}
	else
	{
		CarHealth[playerid] = 0.0; //To aviod that a player dies when he enters a vehicle
	}
    return 1;
}
i'll see if they work combined xD


EDIT:
I figured how to combine them, but i have 2 warnings, and i tried it and it don't work, nothing happens xD:
Код:
C:\Program Files (x86)\Rockstar games\Gta San Andreas\dedicated server\filterscripts\carcrashes.pwn(31) : warning 213: tag mismatch
C:\Program Files (x86)\Rockstar games\Gta San Andreas\dedicated server\filterscripts\carcrashes.pwn(51) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
script:
Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>

#if defined FILTERSCRIPT

enum SavePlayerPosEnum //Peter's Speedo Code
{
  Float:LastX, //Peter's Speedo Code
  Float:LastY, //Peter's Speedo Code
  Float:LastZ //Peter's Speedo Code
} //Peter's Speedo Code
new SavePlayerPos[MAX_PLAYERS][SavePlayerPosEnum]; //Peter's Speedo Code

new lSpeed[MAX_PLAYERS]; //create an array that will store lastspeed.
new cSpeed[MAX_PLAYERS]; //create an array that will store currentspeed.
forward SpeedSystem(playerid); //forward our public

public SpeedSystem(playerid)
{
  new Float:x, Float:y, Float:z, distance;
	new Float:CarHealth[MAX_PLAYERS];
  for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i))
  {
    if(GetPlayerState(i) == 3 || GetPlayerState(i) == 2)
    {
      lSpeed[i] = cSpeed[i]; //set last speed to current speed.
      // Peter's speedo code
      distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2));
      // Peter's speedo code
      cSpeed[i] = floatround(distance * 5.4); //Set cSpeed to his current speed.
      SavePlayerPos[i][LastX] = x; // Peter's speedo code
      SavePlayerPos[i][LastY] = y; // Peter's speedo code
      SavePlayerPos[i][LastZ] = z; // Peter's speedo code
      if(lSpeed[i] <= 10 && (cSpeed[i] - lSpeed[i]) >= 20) //Check if the last speed is very low
      { //and the difference between currentspeed and lastspeed is really great.
		new Float:TempCarHealth;
		GetVehicleHealth(GetPlayerVehicleID(playerid), TempCarHealth);
		new Float:Difference = floatsub(CarHealth[playerid], TempCarHealth);
		if((floatcmp(CarHealth[playerid], TempCarHealth) == 1) && (floatcmp(Difference,100.0) == 1))
		{
		  Difference = floatdiv(Difference, 10.0);
		  new Float:OldHealth;
		  GetPlayerHealth(playerid, OldHealth);
		  SetPlayerHealth(playerid, floatsub(OldHealth, Difference));
	}
		CarHealth[playerid] = TempCarHealth;
	}
	else
	{
	CarHealth[playerid] = 0.0; //To aviod that a player dies when he enters a vehicle
	}

	}
 }
	return 1;
	}
Reply
#8

Why are you combining them? Just use one or the other.
Reply
#9

because the first one is not having a damage function, he told to add it. But now it works, i use fallout's the only thing is that it doesnt hurt people when they hit a car.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)