OnPlayerCrashVehicle
#1

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;
}
Reply
#2

Give this include a try https://sampforum.blast.hk/showthread.php?tid=485682 made by Emmet_
Reply
#3

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.
Reply
#4

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)
Reply
#5

Quote:
Originally Posted by awsomedude
Посмотреть сообщение
Give this include a try https://sampforum.blast.hk/showthread.php?tid=485682 made by Emmet_
I was going to suggest the same, thing. Its a cool include by a very good scripter.
Reply
#6

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.
Reply
#7

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)