xboxxxxd

ZTown, Nemesis Event ('zombies').

Recommended Posts

[Alright, first of all: I just joined the Forums, so if i do anything wrong, just tell me.]

Ok, so i got a problem, it's about an event i want to trigger on a certain amount of zombie's, or on a certain timer, that's all fine and such..

But, i want to merge some event's into a resource called "zombies", like the 'onZombieWasted' event, but then for a seperated Event,

What i mean with that is i want to have a new 'onNemesisWasted' event working together with the 'onZombieWasted',

but they need to sync up with the (if possible exported) createZombie function from the "zombies" resource.

And i am aiming to make it to a elementData trigger, that i locally created as for example: local Nemesis = export.zombies:createZombie(etc,etc..),

So when i check for that element's data on the name 'Nemesis' by existence (as in: if ( isElement ( Nemesis ) ) then) and in combination on the 'onNemesisWasted'-

event to check if that export of createZombie (ped works aswel) is dead or not, after all of that if the createZombie (ped) is actually dead,

then i wan't it to trigger the reward system together with the other piece's of code.

 

To clear out this idea and problem, i also recorded the ZTown Nemesis Event Script and also post the 2 main scripts that hold me from finishing the Nemesis:

The Video of me, quickly explaining what, how, and showing the problem:

"youtube"

And the 2 script's, there both Server-Side,

The Nemesis.lua is changed to test it's functionality and quick testing, but feel free to change the code and re-post it here to function with 'onNemesisWasted' additions!..

