Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

Functions

Noobz4Life edited this page Oct 15, 2018 · 10 revisions

Here is a list of bot functions you can use.

Player:Debug( Message, Color, IsAError )

This function will show messages in console if the CVar, gmbots_debug_mode, is over 0.

  • Message = Self-explanatory.
  • Color = The color of the message, you shouldn't have to use this.
  • IsAError = Used for Player:Error, which isn't gonna be shown on this page, since you shouldn't have to use it.

Example

ply:Debug("This is a example.",Color(0,255,0),false)

Output

This would be shown in Green, just use your imagination.

GMBots Debug, BOT Example: This is a example.

Player:Pathfind( CMD, Position, Walk )

This function will pathfind for you!

  • CMD = User CMD, which is the second parameter you get from the 'GMBotsStart' hook.
  • Position = Vector to pathfind too.
  • Walk = Walk when you're close to the Position.

Example

if ply.Enemy then
    ply:Pathfind(cmd,ply.Enemy:GetPos(),true)
end

Player:BotFollow( CMD, Target )

This function will follow a target, while also keeping distance.

This function also runs Player:Pathfind when the Target is not visible.

  • CMD = User CMD, which is the second parameter you get from the 'GMBotsStart' hook.
  • Target = The target to follow, which should be a player.

Example

if ply.Friend then
    ply:BotFollow(cmd,ply.Friend)
end

Player:BotWander(CMD)

This function will make the Bot wander to spots in the nav mesh.

  • CMD = User CMD, which is the second parameter you get from the 'GMBotsStart' hook.

Example

if not ply.Enemy then
    ply:BotWander(cmd)
end

Player:BotSay( Message, TeamOnly, Cooldown, Time, TimeMultiplier )

This function makes the bot say something, but also has more parameters than Player:Say.

  • Message = Self-explanatory.
  • TeamOnly = Self-explanatory. Defaults to false.
  • Cooldown = This function has a cooldown, you can use this to modify how long the cooldown is. Defaults to 2.
  • Time = Should the bot take time to "type"? Defaults to false.
  • TimeMultiplier = Multiply how long it would take to "type" by this amount. Defaults to 1.

The Time parameter's math is "(string length)/7 * (TimeMultiplier)

Example

ply:BotSay("This is a example.",false,2,true,1)

Output

This would take 2.57142857 seconds for the bot to "type".

BOT Example: This is a example.

Player:LookForPlayers( UseTeams )

This function will look for a player, if it find's one, it will return whoever it found.

  • UseTeams = Should we only find people on other teams? Defaults to false.

Example

ply.Enemy = ply:LookForPlayers(false)
if ply.Enemy then
    ply:Debug("I found a enemy! "..ply.Enemy:Name())
end

Output

Once the player finds a enemy...

GMBots Debug, BOT Example: I found a enemy! Noobz4Life

Player:BotVisible( Target )

This returns if the Target is visible to the bot or not. This isn't the same as Entity:Visible, as this function finds if you can see the target infront of you.

  • Target = Self-explanatory.

Example

ply.Enemy = ply.Enemy or ply:LookForPlayers(false)
if ply.Enemy and ply:BotVisible(ply.Enemy) then
    ply:Debug("Enemy is visible!")
end

Output

Once the player finds a enemy and the enemy is visible...

GMBots Debug, BOT Example: Enemy is visible