Jump to content

help bots script


001

Recommended Posts

--[[function boss (player,comando,weaponid,skinid)
local x,y,z = getElementPosition(player)
 slothbot1 = exports [ "slothbot" ]:spawnBot ( x,y,z , 90, tonumber(skinid), 0, 0, ex, tonumber(weaponid), "hunting", true )
 end
addCommandHandler("spawnbot",boss)]]

ex = createTeam("STAFF",255,0,0)
function boss (player,comando,weaponid,skinid)
local x,y,z = getElementPosition(player)
 slothbot1 = exports [ "slothbot" ]:spawnBot ( x,y,z , 90, tonumber(weaponid), 0, 0, ex, tonumber(skinid), "hunting", true )
 end
addCommandHandler("spawnbot",boss)


function pauseBot (player,command,state)
local allBots = getElementsByType ( "ped" )
for index, boss in ipairs(allBots) do
  if ( exports [ "slothbot" ]: getBotAttackEnabled ( boss ) == false ) then
   exports [ "slothbot" ]: setBotAttackEnabled ( boss, true )
  elseif ( exports [ "slothbot" ]: getBotAttackEnabled ( boss ) == true ) then
   exports [ "slothbot" ]: setBotAttackEnabled ( boss, false )
end
end
end
addCommandHandler("pausebot",pauseBot)


function restartBot (ped,commando)
local allBots = getElementsByType ( "ped" )
for index, boss in pairs(allBots) do
    killPed(boss)
end
end
addCommandHandler("rbot",restartBot)


function rewardOnWasted ( ammo, killer, killerweapon, bodypart )

    if ( killer ) and ( killer ~= source ) then
        givePlayerMoney ( killer, 150 )
    end
end
addEventHandler ( "onPedWasted", getRootElement(), rewardOnWasted )

function info(player)
outputChatBox("Syntaxis : /spawnbot SkinID - WeaponID",player,255,0,0)
outputChatBox("Example : /spawnbot 24 0",player,255,0,0)
end
addCommandHandler("botinfo",info)

this is the script and my question about this line.

ex = createTeam("STAFF",255,0,0)

am asking what to do if i already have team ? and i want make the bots dont harm me if i went to this team and the another question how i can make it with two teams i mean if i put my self in certain teams i chose them i wont die

anyone help me please
 

Link to comment
function boss (player,comando,weaponid,skinid, teamName)
  	local team = getTeamFromName(teamName)
  	if not team then
    		team = createTeam(teamName)
   	end
	local x,y,z = getElementPosition(player)
 	slothbot1 = exports [ "slothbot" ]:spawnBot ( x,y,z , 90, tonumber(weaponid), 0, 0, team, tonumber(skinid), "hunting", true )
end
addCommandHandler("spawnbot",boss)

Try this, I added the last argument 'teamName'. If you add a teamName eg. 

You type: /spawnbot 22, 10, Criminals -> it will look for the team Criminals and if it doesn't exist, it will create that team and spawn the bot assigned to it.

  • Like 1
Link to comment

Yea, I didn't think about that.. try this:

function boss (player,comando,weaponid,skinid, ...)
  	local teamName = table.concat({...}," ")
  	local team = getTeamFromName(teamName)
  	if not team then
    		team = createTeam(teamName)
   	end
	local x,y,z = getElementPosition(player)
 	slothbot1 = exports [ "slothbot" ]:spawnBot ( x,y,z , 90, tonumber(weaponid), 0, 0, team, tonumber(skinid), "hunting", true )
end
addCommandHandler("spawnbot",boss)

 

  • Like 1
Link to comment
function boss (player,comando,weaponid,skinid, ...)
  	if not hasObjectPermissionTo (player, "command.ban") then
    	-- you might want to add your message here
		return
   	end
  	local teamName = table.concat({...}," ")
  	local team = getTeamFromName(teamName)
  	if not team then
    		team = createTeam(teamName)
   	end
	local x,y,z = getElementPosition(player)
 	slothbot1 = exports [ "slothbot" ]:spawnBot ( x,y,z , 90, tonumber(weaponid), 0, 0, team, tonumber(skinid), "hunting", true )
end
addCommandHandler("spawnbot",boss)

That should work 

Edited by pa3ck
Link to comment

It says slothbot is not running.. start the resource, it cannot be renamed, make sure the name of the resource is "slothbot". You can use the function isPedBot to check if the killer is a bot @ event onPlayerWasted.

addEventHandler ( "onPlayerWasted", getRootElement(), function(ammo, attacker)
  if attacker and getElementType(attacker) == "ped" and exports [ "slothbot" ]:isPedbot(attacker) then
      local name = getPlayerName(source)
      outputChatBox("Player " .. name .. " was killed by a bot")
  end  
end)

 

Link to comment

If you mean put it inside the "slothbot" resource, then no, you don't have to put it in there, since it's using exported functions.You can put it into any resource as long as you are using the correct resource name and the resource is running. I sent you the code to do an outputChatBox when the player dies and the 'attacker' is a bot, you can do the same logic to do an outputChatBox when you kill a bot. 

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...