20.09.2011, 11:25
How i can make command when one vehicle is near to other and the drive write /attach to attach the vehicle behind him
CMD:attach(playerid,params[])
{
new Float:pX,Float:pY,Float:pZ;
GetPlayerPos(playerid,pX,pY,pZ);
new Float:vXx,Float:vYx,Float:vZx;
new Found=0;
new vid=0;
while((vid<MAX_VEHICLES)&&(!Found))
{
vid++;
GetVehiclePos(vid,vXx,vYx,vZx);
if ((floatabs(pX-vXx)<7.0)&&(floatabs(pY-vYx)<7.0)&&(floatabs(pZ-vZx)<7.0)&&(vid!=GetPlayerVehicleID(playerid)))
{
Found=1;
if (IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
{
DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
}
AttachTrailerToVehicle(vid,GetPlayerVehicleID(playerid));
}
}
if (!Found)
{
SendClientMessage(playerid,red,"Can't Attach!Any Vehicle Found!");
}
return 1;
}