Towing Cars
#1

I want the car to be towed everytime I press "Caps Lock"
And when I press it again, it un tows the car..

But it only tows it.. I cant untow..
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
	{
	if ((newkeys==KEY_CROUCH)&&(IsPlayerInAnyVehicle(playerid))&&(GetPlayerState(playerid)==PLAYER_STATE_DRIVER))
	  {
	  if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 525)
	    {
	    SendClientMessage(playerid,COLOR_WHITE,"trying to tow a car");
			new Float:pX,Float:pY,Float:pZ;
			GetPlayerPos(playerid,pX,pY,pZ);
			new Float:vX,Float:vY,Float:vZ;
			new Found=0;
			new vid=0;
			while((vid<MAX_VEHICLES)&&(!Found))
  				{
  				vid++;
  				GetVehiclePos(vid,vX,vY,vZ);
  				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(vid,GetPlayerVehicleID(playerid));
  				  SendClientMessage(playerid,COLOR_WHITE,"Car towed!");
  				  }
    			}
			if (!Found)
			  {
			  SendClientMessage(playerid,COLOR_GREY,"There is no car in range.");
			  }
		  }
	  }
	}
Help Please ?
Reply
#2

Enyone ?
Reply
#3

im not sure how to untow cars i try and c if i can do it...
but 4 now u'll just have to smash the car into a building or a tree...
by drifting into it.

Reply
#4

Capslock is not a Key registered , choose another one , for example

newkeys & KEY_SECONDARY_ATTACK
Reply
#5

Quote:
Originally Posted by Rady
I want the car to be towed everytime I press "Caps Lock"
And when I press it again, it un tows the car..

But it only tows it.. I cant untow..
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
	{
	if ((newkeys==KEY_CROUCH)&&(IsPlayerInAnyVehicle(playerid))&&(GetPlayerState(playerid)==PLAYER_STATE_DRIVER))
	  {
	  if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 525)
	    {
	    SendClientMessage(playerid,COLOR_WHITE,"trying to tow a car");
			new Float:pX,Float:pY,Float:pZ;
			GetPlayerPos(playerid,pX,pY,pZ);
			new Float:vX,Float:vY,Float:vZ;
			new Found=0;
			new vid=0;
			while((vid<MAX_VEHICLES)&&(!Found))
 				{
 				vid++;
 				GetVehiclePos(vid,vX,vY,vZ);
 				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));
                    SendClientMessage(playerid, COLOR_WHITE, "Car untowed!");
                    return 1;
 				    }
 				  AttachTrailerToVehicle(vid,GetPlayerVehicleID(playerid));
 				  SendClientMessage(playerid,COLOR_WHITE,"Car towed!");
 				  }
   			}
			if (!Found)
			  {
			  SendClientMessage(playerid,COLOR_GREY,"There is no car in range.");
			  }
		  }
	  }
	}
Help Please ?
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(p layerid)))
{
DetachTrailerFromVehicle(GetPlayerVehicleID(player id));
SendClientMessage(playerid, COLOR_WHITE, "Car untowed!");
return 1;
}

return 1; under DetachTrailerFromVehicle(GetPlayerVehicleID(player id));
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)