Jump to content

SlothBot


.:HyPeX:.

Recommended Posts

Hello, i'm working out slothbot, should this work? i've been doing it according to the wiki..https://wiki.multitheftauto.com/wiki/Slothman/Slothbot

  
ZombieCap[thePlayer] = {} 
function ZombieToEnemy(Player) 
local ZombieTeam = getPlayersInTeam( ZombieArena ) 
local thePlayer = getRandomPlayer( ZombieTeam ) 
local IsEnemy = getPlayerTeam( Player ) 
if not ZombieCap[Player] > 20 then 
    if IsEnemy == ZombieArena then 
        ZombieCap[thePlayer] = tonumber(ZombieCap[Player])+1 
        local X,Y,Z = getElementPosition( Player ) 
        local Rot = getElementRotation( Player ) 
        spawnBot( tonumber(X)+10, tonumber(Y)+10, tonumber(Z), tonumber(Rot), 10, 0, 50, nil, 0, "chasing", Player) 
end 
end 
end 

EDIT//:

  
ZombieCap[thePlayer] = {} 
function ZombieToEnemy(Player) 
local ZombieTeam = getPlayersInTeam( ZombieArena ) 
local RandomPlayer = getRandomPlayer( ZombieTeam ) 
local thePlayer = getPlayerName( RandomPlayer ) 
local IsEnemy = getPlayerTeam( Player ) 
    if not getAccountData( thePlayer, ZombiesKilled ) then 
    outputChatBox("Welcome to the Zombie Arena, each zombie killed will give you $500", source) 
    outputChatBox("If you recived this message it means its your first time in the Zombie Arena", source) 
    outputChatBox("This also means there's a Zombie spawning near you. You can spend the money in the lobby", source) 
    setAccountData( thePlayer, ZombiesKilled, 0) 
    else 
    outputChatBox("a zombie spawned near you!", source) 
    end 
if not ZombieCap[Player] > 20 then 
    if IsEnemy == ZombieArena then 
        ZombieCap[thePlayer] = tonumber(ZombieCap[Player])+1 
        local X,Y,Z = getElementPosition( Player ) 
        local Rot = getElementRotation( Player ) 
        spawnBot( tonumber(X)+10, tonumber(Y)+10, tonumber(Z), tonumber(Rot), 10, 0, 50, nil, 0, "chasing", Player) 
end 
end 
end 
  
function ZombieKilled(attacker, weapon, bodypart) 
local thePlayer = getPlayerName( attacker ) 
ZombieCap[thePlayer] =  tonumber(ZombieCap[Player])-1 
local account = getPlayerAccount( thePlayer ) 
local money = getPlayerMoney( thePlayer ) 
local KilledZombies = getAccountData( account, ZombiesKilled) 
setPlayerMoney( tonumber(money)+500 ) 
setAccountData( account, ZombiesKilled, tonumber(KilledZombies)+1) 
end 
addEventHandler("onBotWasted", getRootElement(), ZombieKilled) 

Link to comment

error line 1: attempt to index global variable..

  
ZombieCap[thePlayer] = {} 
function ZombieToEnemy(Player) 
local ZombieTeam = getPlayersInTeam( ZombieArena ) 
local RandomPlayer = getRandomPlayer( ZombieTeam ) 
local thePlayer = getPlayerName( RandomPlayer ) 
local IsEnemy = getPlayerTeam( Player ) 
    if not getAccountData( thePlayer, ZombiesKilled ) then 
    outputChatBox("Welcome to the Zombie Arena, each zombie killed will give you $500", source) 
    outputChatBox("If you recived this message it means its your first time in the Zombie Arena", source) 
    outputChatBox("This also means there's a Zombie spawning near you. You can spend the money in the lobby", source) 
    setAccountData( thePlayer, ZombiesKilled, 0) 
    else 
    outputChatBox("a zombie spawned near you, warning!", source) 
    end 
if not ZombieCap[Player] > 20 then 
    if IsEnemy == ZombieArena then 
        ZombieCap[thePlayer] = tonumber(ZombieCap[Player])+1 
        local X,Y,Z = getElementPosition( Player ) 
        local Rot = getElementRotation( Player ) 
        spawnBot( tonumber(X)+10, tonumber(Y)+10, tonumber(Z), tonumber(Rot), 10, 0, 0, nil, 0, "chasing", thePlayer) 
    else 
    outputChatBox("".. thePlayer .." is not into ZombieArena team, Zombie spawning failed!") 
    end 
else 
outputChatBox("" .. thePlayer .." has reached the cap of Zombies allowed!") 
end 
end 
setTimer( ZombieToEnemy, 1000, 0) 
  
