Wondering.. - 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: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Wondering.. (
/showthread.php?tid=70849)
Wondering.. -
notec100 - 28.03.2009
Is it possible to have a check to be able to know how fast a car is going when it slams into a wall or other car and gets in a wreck or anything like that? I was just wondering since someone asked me and it's been on my mind every since. Thanks in advance!
Re: Wondering.. -
MenaceX^ - 28.03.2009
I don't understand you..
Re: Wondering.. -
notec100 - 28.03.2009
Quote:
Originally Posted by MenaceX^
I don't understand you..
|
A check like if a player is driving their vehicle, and then they wreck, or hit something, the check would be able to see how fast they are going and how much damage was done to the car or something then as a result their car would not work if it was like a bad wreck or something. I am sorry if you don't understand what I mean as I am having trouble trying to get it into words as it is scrambled in my head!
Re: Wondering.. -
hazdog - 28.03.2009
you mean if a vehicles healh is below a number, stop that vehicle from moving?
new vehiclehealth;
vehiclehealth = GetPlayerVehicleHealth(playerid);
if(vehiclehealth <= 500)
{
//do your stuff
}
Re: Wondering.. -
notec100 - 28.03.2009
Quote:
Originally Posted by hazdog
you mean if a vehicles healh is below a number, stop that vehicle from moving?
new vehiclehealth;
vehiclehealth = GetPlayerVehicleHealth(playerid);
if(vehiclehealth <= 500)
{
//do your stuff
}
|
Actually yeah something like that could also work probably
I'll try it out thanks!
Re: Wondering.. -
Shellegg - 01.04.2009
Where to put this?
in wich public?
pawn Код:
new vehiclehealth;
vehiclehealth = GetPlayerVehicleHealth(playerid);
if(vehiclehealth <= 500)
{
//do your stuff
}
Re: Wondering.. -
Pyrokid - 01.04.2009
You need to make a timer.
Re: Wondering.. -
Shellegg - 01.04.2009
Well i have one but it isnt working..
pawn Код:
forward CheckCarHealth();
pawn Код:
public OnGameModeInit()
checkcarhealthtimer = SetTimer("CheckCarHealth", 10000, 1);
pawn Код:
public CheckCarHealth()
{
new string[256];
new sendername[MAX_PLAYER_NAME];
for (new i=0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new Float:health;
GetVehicleHealth(GetPlayerVehicleID(i),health);
new newcar = GetPlayerVehicleID(i);
if (health <= 500 && !IsABoat(newcar) && !IsABike(newcar) && !IsAPlane(newcar) && !IsATaxi(newcar) && !IsAHelicopter(newcar))
{
if(EngineStatus[GetPlayerVehicleID(i)] == 1)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
TogglePlayerControllable(i, 0);
SendClientMessage(i, COLOR_RED, "O teu carro avariou.");
EngineStatus[GetPlayerVehicleID(i)] = false;
GetPlayerName(i, sendername, sizeof(sendername));
format(string, sizeof(string), "O motor de %s vai abaixo.", sendername);
ProxDetector(20.0, i, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
}
}
}
}
and i have a public to kill the timer
pawn Код:
public GameModeExitFunc()
{
KillTimer(checkcarhealthtimer);
GameModeExit();
}
whats wrong here?
Re: Wondering.. -
Finn - 01.04.2009
You need to keep track of the vehicle's speed, then if the movement of the vehicle stops suddenly and vehicle's health decreases at the same time, the vehicle has crashed into something and you can do whatever you like.
Re: Wondering.. -
Shellegg - 01.04.2009
So what i need to add more?