the first setTimer(function() is there to prevent complication problems from other zombie resource's and scripts, just delaying it for better run's.

Also, the second setTimer(function() is just to delay it's Blip creation and Attaching to prevent the Blip not being attached to the createZombie named nemesis.

Nemesis.lua (start/event):

function nemesisON()
setTimer(function()
    if ( not isElement ( Nemesis ) ) then
      local nemesis = exports.zombies:createZombie ( 2343, 57, 26.5, 90, 38, 0, 0, nemesis, 0, "hunting", true )
            setPedHeadless(nemesis, true)
            exports.extrahealth:setElementExtraHealth ( nemesis, 150 )
      setElementData ( nemesis, "nemesis", true  )
setTimer(function()
        myBlip = createBlipAttachedTo ( nemesis, 23 )
        outputChatBox ('#FFFFFF[#7CFC00ZTown#FFFFFF]: #00BFFF A #00FFFFNemesis #00BFFFHas been spawned inside ZTown! #FFFFFF(#7CFC00Nemesis Boss Event#FFFFFF)', root, 255, 255, 255, true)
        triggerClientEvent(root, "event", root, "start")
end,2500,1)
end
end,2500,1)
end
addEventHandler ( "onResourceStart", getRootElement(), nemesisON)

monemesi.lua (check/reward):

addEvent ( "onNemesisWasted", true )
addEventHandler ( "onNemesisWasted", root,
    function ( killer )
    if ( isElement ( Nemesis ) ) then
givePlayerMoney(killer,math.random(5000,25000))
killer = getPlayerName(killer)
destroyElement ( myBlip )
        outputChatBox ('#FFFFFF[#7CFC00ZTown#FFFFFF]: #00BFFF The #00FFFFNemesis #00BFFFHas been killed! #FFFFFF(#7CFC00Nemesis-Boss Event#FFFFFF)', root, 255, 255, 255, true)
        triggerClientEvent(root, "event", root, "stop")
end
end
)

I hope sombady could find a way to make this function correctly, because i have try'ed loads of ways, and the way to use slothbot together with zombies resource... nahh, won't work, they wil keep fighting together like d*cks.

 

EDIT: if ( isElement ( Nemesis ) ) = nemesis, i already changed that, but right after i posted it, derp..

 

Gr.xboxxxxd

Edited by xboxxxxd

Share this post


Link to post

Ok, so if I understand correctly, there's already an event called "onZombieWasted" which you want to trigger an event called onNemesisWasted, correct?

If so, you can do this:

addEvent("onZombieWasted", true)
addEventHandler("onZombieWasted", root, functon(whatever, args, you, have)
	if whatever = "isthis" and args = "notargs" then
		triggerEvent("onNemesisWasted", root, pass, your, arguments) -- if you want from server to server or client to client, you can also
									    -- trigger this to server -> client or client -> server by using triggerClient/ServerEvent
	end
end)

addEvent("onNemesisWasted", true)
addEventHandler("onNemesisWasted", root, function(pass, your, arguments)
	if pass then
		outputChatBox("onNemesisWasted called")
	end
end)

 

 

  • Like 1

Share this post


Link to post

Hey pa3ck.

Thanks for your answer,

the main problem was i didnt had arguments set up in the function behind the onZombie/NemesisWasted Event,

Thats why i didnot succeed in making this work..

But now i had the problem with sync'ing up the agruments of onZombieWasted, ahh well.. Just Cloned it and added a 1 after the functions name.

And about the Server <> Server and Client <> Client Event Triggers, i already knew that, but i used it the wrong way by using it as a shared library instead of a collab of code,

So after all of that i managed to merge both .lua's that i posted the code of, and put it inside the main resource (zombies) server side event inside another Event..

Then it finally worked.. but i noticed i didnt get money, well... i am not really sure why, but givePlayerMoney does not want to work on both serverside or shared,

anyways, i added another event for that, a reward kind of event, put the remaining code of the nemesis reward back to a new script as shared,

now it worked.. weird..

After some load of Editing, your code doesnt even look like what i made, but it works.. Thanks for it!.

 

I am also testing and scripting these kinds of things on my self hosted server, if you ever wonder what else i do..

just PM me and i'l hook you up with info.

 

Gr.xboxxxxd

 

I am new, Uhmm... how to close a Topic or?..

Edited by xboxxxxd

Share this post


Link to post

Hmm let's not close it yet..

I now got another tricky problem:

ive noticed that its madness to change alot of value's and settings with the zombies resource, with createZombie,

so now i want to use the 'slothbot' resource, and do basicly the same as with createZombie from zombies resource,

but..

as i am intending to add more boss event's, i also want to merge all the boss event's into 1 EventHandler,

for Slothbot it's "onBotWasted", the same type of EventHandler as onZombieWasted,

also, the Creation of these boss event's are already done.

(If you wonder: 'spawnBot' is the creation event of slothbot).

i'l show what i am stuck with:

zombie_server.lua (server-side, from zombies resource):

addEvent("onBotWasted", true)
addEventHandler("onBotWasted", root, function()
if  then  -- <- Between if & then, i am lost on how to make it check if the element (burner) Wasted, as in: onPedWasted & burner alive is false.
	triggerClientEvent(root, "bosseventreward", root, "burner")
end -- <- And this seems to work as it is, don't ask me why.
if  then -- <- Same here as burner.
	triggerClientEvent(root, "bosseventreward", root, "nemesis")
end
end
end)

for the client-side .lua (ps: anything wrong in this script i can solve myself, but i can't se it's effect if the code above won't work correctly, also posted here to make it easyer for a fix/solution):

function bosseventrewards(select)
	if select == "burner" then
		outputChatBox ('#AFAFAF[#BD0202ZTown#AFAFAF]: #EF0C0CThe #F24B4BBurner #EF0C0CHas been killed! #AFAFAF(#BD0202Burner Miniboss Event#AFAFAF)', root, 255, 255, 255, true)
givePlayerMoney ( attacker, 17500 ) 
destroyElement ( myBlip1 )
triggerClientEvent(root, "event", root, "stop")
setTimer(function()
		outputChatBox ('#AFAFAF[#BD0202ZTown#AFAFAF]:#F24B4B ' .. getPlayerName(attacker) .. ' #EF0C0CEarned 17,500$ by killing a #F24B4BBurner#EF0C0C! #AFAFAF(#BD0202Burner Miniboss Event#AFAFAF)', root, 255, 255, 255, true)
end,2500,1)
	elseif select == "nemesis" then
		outputChatBox ('#AFAFAF[#BD0202ZTown#AFAFAF]: #EF0C0CThe #F24B4BNemesis #EF0C0CHas been killed! #AFAFAF(#BD0202Nemesis Boss Event#AFAFAF)', root, 255, 255, 255, true)
givePlayerMoney ( attacker, 25000 ) 
destroyElement ( myBlip )
triggerClientEvent(root, "event", root, "stop")
setTimer(function()
		outputChatBox ('#AFAFAF[#BD0202ZTown#AFAFAF]:#F24B4B ' .. getPlayerName(attacker) .. ' #EF0C0CEarned 25,000$ by killing a #F24B4BNemesis#EF0C0C! #AFAFAF(#BD0202Nemesis Boss Event#AFAFAF)', root, 255, 255, 255, true)
end,2500,1)
	elseif select == "minions" then
givePlayerMoney ( attacker, 7500 ) 
setTimer(function()
		outputChatBox ('#AFAFAF[#BD0202ZTown#AFAFAF]:#F24B4B ' .. getPlayerName(attacker) .. ' #EF0C0CEarned 7,500$ by killing a #F24B4BMinion#EF0C0C! #AFAFAF(#BD0202Nemesis Boss Event#AFAFAF)', root, 255, 255, 255, true)
end,2500,1)
end
end
addEvent("bosseventreward", true)
addEventHandler("bosseventreward", root, bosseventrewards)

I hope sombady can help me out on this one!..

Gr.xboxxxxd

Share this post


Link to post

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.