[ADDON] Engine Breaking System bY MihaiTZa55
#3

Quote:
Originally Posted by MihaiTZa55
Hi there ! This is my first release on sa-mp.com
So here`s what it does...
When your car is very soon to blowing up, a timer gives it a little more health (so that it doesn`t blow up) and removes the player from the vehicle.
This is an AddOn, so you have to add it in your GameMode by yourself !
Here are the code`s :

1. Forward : add it up, where you will see a lot of "forward"s :
Code:
forward EngineBreak();
2. Public : add it up or down, where you will see a lot of "public"s "
Code:
public EngineBreak()
{
  for(new i = 0; i < MAX_PLAYERS; i++)
  {
		if(IsPlayerInAnyVehicle(i))
		{
			new Float:TempCarHealth;
			GetVehicleHealth(GetPlayerVehicleID(i), TempCarHealth);
			if(TempCarHealth <= 250.0)
			{
				SetVehicleHealth(GetPlayerVehicleID(i), 350.0);
				SendClientMessage(i, COLOR_RED, "The vehicle`s engine was broken ! Repair it before proceeding !!!");
				RemovePlayerFromVehicle(i);
				return 1;
			}
		}
	}
	return 1;
}
3. Setting the timer on.
I used this under OnPlayerSpawn, because it would be the simple-est way possible. So under OnPlayerSpawn, you will see something like this :
Code:
public OnPlayerSpawn(playerid)
{
//other stuff goes here
}
Add this :
Code:
SetTimer("EngineBreak",1,true);
And it will look like this :
Code:
public OnPlayerSpawn(playerid)
{
SetTimer("EngineBreak",1,true);
//other stuff goes here
}
Made entirely by me, MihaiTZa55.
Please comment if you liked it.
Also, i`ll upload a video as soon as possible of the script in action !
/wave
xD
Mmmm...

I woudn't use a timer and the loop through all players if I can simply pass the player to the function and apply this only to him.

In your script your checking all the time if all 500 players are in a vehicle (no matter if they are connected or not, or they are npc) all the time.

Try using SetTimerEx to polish your script. It will be a lot better.

Reply


Messages In This Thread
[ADDON] Engine Breaking System bY MihaiTZa55 - by mihaitza55 - 05.06.2010, 19:53
Re: [ADDON] Engine Breaking System bY MihaiTZa55 - by gaby975 - 05.06.2010, 21:13
Re: [ADDON] Engine Breaking System bY MihaiTZa55 - by clavador - 05.06.2010, 22:51
Re: [ADDON] Engine Breaking System bY MihaiTZa55 - by Flake. - 05.06.2010, 22:54

Forum Jump:


Users browsing this thread: 2 Guest(s)