[Help] Native for making NPC see entity as an object?

Yes, but there is no native to track all Peds. There is this:

http://runtime.fivem.net/doc/reference.html#_0xC33AB876A77F8164

With this you can always track the nearest one, but if there are many peds this is a shitty way to do it…

I had this idea… bit vauge but you get my idea…

Is there a way i can spawn a car, but have it invisible to regular players and have you be able to walk through were the car would be
That meaning NPC will trigger that there is a car there, but players dont see it

I found this?

Not the best but could it work?

TASK_SHOCKING_EVENT_REACT #
// 0x452419CBD838065B 0x9BD00ACF
void TASK_SHOCKING_EVENT_REACT(Ped ped, int eventHandle);

EDIT: I just saw my dumbass mistake here, thats for the ped, anyone know the native to shock the peds?

This maybe?

IS_SHOCKING_EVENT_IN_SPHERE #
// 0x1374ABB7C15BAB92 0x2F98823E
BOOL IS_SHOCKING_EVENT_IN_SPHERE(int type, float x, float y, float z, float radius);
Some events that i found, not sure about them, but seems to have logic based on my tests:

    '82 - dead body
    '86 
    '87 
    '88 - shooting, fire extinguisher in use
    '89 
    '93 - ped using horn
    '95 - ped receiving melee attack
    '102 - living ped receiving shot
    '104 - player thrown grenade, tear gas, smoke grenade, jerry can dropping gasoline
    '105 - melee attack against veh
    '106 - player running
    '108 - vehicle theft
    '112 - melee attack
    '113 - veh rollover ped
    '114 - dead ped receiving shot
    '116 - aiming at ped
    '121

You could try ADD_SHOCKING_EVENT_AT_POSITION(int type, float x, float y, float z, float duration); and use the x y z of the object maybe? I’m not sure how that will help them drive around in a nice way. They’ll probably all go bat shit crazy.

This txt appears to have more events then what you have in your list there http://camx.me/gtav/tasks/shockingevents.txt

did you see my previous idea? Im kinda sure that would work

The invisible car? I’m not sure if the AI would drive around it. In my experience, they just stop behind it and form a long line of traffic and never move until the car moves.

I figured that would be the case, but if there are many cones in an area they would eventually get tired and force there way around it no?

I am not sure about that. I’ve never really paid too much attention or played around with it.

Going to try it and see what happens, I just need a native to set the car so players can walk through it?

SetEntityNoCollisionEntity(ent1, ent2, true/false)

This will make it so ent1 and ent2 don’t collide. I’m not sure if there is a better way to do it. I’ve only used this just to stop two players colliding in some instances.

Edit: or you could try SET_ENTITY_COLLISION(Entity entity, BOOL toggle, BOOL keepPhysics). Set keepPhysics to true. I assume that will keep the car there, but everybody will be able to drive/walk through it. Even if there is no collision, maybe the AI will still “see” it?

2 Likes

Maybe some of these might work for you.

SET_PED_PATHS_IN_AREA(float x1, float y1, float z1, float x2, float y2, float z2, BOOL unknown)

BOOL IS_ANY_PED_NEAR_POINT(float x, float y, float z, float radius)

SET_PED_PATHS_BACK_TO_ORIGINAL(Any p0, Any p1, Any p2, Any p3, Any p4, Any p5)

Possibly do a continuous check if a pedal is near the point you lay the item. Then offset the peds path in the area and then once outside that area set it back?

Not sure they would work :confused: Eugh this is triggering me so hard xD

This could for sure work! I can try it, i just need a function to spawn the vehicle now rip my life

This is an excerpt from a script I use. You need to load the model and make sure it is ready before spawning.

local veh = GetHashKey("fbi") RequestModel(veh) while not HasModelLoaded(veh) do Citizen.Wait(1) end veh = CreateVehicle(veh, x, y, z, true, false)

could i use

local carid = issi2
CreateVehicle(carid, playerCoords, 0.0, true, false)

but edit create vehicle to work in my function?

	local carid = adder
		end

		veh = CreateVehicle(carid, playerCoords, 0.0, true, false)
		SetEntityInvincible(veh, true)
	end
end)

Somthing like?

    RequestModel(veh)

	while not HasModelLoaded(veh) do
		Wait(1)
	end

	SetVehicleOnGroundProperly(veh)

those might help Curt

1 Like

Honestly, my brains dead… This thing is sending me loopy… my brain cant fathem how to make a car spawn with it in the same function as the cone 0_o

Makes life even harder because i wont share the code yet 0.0

Eugh xD

And a car isnt an entity is it? so i cant make it work the same way…

And now thinking about it, i could see this making many cones spawned causing lagg…

hold on… can i make it so if a vehicle touches the entity the car despawns?

Very weird move yes, but can act out like it ports them away to mars lol! this way no car pile ups etC?

Umm i’m not sure but what I would do and I’m super new to scripting and to lua and it’s also been a long day for me.

Howevere, I’d create a separate function to spawn my vehicle with some sort of input or something to that function.then at some point in the cone function I’d make a call to the car spawn function that runs the car function based on that input.

I am pretty sure the car is an Entity based on this

IS_ENTITY_A_VEHICLE #
// 0x6AC7003FA6E5575E 0xBE800B01
BOOL IS_ENTITY_A_VEHICLE(Entity entity);

which you might be able to use.

I had a less resoursive idea…

Is the correct?

if HasEntityBeenDamagedByAnyVehicle(cone) = true then DeleteVehicle(&vehicle)

Or would this delete every damn vehicle?

But i have to first set there car as a missionvehicle…

Eughhhh

edit:

BOOL IS_ANY_PED_NEAR_POINT

this could work but what to do after this im not sure.