SEV3NS Posted March 1, 2015 Share Posted March 1, 2015 i want to add the blood system to this bodyguard script i downloaded off the community resources but i cant figure it out. i tried to pull it off the zombie script but the two are still not compatible with each other in dealing and receiving damage to each other. bodyguard --declare global variables guardList = {} markerList = {} blipList = {} iterator=0 --declare custom events addEvent("checkTable",true) --make markers function createMarkerAttachedTo(element, mType, size, r, g, b, a, visibleTo, xOffset, yOffset, zOffset) mType, size, r, g, b, a, visibleTo, xOffset, yOffset, zOffset = mType or "checkpoint", size or 4, r or 0, g or 0, b or 255, a or 255, visibleTo or getRootElement(), xOffset or 0, yOffset or 0, zOffset or 0 assert(isElement(element), "Bad argument @ 'createMarkerAttachedTo' [Expected element at argument 1, got " .. type(element) .. "]") assert(type(mType) == "string", "Bad argument @ 'createMarkerAttachedTo' [Expected string at argument 2, got " .. type(mType) .. "]") assert(type(size) == "number", "Bad argument @ 'createMarkerAttachedTo' [Expected number at argument 3, got " .. type(size) .. "]") assert(type(r) == "number", "Bad argument @ 'createMarkerAttachedTo' [Expected number at argument 4, got " .. type(r) .. "]") assert(type(g) == "number", "Bad argument @ 'createMarkerAttachedTo' [Expected number at argument 5, got " .. type(g) .. "]") assert(type(b) == "number", "Bad argument @ 'createMarkerAttachedTo' [Expected number at argument 6, got " .. type(b) .. "]") assert(type(a) == "number", "Bad argument @ 'createMarkerAttachedTo' [Expected number at argument 7, got " .. type(a) .. "]") assert(isElement(visibleTo), "Bad argument @ 'createMarkerAttachedTo' [Expected element at argument 8, got " .. type(visibleTo) .. "]") assert(type(xOffset) == "number", "Bad argument @ 'createMarkerAttachedTo' [Expected number at argument 9, got " .. type(xOffset) .. "]") assert(type(yOffset) == "number", "Bad argument @ 'createMarkerAttachedTo' [Expected number at argument 10, got " .. type(yOffset) .. "]") assert(type(zOffset) == "number", "Bad argument @ 'createMarkerAttachedTo' [Expected number at argument 11, got " .. type(zOffset) .. "]") local m = createMarker(0, 0, 0, mType, size, r, g, b, a, visibleTo) if m then if attachElements(m, element, xOffset, yOffset, zOffset) then return m end end return false end --make table compressed function compressTable() local tempGuardTable= {} local tempMarkerTable= {} local tempBlipTable= {} local newkey = 0 for key=1, iterator, 1 do if((not isElement(guardList[key]))or(getElementHealth(guardList[key])<=0))then destroyElement(blipList[key]) destroyElement(markerList[key]) else newkey = newkey + 1 tempGuardTable[newkey]=guardList[key] tempMarkerTable[newkey]=markerList[key] tempBlipTable[newkey]=blipList[key] end end guardList = nil markerList = nil blipList = nil guardList = tempGuardTable markerList = tempMarkerTable blipList = tempBlipTable iterator = newkey end addEventHandler("checkTable",getRootElement(),compressTable) --check every dead ped function clearall() compressTable() end addEventHandler("onPedWasted", getRootElement(), clearall) --make the bodyguard function copyBot(from) local x,y,z = getElementPosition(from) local tpTeam = getPlayerTeam(from) local tpName = getPlayerName(from) if(tpTeam and(getPlayerMoney(from)>=0))then iterator = iterator + 1 guardList[iterator] = exports["slothbot"]:spawnBot(x+5, y, z, 0, 287, 0, 0, tpTeam, 29, "following", from) outputChatBox("Working...", from, 0, 0, 255, true) triggerEvent("checkTable", from) if(guardList[iterator])then takePlayerMoney(from, 0) setElementData(guardList[iterator], "ownerName", tpName) blipList[iterator] = createBlipAttachedTo(guardList[iterator],0,2,0,255,0,255,0,65535,from) markerList[iterator] = createMarkerAttachedTo(guardList[iterator],"arrow",0.3,0,255,0,0,from,0,0,1.3) outputChatBox("Beware, "..tpName.." #ff0000 has created a bodyguard!", getRootElement(), 255, 0, 0, true) else guardList[iterator]=nil iterator = iterator - 1 outputChatBox("Sorry an error occured, please pm to the creator(ilhamaryasuta)!", from, 255, 0, 0, true) end elseif(tpTeam and (getPlayerMoney(from)>=0))then outputChatBox("You don't have enough money!",from, 255, 0, 0, true) else if(isGuestAccount(getPlayerAccount(from)))then outputChatBox("Please register/login first!", from, 255, 0, 0, true) else outputChatBox("Please join a team first!", from, 255, 0, 0, true) end end end addCommandHandler("spawnguard", copyBot) --count the bodyguard function countGuard(from) triggerEvent("checkTable", from) outputChatBox("there is "..iterator.." bodyguards", from, 0, 255, 0, true) for gkey,gval in pairs(guardList)do if(isElement(gval))then local gHealth = getElementHealth(gval) local thisOwner = getElementData(gval, "ownerName") outputChatBox("Bodyguard "..gkey.." : "..math.floor(gHealth+0.5).." hp, Owner : "..thisOwner.."#00ff00 !", from, 0, 255, 0, true) else outputChatBox("Bodyguard "..gkey.." : Dead", from, 0, 255, 0, true) end end end addCommandHandler("guard", countGuard) --clean the bodyguard data function sweepGuard(from) triggerEvent("checkTable", from) end addCommandHandler("cleanguard", sweepGuard) day z (i already added the guards blood on the one below but no effect. --[[ #---------------------------------------------------------------# ----* DayZ MTA Script editor_server.lua *---- ----* This Script is owned by Marwin, you are allowed to edit it. ----* Owner: Marwin W., Germany, Lower Saxony, Otterndorf ----* Skype: xxmavxx96 ----* *---- #---------------------------------------------------------------# ]] --SERVER OUTPUTS shownInfos = {} shownInfos["nomag"] = "No magazines left for this weapon!" shownInfos["youconsumed"] = "You consumed" shownInfos["needwatersource"] = "You have to be inside a body of water!" shownInfos["filledup"] = "You filled your Water Bottle up!" shownInfos["noradio"] = "You have no Radio Device!" --GAMEPLAY SETUP gameplayVariables = {} gameplayVariables["zombieblood"] = 6000 -- Zombie Blood/Health - DEFAULT: 6000 gameplayVariables["guardblood"] = 10000 gameplayVariables["foodrestore"] = math.random(40,100) -- Amount of hunger to be restored when eating - DEFAULT: math.random(40,100) - FOR FULL RESTORE, JUST WRITE 100 gameplayVariables["thirstrestore"] = math.random(40,100) -- Amount of hunger to be restored when drinking - DEFAULT: math.random(40,100) - FOR FULL RESTORE, JUST WRITE 100 gameplayVariables["loseHunger"] = -1.5 -- Amount of losing hunger per minute - DEFAULT: -1.5 gameplayVariables["loseThirst"] = -1.5 -- Amount of losing thirst per minute - DEFAULT: -1.5 gameplayVariables["playerzombies"] = 30 -- Amount of spawning zombies per player - DEFAULT: 6 - THE HIGHER THIS VALUE, THE MORE LAG CAN OCCUR! gameplayVariables["amountzombies"] = 10 -- Amount of zombies - DEFAULT: 3 - THE HIGHER THIS VALUE, THE MORE LAG CAN OCCUR! gameplayVariables["temperaturewater"] = -0.01 -- Amount of temperature to be lost when in water - DEFAULT: -0.01 gameplayVariables["temperaturesprint"] = 0.005 -- Amount of temperature to be gained when sprinting - DEFAULT: 0.005 gameplayVariables["sprintthirst"] = -0.2 -- Amount of losing thirst when sprinting - DEFAULT: -0.2 gameplayVariables["enablenight"] = true -- Whether or not the night should be darker - DEFAULT: true - SET TO false to disable - remember you need to set it in editor_client.lua too. gameplayVariables["itemrespawntimer"] = 14400000 -- Number of milliseconds that should elapse before the items will respawn. Note: You can also just do 14400000/2 to make it the half from the current (division). -- SERVER BACKUP gameplayVariables["backupenabled"] = true -- Whether or not backup should be enabled. Backup = saves all tents, accounts & vehicles. - DEFAULT: true - Set to false to disable backup. gameplayVariables["backupinterval"] = 86400000 -- Number of milliseconds that should elapse before backup. Minimum: 50. - 1000 milliseconds = 1 second. - DEFAULT: 86400000 (= 24 hours) } 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