Towing cars
#10

Quote:
Originally Posted by Denying
Посмотреть сообщение
Can I see the code where you tow the car? I mean, type /tow to tow the closest car or whatever.

Код:
This forum requires that you wait 120 seconds between posts. Please try again in 46 seconds.
lol this is a bit annoying.
Код:
#define towpickup 1569.2766,-1477.9763,13.5526
new TowTruckers=0;
new IsTowTrucker[MAX_PLAYERS];

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate==PLAYER_STATE_DRIVER)
 	{
  	if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 525)
    {
    IsTowTrucker[playerid]=1;
    TowTruckers++;
    SendClientMessage(playerid,0xFFFF00AA,"You can use the ACTION KEY to Tow cars");
    }
    }
    if((newstate==PLAYER_STATE_ONFOOT)&&(IsTowTrucker[playerid]==1))
    {
    IsTowTrucker[playerid]=0;
    TowTruckers--;
    }
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if((newkeys==KEY_ACTION)&&(IsPlayerInAnyVehicle(playerid))&&(GetPlayerState(playerid)==PLAYER_STATE_DRIVER))
 	{
  	if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 525)
   	{
    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,0xFFFF00AA,"Car towed!");
    SetPlayerCheckpoint(playerid, towpickup , 3.0);
    }
    }
    if(!Found)
    {
    SendClientMessage(playerid,0xFFFF00AA,"There is no car in range.");
    }
    }
    }
}

public OnPlayerEnterCheckpoint(playerid)
{
    DisablePlayerCheckpoint(playerid);
    if (IsPlayerInRangeOfPoint(playerid, 4.0, towpickup))
    {
    if(IsTowTrucker[playerid] == 1)
    {
	new towedcar;
	GetVehicleTrailer(towedcar);
	if(IsTrailerAttachedToVehicle(towedcar))
	{
	DestroyVehicle(towedcar);
   	GameTextForPlayer(playerid, "~g~Car towed!", 3000, 3);
   	GivePlayerMoney(playerid,50);
   	PlayerPlaySound(playerid,1056,0,0,0);
   	}
    }
    }
	return 1;
}
I used some tow truck filterscript, edited a little bit. So everything seems ok, except nothing happens when I enter the checkpoint
Reply


Messages In This Thread
Towing cars - by siemka321 - 17.03.2013, 07:18
Respuesta: Towing cars - by JustBored - 17.03.2013, 07:24
Re: Towing cars - by mrtms - 17.03.2013, 07:24
Re: Towing cars - by siemka321 - 17.03.2013, 07:52
Re: Towing cars - by Denying - 17.03.2013, 08:44
Re: Towing cars - by Scofield62 - 17.03.2013, 08:46
Re: Towing cars - by Denying - 17.03.2013, 08:48
Re: Towing cars - by siemka321 - 17.03.2013, 08:51
Re: Towing cars - by Denying - 17.03.2013, 08:52
Re: Towing cars - by siemka321 - 17.03.2013, 08:56

Forum Jump:


Users browsing this thread: 3 Guest(s)