Jump to content

[HELP] Bot


1LoL1

Recommended Posts

Hello, i created this code but not work :( can anyone help me?

function cash () 
local bot = getElementType("bot") 
local cash = (getElementData(bot, "cash") or 0) 
outputChatBox("BOT have "..cash.."$ !", getRootElement(), 255, 0, 0, true) 
end 
addCommandHandler("xxx", cash) 
  
  
function cash2 () 
local bot2 = getElementType("bot") 
setElementData(bot2, "cash", (getElementData(bot2, "cash") or 0) + 5000) 
outputChatBox("BOT +5000$ !", getRootElement(), 255, 0, 0, true) 
end 
addCommandHandler("xx", cash2) 

Link to comment
What's wrong with it

not work.

11: Bad argument @ "setElementData" [Expected element at argument 1, got boolean]

11: Bad argument @ "getElementData" [Expected element at argument 1, got boolean]

10: Bad argument @ "getElementType" [Expected element at argument 1, got string "bot"]

Link to comment
But i don't mean bot system. and now i fixed what i want thx for help :D

Anytime

And why this not work? :( please can anyone help me?

function xxx () 
local bot = createElement("bot") 
local cash = (getElementData(bot, "cash") or 0) 
outputChatBox("BOT have "..cash.."$ !", getRootElement(), 255, 0, 0, true) 
end 
addCommandHandler("xxx", xxx) 
  
function xx () 
local bot2 = createElement("bot") 
setElementData(bot2, "cash", (getElementData(bot2, "cash") or 0) + 5000) 
outputChatBox("BOT +5000$ !", getRootElement(), 255, 0, 0, true) 
end 
addCommandHandler("xx", xx) 

Link to comment

Well, bot its not an element, but you can create a ped like this https://wiki.multitheftauto.com/wiki/CreatePed

function cash () 
local bot = createPed ( 0, 0, 0, 0)--Create a Cj in the 0,0,0 coord 
local cash = getElementData(bot, "cash") --This return false, because the bot doesnt have "cash" 
outputChatBox("BOT have "..cash.."$ !", getRootElement(), 255, 0, 0, true) 
end 
addCommandHandler("xxx", cash) 
  
  
function cash2 () 
--You cant operate booleans whit numbers so 
cash = getElementData(bot,"cash") 
if (cash == false) then --You cant operate booleans whit numbers so 
setElementData(bot,"cash", 0 ) 
setElementData(bot, "cash", (getElementData(bot, "cash") + 5000) --Now you can use the comand xxx 
outputChatBox("BOT +5000$ !", getRootElement(), 255, 0, 0, true) 
end 
end 
addCommandHandler("xx", cash2) 

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