22.05.2012, 15:04
Hello,
Anyone have a tow script for me?
With /tow /untow.
Ill give you +REP thank you in advance.
Anyone have a tow script for me?
With /tow /untow.
Ill give you +REP thank you in advance.
CMD:tow(playerid, params[])
{
if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, -1, "You have to be inside a tow truck");
if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 525)
{
new Float:pX1,Float:pY1,Float:pZ1;
GetPlayerPos(playerid,pX1,pY1,pZ1);
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(pX1-vX)<7.0)&&(floatabs(pY1-vY)<7.0)&&(floatabs(pZ1-vZ)<7.0)&&(vid!=GetPlayerVehicleID(playerid)))
{
Found=1;
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
{
DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
}
AttachTrailerToVehicle(vid,GetPlayerVehicleID(playerid));
}
}
}
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)<5.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!"); } } } } }