Advertisement
djhonga2001

Untitled

Nov 10th, 2015
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. int getRaycastHandle(int type)
  2. {
  3. Vector3 camrot = CAM::GET_GAMEPLAY_CAM_ROT(0);
  4. Vector3 campos = CAM::GET_GAMEPLAY_CAM_COORD();
  5. Vector3 selfvec = ENTITY::GET_ENTITY_FORWARD_VECTOR(PLAYER::PLAYER_PED_ID());
  6. Vector3 multiplied = Vector3{ RotationToDirection(&camrot).x * 1000.0f, 0, RotationToDirection(&camrot).y * 1000.0f, 0, RotationToDirection(&camrot).z * 1000.0f, 0 };
  7. int ray = WORLDPROBE::_CAST_RAY_POINT_TO_POINT(campos.x + selfvec.x, campos.y + selfvec.y, campos.z + selfvec.z, campos.x + multiplied.x * 5000, campos.y + multiplied.y * 5000, campos.z + multiplied.z * 5000, type, 0, 7);
  8. return ray;
  9. }
  10.  
  11.  
  12.  
  13.  
  14. // Raycast test
  15. if ((PLAYER::IS_PLAYER_FREE_AIMING(player) || PLAYER::IS_PLAYER_TARGETTING_ANYTHING(player)))
  16. {
  17. try
  18. {
  19. int handle = getRaycastHandle(-1);
  20. int hitsomething = 0;
  21. int entityhandle = 0;
  22. Vector3 hitCoords, surfaceNormal;
  23. int result = WORLDPROBE::_GET_RAYCAST_RESULT(handle, &hitsomething, &hitCoords, &surfaceNormal, &entityhandle);
  24. if (hitsomething != 0) // only execute if ray successfully hit something
  25. {
  26. if (ENTITY::DOES_ENTITY_EXIST(entityhandle)) // if the ray hit an entity
  27. {
  28. notifyBottom(std::to_string(entityhandle));
  29. }
  30. else // if the ray hit anything other than an entity
  31. {
  32. // use hitCoords
  33. }
  34. }
  35. }
  36. catch (...) { Log::Msg("Crashed"); }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement