Tow a car.
#1

Hey.

I'm failing to attach someones car to Tow car. The idea is simple, Mechanic attaches someones car to his own truck and then pulls it to where it should be.

Код:
CMD:towcar(playerid, params[])
{
	if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 525) return SendClientMessage(playerid, COLOR_GREY, "You have to be in TowCar to use this command.");
	new TowCar = GetPlayerVehicleID(playerid);
	new CarToBeTowed = GetPlayerVehicleID(params[0]);
	AttachTrailerToVehicle(CarToBeTowed, TowCar);
	return 1;
}
So, what am i doing wrong here?
Reply
#2

you are doing all wrong, try like this:
PHP код:
CMD:towcar(playeridparams[]){
    if (
GetVehicleModel(GetPlayerVehicleID(playerid)) != 525) return SendClientMessage(playeridCOLOR_GREY"You have to be in TowCar to use this command.");
    new 
Float:pXFloat pYFloat pZ;
    
GetPlayerPos(playeridpXpYpZ);
    new 
Float:vXFloat vYFloat vZ;
    new 
Found 0;
    new 
vid 0;
    while ((
vid<MAX_VEHICLES) && (!Found)) {
        
vid++;
        
GetVehiclePos(vidvXvYvZ);
        if ((
floatabs(pX vX)<7.0) && (floatabs(pY vY)<7.0) && (floatabs(pZ vZ)<7.0) && (vid != GetPlayerVehicleID(playerid))) {
            
Found 1;
            if (
IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))) {
                
DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
            }
            
AttachTrailerToVehicle(vidGetPlayerVehicleID(playerid));
            
SendClientMessage(playerid0xFFFF00AA"Car towed!");
        }
    }
    if (!
Found) {
        
SendClientMessage(playerid0xFFFF00AA"There is no car in range.");
    }
    return 
1;

Reply
#3

It's basicly the same thing, it just checks if the car is in the range....
Reply


Forum Jump:


Users browsing this thread: