Jump to content

How to make player ped attack another ped?


Recommended Posts

Cloud_Power

As the title says...

I've tried :

 

Game.Player.Character.Task.FightAgainst(enemy);

 

Game.Player.Character.Task.ShootAt(enemy);

TASK_COMBAT_PED(Ped ped, Ped targetPed, int p2, int p3)
TASK_PUT_PED_DIRECTLY_INTO_MELEE(Ped ped, Ped meleeTarget, float p2,  float p3, float p4, BOOL p5)

without any luck!

 

How can I task the player ped to do that?

 

Thank you! :D

Link to comment
https://gtaforums.com/topic/882883-how-to-make-player-ped-attack-another-ped/
Share on other sites

jedijosh920

I don't think you can do that with a player controlled ped. Albeit, I recommend creating a fake gameplay camera with a fake ped attached to the player and control the fake ped while applying the task to the player ped.

Edited by jedijosh920
Cloud_Power

Right... I'm trying to avoid that though... Do you know any way to "simulate" an input? I mean, you press anything, but the game just receive an input. I have found

void SIMULATE_PLAYER_INPUT_GAIT(Any p0, Any p1, Any p2, Any p3, Any p4,  Any p5)

But there is no documentation at all...

Right... I'm trying to avoid that though... Do you know any way to "simulate" an input? I mean, you press anything, but the game just receive an input. I have found

void SIMULATE_PLAYER_INPUT_GAIT(Any p0, Any p1, Any p2, Any p3, Any p4,  Any p5)

But there is no documentation at all...

You can simulate an input with SetControlNormal. For some reason the unofficial native name, which was _SET_CONTROL_NORMAL, was removed from the NativeDB; the hash is 0xE8A25867FBA3B05E. Use GetControlValue to get an idea of what kind of values you'd need to input.

  • Like 1
Cloud_Power

EDIT:

Nevermind, my bad. I've found out that 127.0f is when the Attack button is released and 254.0f when pressed.

The game does recognize that when I use SetControlNormal, but nothing happens.

No animation, no melee fight, nothing... Do you guys have an idea?

if(Game.IsControlJustReleased(0, GTA.Control.Attack)){     UI.Notify(Game.GetControlNormal(0, GTA.Control.Attack).ToString());}
if(Game.IsControlJustReleased(0, GTA.Control.Attack)){     UI.Notify(Game.GetControlValue(0, GTA.Control.Attack).ToString());}

Both gives me 0

 

but when I use

if(e.KeyCode == Keys.O){     Game.SetControlNormal(0, GTA.Control.Attack, 0.0f);}

Nothing happens. Maybe I'm using this in a wrong way? Can you kindly shine a light on this for me? :D

I really appreciate your help! ;)

Edited by Cloud_Power

Nothing happens. Maybe I'm using this in a wrong way? Can you kindly shine a light on this for me? :D

I really appreciate your help! ;)

IIRC, GetControlNormal ranges from 0 to 1 or -1 to 1 (depending on the Control. I think MoveLeftRight works like this). Basically, 0% pressed to 100% pressed. So 1f as the last parameter should work.
Btw, about this code:
if(Game.IsControlJustReleased(0, GTA.Control.Attack)){     UI.Notify(Game.GetControlNormal(0, GTA.Control.Attack).ToString());}

I think it returns 0 because it is only displaying the control value after releasing the control, which means it is 0% pressed by the time the subtitle is shown :lol:

Edited by stillhere
Cloud_Power

Unfortunately It seems not to work! Or, at least, it doesn't work the way I wished. The game does recognize that the button has been pressed/clicked but the action binded to that button doesn't play. So yeah, it works but not how I wished to! :p

Unfortunately It seems not to work! Or, at least, it doesn't work the way I wished. The game does recognize that the button has been pressed/clicked but the action binded to that button doesn't play. So yeah, it works but not how I wished to! :p

Sorry for the late reply. I have personally used this with the movement controls (left stick on gamepads) and it works, but I just tried with the attack/melee controls and they don't work. Sorry man! :*(

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 0 User Currently Viewing
    0 members, 0 Anonymous, 0 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.