Hello everybody, I'm new in LUA scripting, I followed tutorials, it helped me very well, thanks for that, but I have a problem
I've made a boss bot (Alex Mercer) for my server, and I want it to use no weapons, and to instant kill players in sight when this boss hits them, here's the script
outputChatBox ("Alex Mercer is attacking Los Santos ! Stop him before he transforms the whole city into a giant hive !",getRootElement(), 255, 0, 0, true )
function boss ( )
Alex = exports [ "slothBot" ]:spawnBot ( 1479.33984375, -1675.4399414063, 14.0406875, 90, 308, 0, 0, Alex, 0, "hunting", true )
exports.extra_health:setElementExtraHealth ( Alex, 75000 )
myBlip = (createBlipAttachedTo ( Alex, 41 ))
setBotWeapon (Alex, 0)
setElementData ( Alex, "alex", true )
end
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), boss )
function alexattack ( attacker, weapon, bodypart )
if (attacker) then
if getElementType ( attacker ) == "ped" then
if (getElementData (attacker, "alex") == true) then
local playerHealth = getElementHealth ( getLocalPlayer() )
if playerHealth > 15 then
setElementHealth ( source, playerHealth - 500 )
end
end
end
end
end
addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), alexattack )
function money (theKiller)
if (source == Alex) then
givePlayerMoney(theKiller,math.random(5000000,10000000))
outputChatBox ( getPlayerName ( theKiller ) .. " stopped Alex Mercer ! But the virus will never die ...",getRootElement(), 10, 255 , 10, true )
end
end
addEvent("onBotWasted", true)
addEventHandler("onBotWasted", getRootElement(), money)
The boss is working, he have 75.000 HP, he go attack players who shot him, and we he got killed, the player who killed him get rewarded, the problem is that the boss isn't killing the players he attacks with 1 hit (it does only normal punch damage)
If somebody can help me to fix this, i've tried everything I could do, I'm kinda desperate to see that my script isn't working properly.
Best regards
Kahlua