SA-MP Forums Archive
Repair Car problems - 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: Repair Car problems (/showthread.php?tid=547629)



Repair Car problems - FiveCentz - 23.11.2014

So I am making just a little repair car FS and there is some problems.

1. When you are outside of a car it says "The vehicle is too damage to repair" instead of "You must be inside a vehicle"
2. When the vehicle is under 900DL it sends the clientmessage but never repairs it.
Thanks for any help.

Код:
CMD:fixveh(playerid, params[])
{
    new Float:health;
    new veh = GetPlayerVehicleID(playerid);
    GetVehicleHealth(veh, health);
    {
		if(health > 900) return SendClientMessage(playerid, COLOR_RED, "Vehicle doesn't need repairing!");
		else if(health < 500) return SendClientMessage(playerid, COLOR_RED, "Vehicle is too damaged! Get a mechanic!");
		if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, COLOR_RED, "You don't have enough money! You need $500!");
		else if(GetPlayerMoney(playerid) > 500) return SendClientMessage(playerid, COLOR_GREEN, "The vehicle is now repaired."); SetVehicleHealth(veh, 1000.0); GetPlayerMoney(playerid, -500);
		return 0
	}
	IsPlayerInAnyVehicle(playerid);
	{
		if(false) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle");
		return 0
	}
	return 1;



Re: Repair Car problems - Vince - 23.11.2014

Statements are evaluated top to bottom, not in some random order. You're already checking the health before you have verified that the player is actually in a vehicle.


Re: Repair Car problems - FiveCentz - 23.11.2014

What about it not fixing itself? And I will the try putting it at the top/

E:

Код:
CMD:fixveh(playerid, params[])
{
    new Float:health;
    new veh = GetPlayerVehicleID(playerid);
    IsPlayerInAnyVehicle(playerid);
	{
		if(false) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle");
	}
    GetVehicleHealth(veh, health);
    {
		if(health > 900) return SendClientMessage(playerid, COLOR_RED, "Vehicle doesn't need repairing!");
		else if(health < 500) return SendClientMessage(playerid, COLOR_RED, "Vehicle is too damaged! Get a mechanic!");
		if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, COLOR_RED, "You don't have enough money! You need $500!");
		else if(GetPlayerMoney(playerid) > 500) return SendClientMessage(playerid, COLOR_GREEN, "The vehicle is now repaired."); SetVehicleHealth(veh, 1000.0); GetPlayerMoney(playerid, -500);
	}
	return 1;
}
The script is like that now, but it still didnt work.


Re: Repair Car problems - UltraScripter - 23.11.2014

pawn Код:
CMD:fixveh(playerid, params[])
{
    new Float:health;
    new veh = GetPlayerVehicleID(playerid);
    GetVehicleHealth(veh, health);
    {
        if(health > 900) return SendClientMessage(playerid, COLOR_RED, "Vehicle doesn't need repairing!");
        else if(health < 500) return SendClientMessage(playerid, COLOR_RED, "Vehicle is too damaged! Get a mechanic!");
        if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, COLOR_RED, "You don't have enough money! You need $500!");
        else if(GetPlayerMoney(playerid) > 500) return SendClientMessage(playerid, COLOR_GREEN, "The vehicle is now repaired."); RepairVehicle(veh) GetPlayerMoney(playerid, -500);
        return 0
    }
    IsPlayerInAnyVehicle(playerid);
    {
        if(false) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle");
        return 0
    }
    return 1;



Re: Repair Car problems - FiveCentz - 23.11.2014

http://prntscr.com/59hkj0 I got errors when I did that.


Re: Repair Car problems - UltraScripter - 23.11.2014

Ok Try This :
pawn Код:
CMD:fixveh(playerid, params[])
{
    new veh, Float:health;
    veh = GetPlayerVehicleID(playerid);
    GetVehicleHealth(veh, health);
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You must be in vehicle");
        if(health >= 900) return SendClientMessage(playerid, 0xFF0000FF, "Vehicle doesn't need repairing!");
        else if(health <= 500) return SendClientMessage(playerid, 0xFF0000FF, "Vehicle is too damaged! Get a mechanic!");
        if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, 0xFF0000FF, "You don't have enough money! You need $500!");
        SendClientMessage(playerid, 0x00FF00FF, "The vehicle is now repaired.");
        RepairVehicle(veh);
        GivePlayerMoney(playerid, -500);
    }
    return 1;
}



Re: Repair Car problems - FiveCentz - 23.11.2014

It works! THANKS!


Re: Repair Car problems - UltraScripter - 23.11.2014

No Prob Bro !.