function ZombieKilled(attacker, weapon, bodypart) 
local thePlayer = getPlayerName( attacker ) 
ZombieCap[thePlayer] =  tonumber(ZombieCap[Player])-1 
local account = getPlayerAccount( thePlayer ) 
local money = getPlayerMoney( thePlayer ) 
local KilledZombies = getAccountData( account, ZombiesKilled) 
setPlayerMoney( tonumber(money)+500 ) 
setAccountData( account, ZombiesKilled, tonumber(KilledZombies)+1) 
end 
outputChatBox("".. thePlayer .." has killed a zombie and $500 were added to his account!") 
addEventHandler("onBotWasted", getRootElement(), ZombieKilled) 

Link to comment
ZombieCap = {} 
function ZombieToEnemy(Player) 
if ( not ZombieCap[Player] ) then 
    ZombieCap[Player] = 0 
end 
local ZombieTeam = getPlayersInTeam( ZombieArena ) 
local RandomPlayer = getRandomPlayer( ZombieTeam ) 
local thePlayer = getPlayerName( RandomPlayer ) 
local IsEnemy = getPlayerTeam( Player ) 
    if not getAccountData( thePlayer, ZombiesKilled ) then 
    outputChatBox("Welcome to the Zombie Arena, each zombie killed will give you $500", source) 
    outputChatBox("If you recived this message it means its your first time in the Zombie Arena", source) 
    outputChatBox("This also means there's a Zombie spawning near you. You can spend the money in the lobby", source) 
    setAccountData( thePlayer, ZombiesKilled, 0) 
    else 
    outputChatBox("a zombie spawned near you, warning!", source) 
    end 
if not ZombieCap[Player] > 20 then 
    if IsEnemy == ZombieArena then 
        ZombieCap[Player] = tonumber(ZombieCap[Player])+1 
        local X,Y,Z = getElementPosition( Player ) 
        local Rot = getElementRotation( Player ) 
        spawnBot( tonumber(X)+10, tonumber(Y)+10, tonumber(Z), tonumber(Rot), 10, 0, 0, nil, 0, "chasing", thePlayer) 
    else 
    outputChatBox("".. thePlayer .." is not into ZombieArena team, Zombie spawning failed!") 
    end 
else 
outputChatBox("" .. thePlayer .." has reached the cap of Zombies allowed!") 
end 
end 
setTimer( ZombieToEnemy, 1000, 0) 
  
function ZombieKilled(attacker, weapon, bodypart) 
local thePlayer = getPlayerName( attacker ) 
if ( not ZombieCap[attacker] ) then 
    ZombieCap[attacker] = 0 
end 
ZombieCap[attacker] =  tonumber(ZombieCap[attacker])-1 
local account = getPlayerAccount( thePlayer ) 
local money = getPlayerMoney( thePlayer ) 
local KilledZombies = getAccountData( account, ZombiesKilled) 
setPlayerMoney( tonumber(money)+500 ) 
setAccountData( account, ZombiesKilled, tonumber(KilledZombies)+1) 
outputChatBox("".. thePlayer .." has killed a zombie and $500 were added to his account!") 
end 
addEventHandler("onBotWasted", getRootElement(), ZombieKilled)  

Try that.

Link to comment
ZombieCap = {} 
function ZombieToEnemy(Player) 
local ZombieTeam = getPlayersInTeam( ZombieArena ) 
local RandomPlayer = getRandomPlayer( ZombieTeam ) 
if ( not ZombieCap[RandomPlayer] ) then 
    ZombieCap[RandomPlayer] = 0 
end 
local thePlayer = getPlayerName( RandomPlayer ) 
local IsEnemy = getPlayerTeam( RandomPlayer ) 
    if not getAccountData( thePlayer, ZombiesKilled ) then 
    outputChatBox("Welcome to the Zombie Arena, each zombie killed will give you $500", source) 
    outputChatBox("If you recived this message it means its your first time in the Zombie Arena", source) 
    outputChatBox("This also means there's a Zombie spawning near you. You can spend the money in the lobby", source) 
    setAccountData( thePlayer, ZombiesKilled, 0) 
    else 
    outputChatBox("a zombie spawned near you, warning!", source) 
    end 
