Electro88 Posted February 6, 2016 Posted February 6, 2016 hello i request boss use rocket launcher but no work what wrong ? function boss ( ) nemesi = exports [ "slothBot" ]:spawnBot ( math.random(0,3000), math.random(0,2000), math.random(30), 90, 312, 0, 0, Nemesis, 0,"hunting", true ) outputChatBox ("Nemesis!!!",getRootElement(), 255, 0, 0, true ) myBlip = createBlipAttachedTo ( nemesi, 23 ) setElementData(nemesi, "Nemesis",true) triggerClientEvent ( "rocket", root ) giveWeapon(nemesi, 35, 9999, true ) setPedWeaponSlot (nemesi, 7) if nemesi then exports.extra_health:setElementExtraHealth ( nemesi, math.random(15000,25000 ) ) end end setTimer(boss,1000,1) 1
Electro88 Posted February 6, 2016 Author Posted February 6, 2016 addEvent ( "rocket", true ) addEventHandler ( "rocket", root, function NemesisShotRocktLancer(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if (getElementData(source, "Nemesis") == true) then local resultado = math.random(1,6) if resultado == 1 then local xw, yw, zw = getPedWeaponMuzzlePosition ( source ) createProjectile(localPlayer, 20, xw, yw, zw, 0.1, getLocalPlayer()) end end end addEventHandler ( "onClientPedWeaponFire", getRootElement(), NemesisShotRocktLancer) addEventHandler("onClientPedDamage",root, function(ata,wea,bod,los) if (ata and getElementType(ata) == "player") then if (getElementData(source,"nemesi") == true) then if (los >=5) then los = los-los+5 end end end) addEvent ( "rocket", true ) addEventHandler ( "rocket", root, function bossweapon (weapon, ammo) givePedWeapon(nemesi, 31, 5000, true) end addEventHandler( "givePedWeapon", rootElement, bosseapon ) function nemesisattack ( attacker, weapon, bodypart ) if (attacker) then if (getElementData (attacker, "nemesi") == true) then triggerServerEvent("KillByNemesis",source,attacker) end end end addEventHandler ( "onClientPlayerDamage",root, nemesisattack )
1LoL1 Posted February 6, 2016 Posted February 6, 2016 addEvent ( "rocket", true ) addEventHandler ( "rocket", root, function bossweapon (weapon, ammo) givePedWeapon(nemesi, 31, 5000, true) end addEventHandler( "givePedWeapon", getRootElement(), bossweapon) -- here you had bosseapon not bossweapon
Electro88 Posted February 6, 2016 Author Posted February 6, 2016 again not work boss only melee attack
1LoL1 Posted February 6, 2016 Posted February 6, 2016 again not work boss only melee attack Errors / Warnings?
Electro88 Posted February 6, 2016 Author Posted February 6, 2016 ERROR: server triggered clientside event rocket, but event is not added clientside ERROR: Loading script failed: BossZ/client.lua:17: '(' expected near 'bossweapon' Please Help me function NemesisShotRocketLancer(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if (getElementData(source, "Nemesis") == true) then local resultado = math.random(1,6) if resultado == 1 then local xw, yw, zw = getPedWeaponMuzzlePosition ( source ) createProjectile(localPlayer, 20, xw, yw, zw, 0.1, getLocalPlayer()) end end end addEventHandler ( "onClientPedWeaponFire", getRootElement(), NemesisShotRocktLancer) addEvent ( "rocket", true ) addEventHandler ( "rocket", root, function bossweapon (weapon, ammo) givePedWeapon(nemesi, 35, 5000, true) setPedWeaponSlot (nemesi, 7) end addEventHandler( "givePedWeapon", getRootElement(), bossweapon ) function nemesisattack ( attacker, weapon, bodypart ) if (attacker) then if (getElementData (attacker, "nemesi") == true) then triggerServerEvent("KillByNemesis",source,attacker) end end end addEventHandler ( "onClientPlayerDamage",root, nemesisattack )
1LoL1 Posted February 6, 2016 Posted February 6, 2016 ERROR: server triggered clientside event rocket, but event is not added clientsideERROR: Loading script failed: BossZ/client.lua:17: '(' expected near 'bossweapon' Please Help me function NemesisShotRocketLancer(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if (getElementData(source, "Nemesis") == true) then local resultado = math.random(1,6) if resultado == 1 then local xw, yw, zw = getPedWeaponMuzzlePosition ( source ) createProjectile(localPlayer, 20, xw, yw, zw, 0.1, getLocalPlayer()) end end end addEventHandler ( "onClientPedWeaponFire", getRootElement(), NemesisShotRocktLancer) addEvent ( "rocket", true ) addEventHandler ( "rocket", root, function bossweapon (weapon, ammo) givePedWeapon(nemesi, 35, 5000, true) setPedWeaponSlot (nemesi, 7) end addEventHandler( "givePedWeapon", getRootElement(), bossweapon ) function nemesisattack ( attacker, weapon, bodypart ) if (attacker) then if (getElementData (attacker, "nemesi") == true) then triggerServerEvent("KillByNemesis",source,attacker) end end end addEventHandler ( "onClientPlayerDamage",root, nemesisattack ) addEvent("rocket", true) addEventHandler("rocket", root, function bossweapon (weapon, ammo) givePedWeapon(nemesi, 35, 5000, true) setPedWeaponSlot (nemesi, 7) end) addEventHandler("givePedWeapon", getRootElement(), bossweapon)
Bonus Posted February 6, 2016 Posted February 6, 2016 You dont use a name when you directly create the function in another MTA-function. function ( weapon, ammo ) setTimer ( function ( ... ) ... end, ... ) addEventHandler ( ..., function ( ... ) ... end ) table.sort ( array, function ( ... ) ... end ) bindKey ( ..., function
Electro88 Posted February 7, 2016 Author Posted February 7, 2016 i fixed rocket now bot have rocket but no fire why not work ? function rocketfire () local target for i, thePlayer in ipairs ( getElementsByType("player") ) do -- iterate over all players target = getPedTarget ( thePlayer ) -- get the target of if ( target ) then setPedAnalogControlState (nemesi, 'aim_weapon', 1) toggleControl(nemesi, "aim_weapon", true) setPedAnalogControlState (nemesi, 'fire', 1) setPedControlState ( nemesi, "aim_weapon", true ) end end end addEventHandler ("setPedControl", getRootElement(), rocketfire )
Bonus Posted February 8, 2016 Posted February 8, 2016 That code makes no sense. You let nemesis attack everyone at once who gets targeted by a player. How can it attack everyone at once? Why attack a targeted player? Better create a colshape on nemesis with radius 10-20. Then get all the players with getElementsWithinColShape, put them in an array. Use math.random ( 1, #array ) to get a random number and let nemesis attack array[rndnumber] - a random player near nemesis.
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