07.10.2011, 20:31
Edit the command:
Not lift a car with TOW TRUCK in my RP
Код:
forward VehicleToPlayer(playerid,vehicleid); public VehicleToPlayer(playerid,vehicleid) { new Float:pX,Float:pY,Float:pZ,Float:cX,Float:cY,Float:cZ,Float:distance; GetPlayerPos(playerid,pX,pY,pZ); GetVehiclePos(vehicleid,cX,cY,cZ); distance = floatsqroot(floatpower(floatabs(floatsub(cX,pX)),2) + floatpower(floatabs(floatsub(cY,pY)),2) + floatpower(floatabs(floatsub(cZ,pZ)),2)); return floatround(distance); } forward GetClosestVehicle(playerid); public GetClosestVehicle(playerid) { new Float:distance = 99999.000+1,Float:distance2,result = -1; for(new i = 0; i < MAX_VEHICLES; i++) { distance2 = VehicleToPlayer(playerid,i); if(distance2 < distance) { distance = distance2; result = i; } } return result; } if(strcmp(cmdtext, "/towcar", true) == 0) { new closest = GetClosestVehicle(playerid); if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 525) { if(VehicleToPlayer(playerid, closest) < 10) { AttachTrailerToVehicle(closest, GetPlayerVehicleID(playerid)); return 1; } return 1; } return SendClientMessage(playerid, 0xFF0000FF, "You are not in a TOW TRUCK!"); }