29.10.2008, 13:38
I want the car to be towed everytime I press "Caps Lock"
And when I press it again, it UnTows the car..
For UnTowing it when I press Caps Lock again, what do I have to change here ?
And when I press it again, it UnTows the car..
For UnTowing it when I press Caps Lock again, what do I have to change here ?
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if ((newkeys==KEY_CROUCH)&&(IsPlayerInAnyVehicle(playerid))&&(GetPlayerState(playerid)==PLAYER_STATE_DRIVER)) { if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 525) { SendClientMessage(playerid,COLOR_WHITE,"trying to tow a car"); 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,COLOR_WHITE,"Car towed!"); } } if (!Found) { SendClientMessage(playerid,COLOR_GREY,"There is no car in range."); } } } }