24.10.2011, 13:57
Hi,
I have this code:
It works fine.. I can drive up to a vehicle and tow it.. But i cannot detach the trailer, any ideas why?
I have this code:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) == 525)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(newkeys == KEY_FIRE)
{
if(IsTrailerAttachedToVehicle(vehicleid))
{
DetachTrailerFromVehicle(GetVehicleTrailer(vehicleid));
}
else
{
new Float:x, Float:y, Float:z;
GetVehiclePos(vehicleid, x, y, z);
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(IsVehicleInRangeOfPoint(i, 6, x, y, z))
{
AttachTrailerToVehicle(i, vehicleid);
}
}
}
}
}
}
}
return 1;
}