ThePCGuy Posted January 23, 2013 Share Posted January 23, 2013 Hello, I need some help with a Community Zombie script called: Zday. You have 3 types of zombie walks that activates by a setting trough meta.xml ZombieSpeed = get("zombies.Speed") Since i want to change the walk randomly i did this: ZombieSpeed = math.random( 1, 3 ) if ZombieSpeed == 1 then --super slow zombies (goofy looking) chaseanim = "WALK_drunk" checkspeed = 2000 elseif ZombieSpeed == 2 then -- normal speed chaseanim = "run_old" checkspeed = 1000 elseif ZombieSpeed == 3 then -- rocket zombies (possibly stressful on server) chaseanim = "Run_Wuzi" checkspeed = 680 end It does work, only it doesnt refresh on each zombie spawn. The math.random only activates once at the resource startup or restart. Is it possible to refresh after each zombie spawn? Link to comment
KenXeiko Posted January 23, 2013 Share Posted January 23, 2013 I believe that it's possible, just check the whole resource, you should be able to find the spawn function. Link to comment
ThePCGuy Posted January 23, 2013 Author Share Posted January 23, 2013 I just checked the whole resource (2 lua scripts) and didnt find something usefull about the spawns. Zombies spawn randomly if you walk around with ofcourse the danger elementdata. setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped ) ''chaseanim'' is the animation, so is it possible to make the math.random refresh ? Link to comment
Castillo Posted January 23, 2013 Share Posted January 23, 2013 Try with this: http://pastebin.com/Ggf6Rckg Link to comment
ThePCGuy Posted January 24, 2013 Author Share Posted January 24, 2013 Try with this: http://pastebin.com/Ggf6Rckg Does not work.. Link to comment
Castillo Posted January 24, 2013 Share Posted January 24, 2013 Yes, I noticed why, I forgot to return the values, replace the last function ( getRandomZombieSpeed ) with this: function getRandomZombieSpeed ( ) local ZombieSpeed = math.random( 1, 3 ) if ( ZombieSpeed == 1 ) then --super slow zombies (goofy looking) chaseanim = "WALK_drunk" checkspeed = 2000 elseif ( ZombieSpeed == 2 ) then -- normal speed chaseanim = "run_old" checkspeed = 1000 elseif ( ZombieSpeed == 3 ) then -- rocket zombies (possibly stressful on server) chaseanim = "Run_Wuzi" checkspeed = 680 end return checkspeed, chaseanim end Link to comment
ThePCGuy Posted January 24, 2013 Author Share Posted January 24, 2013 Yes, I noticed why, I forgot to return the values, replace the last function ( getRandomZombieSpeed ) with this: function getRandomZombieSpeed ( ) local ZombieSpeed = math.random( 1, 3 ) if ( ZombieSpeed == 1 ) then --super slow zombies (goofy looking) chaseanim = "WALK_drunk" checkspeed = 2000 elseif ( ZombieSpeed == 2 ) then -- normal speed chaseanim = "run_old" checkspeed = 1000 elseif ( ZombieSpeed == 3 ) then -- rocket zombies (possibly stressful on server) chaseanim = "Run_Wuzi" checkspeed = 680 end return checkspeed, chaseanim end Works now, only the animation changes every 1 second for all zombies in the game. Thats not what i meant if you thought it was. I want to randomly change the animation over time or even better each zombie that spawns have a different one. Link to comment
Castillo Posted January 24, 2013 Share Posted January 24, 2013 http://pastebin.com/b6Z4iGUy Try it. Link to comment
ThePCGuy Posted January 24, 2013 Author Share Posted January 24, 2013 http://pastebin.com/b6Z4iGUyTry it. ERROR: [DayZ-MTA]\zombietest\zombie_server.lua:48: bad argument #1 to 'unpack' (table expected, got boolean) Shows that error on each zombie spawn now. Link to comment
Castillo Posted January 24, 2013 Share Posted January 24, 2013 Here it works. Try this another one: http://pastebin.com/rM4yC83S Link to comment
ThePCGuy Posted January 24, 2013 Author Share Posted January 24, 2013 Zombies spawn, only it spams that error every second on debugscript 3 and Console, so it doesnt apply the animation now. Link to comment
Castillo Posted January 24, 2013 Share Posted January 24, 2013 I haven't got any error here, it works fine. Link to comment
ThePCGuy Posted January 24, 2013 Author Share Posted January 24, 2013 (edited) How? I am confused. You are not getting any error but i am.. EDIT: I think its cause of the elementData ''zombieData". Also i am using slothbot and a other zombie spawn script so thats why its conflicting cause the zombie spawns on slothbot but it applies the animation cause of ''chaseanim'' can you make a way around the elementData "zombieData" ? Edited January 24, 2013 by Guest Link to comment
Castillo Posted January 24, 2013 Share Posted January 24, 2013 Could be the game mode you are using, that is messing around with it. Link to comment
Castillo Posted January 24, 2013 Share Posted January 24, 2013 I'm not sure, but slothbots and zombies aren't meant to work together if I'm right. Link to comment
ThePCGuy Posted January 24, 2013 Author Share Posted January 24, 2013 Indeed, as i am using the zombies gamemode for the animations, moaning etcetra. It only needs to set the ''chaseanim'' differently. So can you make a way around so you dont have to use that elementData? Link to comment
Castillo Posted January 25, 2013 Share Posted January 25, 2013 No, that element data is required to store the random animation when the zombie spawns. Link to comment
ThePCGuy Posted January 25, 2013 Author Share Posted January 25, 2013 Well in that case, i have a problem anyways now since the zombie script itself wont spawn zombies for some reason. Already stopped the resource scoreboard. EDIT: Fixed now. 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