if not ZombieCap[RandomPlayer] > 20 then 
    if IsEnemy == ZombieArena then 
        ZombieCap[RandomPlayer] = tonumber(ZombieCap[RandomPlayer])+1 
        local X,Y,Z = getElementPosition( RandomPlayer ) 
        local Rot = getElementRotation( RandomPlayer ) 
        spawnBot( tonumber(X)+10, tonumber(Y)+10, tonumber(Z), tonumber(Rot), 10, 0, 0, nil, 0, "chasing", thePlayer) 
    else 
    outputChatBox("".. thePlayer .." is not into ZombieArena team, Zombie spawning failed!") 
    end 
else 
outputChatBox("" .. thePlayer .." has reached the cap of Zombies allowed!") 
end 
end 
setTimer( ZombieToEnemy, 1000, 0) 
  
function ZombieKilled(attacker, weapon, bodypart) 
local thePlayer = getPlayerName( attacker ) 
if ( not ZombieCap[attacker] ) then 
    ZombieCap[attacker] = 0 
end 
ZombieCap[attacker] =  tonumber(ZombieCap[attacker])-1 
local account = getPlayerAccount( thePlayer ) 
local money = getPlayerMoney( thePlayer ) 
local KilledZombies = getAccountData( account, ZombiesKilled) 
setPlayerMoney( tonumber(money)+500 ) 
setAccountData( account, ZombiesKilled, tonumber(KilledZombies)+1) 
outputChatBox("".. thePlayer .." has killed a zombie and $500 were added to his account!") 
end 
addEventHandler("onBotWasted", getRootElement(), ZombieKilled) 

Link to comment

i got alot of errors from bad argument on lines 3, 10, 14 and 18.(getPlayersInTeam, getAccountdata, setAccountdata, compare a boolean). the one you did also spams the firt time zombie spawned message.

i was also working out on my side, but i'm getting the debug message that the player isnt in the ZombieArena team.(i created the team via Admin panel and got me in). i havent still checked the main function.

  
ZombieCap = {} 
  
function getaPlayer() 
local RandomPlayer = getRandomPlayer() 
local RandomPlayerTeam = getPlayerTeam(RandomPlayer) 
if RandomPlayerTeam == "ZombieArena" then 
g_Player = RandomPlayer 
    if not ZombieCap[g_Player] then 
    ZombieCap[g_Player] = 0 
    setTimer ( ZombieToEnemy, 50, 1 ) 
    else 
    outputChatBox("ZombieCap is already defined!") 
    setTimer ( ZombieToEnemy, 50, 1 ) 
    end 
else 
outputChatBox("RandomPlayerTeam is not == ZombieArena") 
end 
end 
setTimer(getaPlayer, 1000, 0) 
  
function ZombieToEnemy(Player) 
local isEnemy = getPlayerTeam( g_Player ) 
    if not getAccountData( thePlayer, ZombiesKilled ) then 
    outputChatBox("Welcome to the Zombie Arena, each zombie killed will give you $500", source) 
    outputChatBox("If you recived this message it means its your first time in the Zombie Arena", source) 
    outputChatBox("This also means there's a Zombie spawning near you. You can spend the money in the lobby", source) 
    setAccountData( thePlayer, ZombiesKilled, 0) 
    else 
    outputChatBox("a zombie spawned near you, warning!", source) 
    end 
if not ZombieCap[g_Player] > 20 then 
    if IsEnemy == ZombieArena then 
        ZombieCap[g_Player] = tonumber(ZombieCap[g_Player])+1 
        local X,Y,Z = getElementPosition( g_Player ) 
        local Rot = getElementRotation( g_Player ) 
        spawnBot( tonumber(X)+10, tonumber(Y)+10, tonumber(Z), tonumber(Rot), 10, 0, 50, nil, 0, "chasing", thePlayer) 
    else 
    outputChatBox("".. g_Player .." is not into ZombieArena team, Zombie spawning failed!") 
    end 
else 
outputChatBox("" .. g_Player .." has reached the cap of Zombies allowed!") 
end 
end 
  
function ZombieKilled(attacker, weapon, bodypart) 
local thePlayer = getPlayerName( attacker ) 
if ( not ZombieCap[attacker] ) then 
    ZombieCap[attacker] = 0 
end 
ZombieCap[attacker] =  tonumber(ZombieCap[attacker])-1 
local account = getPlayerAccount( thePlayer ) 
local money = getPlayerMoney( thePlayer ) 
local KilledZombies = getAccountData( account, ZombiesKilled) 
setPlayerMoney( tonumber(money)+500 ) 
setAccountData( account, ZombiesKilled, tonumber(KilledZombies)+1) 
outputChatBox("".. thePlayer .." has killed a zombie and $500 were added to his account!") 
end 
addEventHandler("onBotWasted", getRootElement(), ZombieKilled) 

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...