SA-MP Forums Archive
[ADDON] Engine Breaking System bY MihaiTZa55 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [ADDON] Engine Breaking System bY MihaiTZa55 (/showthread.php?tid=152774)



[ADDON] Engine Breaking System bY MihaiTZa55 - mihaitza55 - 05.06.2010

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


Re: [ADDON] Engine Breaking System bY MihaiTZa55 - gaby975 - 05.06.2010

Cool script. Congratz


Re: [ADDON] Engine Breaking System bY MihaiTZa55 - clavador - 05.06.2010

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.




Re: [ADDON] Engine Breaking System bY MihaiTZa55 - Flake. - 05.06.2010

nice script! would be awesome for a RP server