ok! This is what i have:
botPed = null
function createBot()
if (botPed == null ) then
botPed = createPed( 312, 1989, -2190, 14, 180, 0, 180 )
outputConsole("Bot is in game!")
else
outputConsole("Bot already exists.")
end
end
function deleteBot()
if (botPed ~= null) then
destroyElement( botPed )
outputConsole("Bot has been deleted.")
botPed = null
else
outputConsole("No bot to remove.")
end
end
function smartBotON()
setPedAnimation( botPed, "ped", "run_player" )
-- detection event
addEventHandler( "onClientRender", getRootElement(), detecting )
-- detecting event
outputConsole( "Bot is now smart!" )
end
function standBot()
setPedAnimation( botPed )
outputConsole( "Bot is standing still." )
removeEventHandler( "onClientRender", getRootElement(), detecting )
end
function detecting( element, dim )
-- detection hit
-- if hit must do "botHit()"
end
function botTurn()
if (botPed ~= null) then
outputDebugString("Bot turned in random direction.")
outputConsole("Bot turned in random direction.")
setPedRotation(botPed, getPedRotation(botPed) + math.random(90, 270))
end
end
function botHit()
outputDebugString("Bot detected obsticale infront of it.")
outputConsole("Bot detected obsticale infront of it.")
botTurn()
end
addCommandHandler( "smart", smartBotON )
addCommandHandler( "stand", standBot )
addCommandHandler( "botON", createBot )
addCommandHandler( "botOFF", deleteBot )
I really hope no one will copy this code!
Is possible to delete topic?