if(strcmp(cmd, "/attach", true) == 0) { if(IsPlayerInAnyVehicle(playerid)) { new vehid; new vehid2; vehid = GetPlayerVehicleID(playerid); vehid2 = GetClosestCar(playerid); AttachTrailerToVehicle(vehid,vehid2); } } |
if(strcmp(cmd, "/attach", true) == 0)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehid;
new vehid2;
vehid = GetPlayerVehicleID(playerid);
vehid2 = GetClosestCar(playerid);
AttachTrailerToVehicle(vehid,vehid2);
}
return 1;
}
if(strcmp(cmd, "/attach", true) == 0) { if(IsPlayerInAnyVehicle(playerid)) { new vehid; new vehid2; vehid = GetPlayerVehicleID(playerid); vehid2 = GetClosestVehicle(playerid); AttachTrailerToVehicle(vehid,vehid2); } return 1; } |
stock GetClosestVehicle(playerid) { new vehicle = -1, Float:dis = 2000.0; for(new i = 0; i < MAX_VEHICLES; i++) { new Float:dis2 = GetPlayerDistanceToVehicle(playerid, i); if(dis2 > dis) { dis = dis2; vehicle = i; } } return vehicle; } stock Float:GetPlayerDistanceToVehicle(playerid, vehicleid) { new Floatos[3]; GetVehiclePos(vehicleid, pos[0], pos[1], pos[2]); return GetPlayerDistanceToPoint(playerid, pos[0], pos[1], pos[2]); } stock Float:GetPlayerDistanceToPoint(playerid, {Float,_}:...) { new num = numargs(), Floatos[3]; GetPlayerPos(playerid, pos[0], pos[1], pos[2]); if(num == 3) return floatsqroot(floatpower(floatabs(floatsub(pos[0], Float:getarg(1))), 2) + floatpower(floatabs(floatsub(pos[1], Float:getarg(2))), 2)); else if(num == 4) return floatsqroot(floatpower(floatabs(floatsub(pos[0], Float:getarg(1))), 2) + floatpower(floatabs(floatsub(pos[1], Float:getarg(2))), 2) + floatpower(floatabs(floatsub(pos[2], Float:getarg(3))), 2)); return -1.0; } |
if(strcmp(cmd, "/attach", true) == 0) { if(IsPlayerInAnyVehicle(playerid)) { new vehid; new vehid2; vehid = GetPlayerVehicleID(playerid); vehid2 = GetClosestVehicle(playerid); PutPlayerInVehicle ( playerid, vehid2, 0 ); PutPlayerInVehicle ( playerid, vehid, 0 ); AttachTrailerToVehicle(vehid2,vehid); //vehid2 is the "trailer"! This must be the first! } return 1; }