
forward EngineBreak();
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;
}
public OnPlayerSpawn(playerid)
{
//other stuff goes here
}
SetTimer("EngineBreak",1,true);
public OnPlayerSpawn(playerid)
{
SetTimer("EngineBreak",1,true);
//other stuff goes here
}
|
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(); 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;
}
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
}
Code:
SetTimer("EngineBreak",1,true);
Code:
public OnPlayerSpawn(playerid)
{
SetTimer("EngineBreak",1,true);
//other stuff goes here
}
Please comment if you liked it. Also, i`ll upload a video as soon as possible of the script in action ! /wave xD |