Quote:
Originally Posted by MadeMan
pawn Код:
stock Float:DistanceCameraTargetToLocation(playerid, Float:ObjX, Float:ObjY, Float:ObjZ) { new Float:CamX, Float:CamY, Float:CamZ; GetPlayerCameraPos(playerid, CamX, CamY, CamZ);
new Float:TGTDistance; TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));
new Float:FrX, Float:FrY, Float:FrZ; GetPlayerCameraFrontVector(playerid, FrX, FrY, FrZ);
new Float:tmpX, Float:tmpY, Float:tmpZ; tmpX = FrX * TGTDistance + CamX; tmpY = FrY * TGTDistance + CamY; tmpZ = FrZ * TGTDistance + CamZ;
return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ)); }
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) { if(newkeys & KEY_SECONDARY_ATTACK) { new Float:pos[3]; for(new v=1; v < MAX_VEHICLES; v++) { if(GetVehiclePos(v, pos[0], pos[1], pos[2])) { if(DistanceCameraTargetToLocation(playerid, pos[0], pos[1], pos[2]) < 5.0) { PutPlayerInVehicle(playerid, v, 0); return 1; } } } } } return 1; }
|
Erm..that's what i was going to say