Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int getRaycastHandle(int type)
- {
- Vector3 camrot = CAM::GET_GAMEPLAY_CAM_ROT(0);
- Vector3 campos = CAM::GET_GAMEPLAY_CAM_COORD();
- Vector3 selfvec = ENTITY::GET_ENTITY_FORWARD_VECTOR(PLAYER::PLAYER_PED_ID());
- Vector3 multiplied = Vector3{ RotationToDirection(&camrot).x * 1000.0f, 0, RotationToDirection(&camrot).y * 1000.0f, 0, RotationToDirection(&camrot).z * 1000.0f, 0 };
- 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);
- return ray;
- }
- // Raycast test
- if ((PLAYER::IS_PLAYER_FREE_AIMING(player) || PLAYER::IS_PLAYER_TARGETTING_ANYTHING(player)))
- {
- try
- {
- int handle = getRaycastHandle(-1);
- int hitsomething = 0;
- int entityhandle = 0;
- Vector3 hitCoords, surfaceNormal;
- int result = WORLDPROBE::_GET_RAYCAST_RESULT(handle, &hitsomething, &hitCoords, &surfaceNormal, &entityhandle);
- if (hitsomething != 0) // only execute if ray successfully hit something
- {
- if (ENTITY::DOES_ENTITY_EXIST(entityhandle)) // if the ray hit an entity
- {
- notifyBottom(std::to_string(entityhandle));
- }
- else // if the ray hit anything other than an entity
- {
- // use hitCoords
- }
- }
- }
- catch (...) { Log::Msg("Crashed"); }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement