001 Posted June 8, 2017 Share Posted June 8, 2017 --[[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
Hale Posted June 9, 2017 Share Posted June 9, 2017 You could use: ex = getTeamFromName("Staff") 1 Link to comment
001 Posted June 9, 2017 Author Share Posted June 9, 2017 @Hale and what about if i wanna do something add somebots with team and the another bots with another team means i added 5 bots i want them to be in criminal side and the rest in government side etc... Link to comment
pa3ck Posted June 9, 2017 Share Posted June 9, 2017 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. 1 Link to comment
001 Posted June 9, 2017 Author Share Posted June 9, 2017 thanks but @pa3ck i've team named Emergency Services when i spawn bot to it it create new team called Emergency how to solve the spaces problem ? Link to comment
pa3ck Posted June 9, 2017 Share Posted June 9, 2017 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) 1 Link to comment
001 Posted June 9, 2017 Author Share Posted June 9, 2017 11 minutes ago, pa3ck said: You're welcome the last thing please can i restrict that command spawnbot and rbot to one got ban access ? tell me the code please Link to comment
pa3ck Posted June 9, 2017 Share Posted June 9, 2017 (edited) 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 June 9, 2017 by pa3ck Link to comment
001 Posted June 9, 2017 Author Share Posted June 9, 2017 (edited) ok can u tell me how to make kill message when bot killes me example Bot Killed Sia (M4) or when i kill a bot ? Edited June 9, 2017 by Sia Link to comment
pa3ck Posted June 9, 2017 Share Posted June 9, 2017 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
001 Posted June 9, 2017 Author Share Posted June 9, 2017 put this in the bot acl right ? Link to comment
pa3ck Posted June 9, 2017 Share Posted June 9, 2017 Put what to the ACL? You don't have to put anything in the ACL Link to comment
001 Posted June 9, 2017 Author Share Posted June 9, 2017 ughh i mean Put it in bot.lua file sry/* Link to comment
pa3ck Posted June 9, 2017 Share Posted June 9, 2017 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now