Fix Command.
#1

Hey, Im making a Fix command for Mechanic class, But it doesn't repair the vehicle..
And I have to be in the vehicle, I want it so it repairs the vehicle outside of the car

Any help would be appreciated.

Here is my code

Код:
CMD:fix(playerid, params[])
{
	new
	aName[MAX_PLAYER_NAME],
	    taName[MAX_PLAYER_NAME],
		vehicleid,
		targetid
	;
 	vehicleid = GetClosestVehicle(playerid);
 	GetPlayerName(playerid, aName, sizeof(aName));
  	GetPlayerName(targetid, taName, sizeof(taName));
	if(gTeam[playerid] == ASSISTANCE)
 	{
	    if (IsPlayerInVehicle(targetid, vehicleid))
			{
        	RepairVehicle(GetPlayerVehicleID(vehicleid));
			SendClientMessage(playerid, COLOR_WHITE, "You have Succesfully repaired the Vehicle.");
   			
     		return 1;
        	}
      	else return SendClientMessage(playerid, RED, "ERROR: You are not near a vehicle!");

	}
	return 1;
}
Reply
#2

Код:
CMD:fix(playerid, params[])
{
        new vehicleid = GetPlayerVehicleID(playerid);
	new
	aName[MAX_PLAYER_NAME],
	    taName[MAX_PLAYER_NAME],
		vehicleid,
		targetid
	;
 	vehicleid = GetClosestVehicle(playerid);
 	GetPlayerName(playerid, aName, sizeof(aName));
  	GetPlayerName(targetid, taName, sizeof(taName));
	if(gTeam[playerid] == ASSISTANCE)
 	{
	    if (IsPlayerInVehicle(targetid, vehicleid))
			{
        	 SetVehicleHealth(vehicleid, 1000.0);
			SendClientMessage(playerid, COLOR_WHITE, "You have Succesfully repaired the Vehicle.");
   			
     		return 1;
        	}
      	else return SendClientMessage(playerid, RED, "ERROR: You are not near a vehicle!");

	}
	return 1;
}
++REP!!!
Reply
#3

pawn Код:
CMD:fix(playerid, params[]) {
    new
        vehicleid = GetPlayerVehicleID(playerid);
    if(gTeam[playerid] == ASSISTANCE) {
        if(IsPlayerInVehicle(playerid, vehicleid)) {
            RepairVehicle(vehicleid);
            SendClientMessage(playerid, COLOR_WHITE, "You have successfully repaired the vehicle.");
        }
        else SendClientMessage(playerid, RED, "ERROR: You are not in a vehicle!");
    }
    return 1;
}
Try that.
Reply
#4

We got it fixed cheers guys, I'll rep you both.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)