06.02.2014, 23:21
Can someone tell me why this tow system doesn't work properly? I mean, when i press "Y" the vehicle is attached, but when i press it again (it should de-attach it), doesn't work, the vehicle is still attached.
pawn Код:
if(newkeys == KEY_YES)
{
if (IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))) SendClientMessage(playerid, COLOR_GREY, "You are already towing a vehicle.");
new Float:PPPX,Float:PPPY,Float:PPPZ;
GetPlayerPos(playerid,PPPX,PPPY,PPPZ);
new Float:VVVX,Float:VVVY,Float:VVVZ;
new Found=0;
new vid=0;
while((vid<MAX_VEHICLES)&&(!Found))
{
vid++;
GetVehiclePos(vid,VVVX,VVVY,VVVZ);
if ((floatabs(PPPX-VVVX)<7.0)&&(floatabs(PPPY-VVVY)<7.0)&&(floatabs(PPPZ-VVVZ)<7.0)&&(vid!=GetPlayerVehicleID(playerid)))
{
Found=1;
AttachTrailerToVehicle(vid,GetPlayerVehicleID(playerid));
GameTextForPlayer(playerid, "~w~You are towing this vehicle!", 5000, 3);
TowingVehicle[playerid] = 1;
}
}
if (TowingVehicle[playerid] == 1)
{
DetachTrailerFromVehicle(vid);
GameTextForPlayer(playerid, "~w~You stopped towing this vehicle!", 5000, 3);
TowingVehicle[playerid] = 0;
}
}