OnPlayerCrashVehicle - 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)
+--- Thread: OnPlayerCrashVehicle (
/showthread.php?tid=547264)
OnPlayerCrashVehicle -
HY - 21.11.2014
Hello. I've tried to make a function, include, when a player crashes vehicle. I tried, if his car's health it's less than 1000 then will get a message. I tried this function for a DMV Exam on my server. What's wrong here?
pawn Код:
forward OnPlayerCrashVehicle(playerid);
stock Health(playerid)
{
new vehicle;
new Float:Health;
vehicle = GetPlayerVehicleID(playerid);
GetVehicleHealth(vehicle, health);
if(health > 1000) return CallLocalFunction("OnPlayerCrashVehicle", "i", playerid);
}
public OnPlayerCrashVehicle(playerid)
{
SendClientMessage(playerid, -1, "You crashed the vehicle, so you lost DMV Exam. Please try again !");
return 1;
}
Re: OnPlayerCrashVehicle -
awsomedude - 21.11.2014
Give this include a try
https://sampforum.blast.hk/showthread.php?tid=485682 made by Emmet_
Re: OnPlayerCrashVehicle -
Evocator - 21.11.2014
Quote:
Originally Posted by HY
Hello. I've tried to make a function, include, when a player crashes vehicle. I tried, if his car's health it's less than 1000 then will get a message. I tried this function for a DMV Exam on my server. What's wrong here?
Код:
forward OnPlayerCrashVehicle(playerid);
stock Health(playerid)
{
new vehicle;
new Float:Health;
vehicle = GetPlayerVehicleID(playerid);
GetVehicleHealth(vehicle, health);
if(health > 1000) return CallLocalFunction("OnPlayerCrashVehicle", "i", playerid);
}
public OnPlayerCrashVehicle(playerid)
{
SendClientMessage(playerid, -1, "You crashed the vehicle, so you lost DMV Exam. Please try again !");
return 1;
}
|
x > 2
x greater than 2.
x < 2
x less than 2.
Re: OnPlayerCrashVehicle -
Abagail - 21.11.2014
This is inefficient all itself, and plain wrong. Just because the vehicle has lost 1000 health, does NOT mean the vehicle was crashed.
Ex:
- It could've been set by SetVehicleHealth.
- It could be because someone has attacked the vehicle.
It should be at-least worded right.
Anyway, the issue is you use this code:
pawn Код:
if(GetVehicleHealth(vehicleid) > 1000)
Which checks for higher, and not lower or even equal to. The correction would be:
pawn Код:
if(GetVehicleHealth(vehicleid) < 1000)
Re: OnPlayerCrashVehicle -
zT KiNgKoNg - 21.11.2014
Quote:
Originally Posted by awsomedude
|
I was going to suggest the same, thing. Its a cool include by a very good scripter.
Re: OnPlayerCrashVehicle -
Evocator - 21.11.2014
Quote:
Originally Posted by Abagail
This is inefficient all itself, and plain wrong. Just because the vehicle has lost 1000 health, does NOT mean the vehicle was crashed.
Ex:
- It could've been set by SetVehicleHealth.
- It could be because someone has attacked the vehicle.
It should be at-least worded right.
Anyway, the issue is you use this code:
pawn Код:
if(GetVehicleHealth(vehicleid) > 1000)
Which checks for higher, and not lower or even equal to. The correction would be:
pawn Код:
if(GetVehicleHealth(vehicleid) < 1000)
|
I dont know if you can read the post above urs, and the one above the above that stated thats itll be used for a "DMV Exam" so his code does the job for it.
Re: OnPlayerCrashVehicle -
Abagail - 21.11.2014
Quote:
Originally Posted by Ralfie
I dont know if you can read the post above urs, and the one above the above that stated thats itll be used for a "DMV Exam" so his code does the job for it.
|
Yes, how-ever he should use something like:
OnPlayerFailExam.
The wording can be very misleading, which can cause issues later on when your script starts becoming larger.