ronaldoguedess Posted October 2, 2013 Share Posted October 2, 2013 Hello My Friends, I am new here in the fórum. I'm trying to create a system of PEDS zombies, would not want to use the slothbot. I want to create a sort of articial intelligence to 'my zombies'. I need to create a system of blood (HP) for them. - Blood 5000 - And want to check if he died. Thus I check if he died right? function pedDamagep(attacker, weapon, bodypart, loss) if getElementData(source, "blood") <= 0 then outputChatBox("Ped died!", getLocalPlayer()) local x, y, z = getElementPosition(source) end end addEventHandler("onClientPedDamage", getRootElement(), pedDamagep) I wonder how I define Hp to 5000 for my zombie. Hugs. Link to comment
Castillo Posted October 2, 2013 Share Posted October 2, 2013 Max health is 200% using a stat ( setPedStat ), but you could use my resource "extra_health" which is used to give players/peds any amount of health. Link to comment
myonlake Posted October 2, 2013 Share Posted October 2, 2013 Another way to work around this is that the pedestrian never takes physical damage, but instead lowers the element data value everytime it is hit. Edit: I suppose Solidsnake's resource works that way. Link to comment
ronaldoguedess Posted October 2, 2013 Author Share Posted October 2, 2013 No problem, can be a lower value. but as I seto to their health? Not to succeeding. Link to comment
Castillo Posted October 2, 2013 Share Posted October 2, 2013 There's an event for when a ped dies: https://wiki.multitheftauto.com/wiki/OnClientPedWasted Link to comment
.:HyPeX:. Posted October 2, 2013 Share Posted October 2, 2013 Just a quick thingy.. not sure if it helps or not local ZombieCap = 10 -- Max zombies to spawn local alivezombies = 0 -- Current Zombies alive function zombies() if ZombieCap < alivezombies then local X, Y, Z = getElementPosition(getRandomPlayer) -- get Player Position local ZombiePed = createPed ( 10,X+10, Y-10,Z) -- Create the zombie next to player setElementData(ZombiePed, Blood, 5000) local alivezombies = alivezombies + 1 -- New Zombie to count end end function pedDamagep(attacker, weapon, bodypart, loss) local thePedZombie = getElementModel(source) -- get if its a zombie if thePedZombie = 10 then -- Check the zombie local Health = getElementData(source, Blood) setElementData(source, Blood, Health-ClientPedDamage) cancelEvent(ClientPedDamage) if getElementData(source, "Blood") <= 0 then outputChatBox("Ped died!", getLocalPlayer()) local x, y, z = getElementPosition(source) local alivezombies = alivezombies - 1 -- Zombie died, spawn a new one end end end addEventHandler("onClientPedDamage", getRootElement(), pedDamagep) Link to comment
ronaldoguedess Posted October 3, 2013 Author Share Posted October 3, 2013 Just a quick thingy.. not sure if it helps or not local ZombieCap = 10 -- Max zombies to spawn local alivezombies = 0 -- Current Zombies alive function zombies() if ZombieCap < alivezombies then local X, Y, Z = getElementPosition(getRandomPlayer) -- get Player Position local ZombiePed = createPed ( 10,X+10, Y-10,Z) -- Create the zombie next to player setElementData(ZombiePed, Blood, 5000) local alivezombies = alivezombies + 1 -- New Zombie to count end end function pedDamagep(attacker, weapon, bodypart, loss) local thePedZombie = getElementModel(source) -- get if its a zombie if thePedZombie = 10 then -- Check the zombie local Health = getElementData(source, Blood) setElementData(source, Blood, Health-ClientPedDamage) cancelEvent(ClientPedDamage) if getElementData(source, "Blood") <= 0 then outputChatBox("Ped died!", getLocalPlayer()) local x, y, z = getElementPosition(source) local alivezombies = alivezombies - 1 -- Zombie died, spawn a new one end end end addEventHandler("onClientPedDamage", getRootElement(), pedDamagep) Exactly Hypex. Thank you. however, I am having some incompatibility. My PED has created reactions and life itself now until the data varies with the gun, and I do not programmed any of that yet. What do I do? Does the GAMEMOD Play? ? There's an event for when a ped dies: https://wiki.multitheftauto.com/wiki/OnClientPedWasted I'm trying to learn the system of HP first, then I'll learn this. thank you! Link to comment
.:HyPeX:. Posted October 3, 2013 Share Posted October 3, 2013 well, you can edit the variables of the gun.. not sure if concat will work like this, never used it. -----------Zombie Managing---------- local ZombieCap = 10 -- Max zombies to spawn local alivezombies = 0 -- Current Zombies alive --------Weapon Managing-------------- local Weapon1 = 1 local Weapon2 = 2 local Weapon3 = 3 local Weapon4 = 4 local Weapon5 = 5 local Weapon6 = 6 local Weapon = { Weapon1 = {10}; -- Just edit values according to Weapon Type Weapon2 = {20}; Weapon3 = {30}; Weapon4 = {40}; Weapon5 = {50}; Weapon6 = {60}; };-- you can add more tables ----------------Function for Spawning Zombies------------- function zombies() if ZombieCap < alivezombies then local X, Y, Z = getElementPosition(getRandomPlayer) -- get Player Position local ZombiePed = createPed ( 10,X+10, Y-10,Z) -- Create the zombie next to player setElementData(ZombiePed, Blood, 5000) local alivezombies = alivezombies + 1 -- New Zombie to count end end --------Function for Damage on Zombies or kill---------------- function pedDamagep(attacker, weapon, bodypart, loss) local WeaponDamage local thePedZombie = getElementModel(source) -- get if its a zombie local weaponType = getPedWeapon(attacker) local WeaponDamage = table.concat(Weapon, weaponType) local Health = getElementData(source, Blood) if weaponType > 0 then -- If player has a weapon setElementData(source, Blood, Health-WeaponDamage) else if thePedZombie = 10 then -- Check the zombie setElementData(source, Blood, Health-ClientPedDamage) cancelEvent(ClientPedDamage) if getElementData(source, "Blood") <= 0 then outputChatBox("Ped died!", getLocalPlayer()) local x, y, z = getElementPosition(source) local alivezombies = alivezombies - 1 -- Zombie died, spawn a new one end end end end addEventHandler("onClientPedDamage", getRootElement(), pedDamagep) Link to comment
ronaldoguedess Posted October 3, 2013 Author Share Posted October 3, 2013 In short, in theory I would have to give 10 Hit Zombie for him to die .. But he dies with 3 shots, and the dummy falls, and even programmed it. Helpp. SERVER FILE: local zumb = createPed (37, -1993.5111083984,102.96244049072,27.5390625) setElementHealth (zumb, 200) setElementData(zumb, "status", true) local playerHealth = getElementHealth ( zumb ) tt = setTimer(function() if getElementHealth(zumb) <= 0 then outputChatBox ( "Zumbi Died", theplayer, 255, 0, 0 ) setElementData(zumb, "status", false) end end, 1000, 0) Client File: function zombiedamaged ( attacker, weapon, bodypart, loss ) if getElementType ( source ) == "ped" then --if (getElementData (source, "zumb") == true) then if ( bodypart == 9 ) then if (weapon == 25) or (weapon == 26) or (weapon == 27) then outputChatBox ( "head Shot", 255, 0, 0 ) setPedHeadless(source, true) setPedAnimation ( source, "PED" , "HitA_1", -1,false ) setElementHealth ( source, ( getElementHealth (source) - 10 ) ) end end end --end end addEventHandler ( "onClientPedDamage", getRootElement(), zombiedamaged ) Link to comment
.:HyPeX:. Posted October 3, 2013 Share Posted October 3, 2013 You are not getting the Weapon type over those scripts so Weapon will not apply. also you got some -- over there wich might be blocking the function. Link to comment
ronaldoguedess Posted October 3, 2013 Author Share Posted October 3, 2013 Thank you friend, it really was! However the only way I could get was this: addEventHandler("onResourceStart",resourceRoot, function ( ) setWeaponProperty(23, "pro", "damage", 100) end ) Would you like something more professional using tables, can you help me? I made a small table with the damage of weapons. damageTable = { {"M4",100}, {"AK-47",80}, {"Shotgun",100}, {"Silencied",10} } However, I do not know further if you can help me with some example will be grateful. This is the script that subtract the value of getElementHealth setElementHealth ( source, ( getElementHealth (source) - 100) ) Gostaria de pegar o valor do dano da arma, pela tabela e descontar nesse script acima. have any examples or explanation? Thanks to All! Link to comment
.:HyPeX:. Posted October 3, 2013 Share Posted October 3, 2013 If you meant to get the Damage of the weapon to the ped then its easy, just you need to get the damage. about using tables.. i still do not know how to read them correctly, i'm still playing over them. This should make it easier. function onpeddamge(attacker, weapon, bodypart, loss) -- Your function local weaponType = getPedWeapon(attacker) -- Getting the weapon.. if weaponType == 1 then -- If its this weapon then give it a string name(letters) local PedAtacker = M4 elseif weaponType == 2 then local PedAtacker = AK-47 elseif weaponType == 3 then local Pedatacker = Shotgun elseif weaponType == 4 then local Pedatacker = Silenced end if PedAtacker == M4 then -- Give the weapons a damage local PedAttackerWeapon = 100 elseif PedAtacker == AK-47 then local PedAttackerWeapon = 80 elseif PedAtacker == Shotgun then local PedAttackerWeapon = 100 elseif PedAtacker == Silenced then local PedAttackerWeapon = 10 end end setElementHealth ( source, ( getElementHealth (source) - PedAttackerWeapon) ) outputChatBox("You did".. PedAttackerWeapon .."damage with a ".. PedAtacker .." to the zombie!",source, true, 50, 255, 50) end addEventHandler ( "onClientPedDamage", getRootElement(), onpeddamage ) Link to comment
Moderators IIYAMA Posted October 4, 2013 Moderators Share Posted October 4, 2013 sorry, but this is just crap. local's can't leave the 'if' block. and much more mistakes. Link to comment
ronaldoguedess Posted October 9, 2013 Author Share Posted October 9, 2013 Thank you.: HyPeX, 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