Skip to content

Instantly share code, notes, and snippets.

@samhains
Created May 15, 2019 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samhains/0933b60b850842176e97a16da6b75101 to your computer and use it in GitHub Desktop.
Save samhains/0933b60b850842176e97a16da6b75101 to your computer and use it in GitHub Desktop.
using GTA;
using System;
using GTA.Native;
using System.Windows.Forms;
public class ScriptTutorial : Script
{
bool isBotEngaged = true;
public ScriptTutorial()
{
this.Tick += onTick;
this.KeyUp += onKeyUp;
this.KeyDown += onKeyDown;
this.Interval = 5000;
}
void onTick(object sender, EventArgs e)
{
if (isBotEngaged)
{
Random random = new Random();
int randomNumber = random.Next(0, 100);
Ped player = Game.Player.Character;
int areaSize = random.Next(20,60);
if (randomNumber > 20)
{
player.Task.WanderAround(player.Position + (areaSize-1)*player.ForwardVector, areaSize);
} else
{
int runSize = random.Next(10, 40);
player.Task.ClearAll();
player.Task.RunTo(player.ForwardVector * runSize + player.Position);
}
}
}
void onKeyDown(object sender, KeyEventArgs e)
{
}
void onKeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.H)
{
Ped player = Game.Player.Character;
player.Task.ClearAll();
isBotEngaged = !isBotEngaged;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment