Kahlua Posted May 20, 2014 Share Posted May 20, 2014 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 Link to comment
.:HyPeX:. Posted May 20, 2014 Share Posted May 20, 2014 Try changing this if playerHealth > 15 then setElementHealth ( source, playerHealth - 500 ) end into this killPed(source) PD: You must also move this event server-side. There's no problem in doing that. Link to comment
Kahlua Posted May 20, 2014 Author Share Posted May 20, 2014 I modified like you said, but it's not working, even server-sided 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() ) killPed(source) 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) I also tried to put this instead of what you say, nothing changes killPed( sourcePlayer, attacker, 0) Link to comment
manawydan Posted May 20, 2014 Share Posted May 20, 2014 try 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 killPed(source,attacker) end end end end addEventHandler ( "onPlayerDamage",root, 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) Link to comment
manawydan Posted May 20, 2014 Share Posted May 20, 2014 ok try again server 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 )) setElementData ( Alex, "alex", true ) setBotWeapon (Alex, 0) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), boss ) 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) addEvent("KillByAlex",true) addEventHandler("KillByAlex",root, function(atacker) killPed(source,atacker) end) Client function alexattack ( attacker, weapon, bodypart ) if (attacker) then if (getElementData (attacker, "alex") == true) then triggerServerEvent("KillByAlex",source,attacker) end end end addEventHandler ( "onClientPlayerDamage",root, alexattack ) Link to comment
Kahlua Posted May 21, 2014 Author Share Posted May 21, 2014 It's finally working ! Thank you very much for the help 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