NullSystemWorks / mtadayz

Official MTA:DayZ Repository
Other
42 stars 35 forks source link

Change player spawn #28

Closed GribixTugaZ closed 7 years ago

GribixTugaZ commented 7 years ago

Hello there.I have a suggestion related to the players spawn. Back in the day when i had my server,players were always doing spawn kill. What i did to change that was implement a new spawn system.The system consists in making all the players,spawn in the air,in random locations.In my opinion,this is something that you guys should take in consideration. I already tried to change the spawn locations.The problem is that i can't seem to find the file where the coordinates are. This is my suggestion.Before i leave,i just wanna thank you guys for the impressive work,ya'll have developed so far!Very impressed!

Thank you 👍

mtadayz commented 7 years ago

Seems to be related to issue #27. Spawnpositions can be changed here: tables/table_player.lua, while the function that determines spawning behaviour is located at init/spawn_init.lua.

As for the spawning in air, I've seen that on a few brazilian servers, and wasn't really impressed, mainly because it seemed so...out of place. It kind of breaks immersion. However, spawn killing is a valid concern, one we'll look into (perhaps by adding something like mercy invincibility?).

GribixTugaZ commented 7 years ago

Thanks for the handy info! Went ahead i deleted all the cords and just added one cord that i randomly got,in the air.After testing if it was working,i found a bug.I don't know if it's just happening to me,but when i was falling from the sky and hit the ground,i would get negative blood and not die.I could still walk with no problems and the blood would just raise no stop (negative). Back when i had my server,i addded a script that did what you just said.It gave kind of infinite health to a freshly spawned player.It was only like 15 seconds.The idea is good.The problem is that in the end it din't really work out.In my experience what works out is the idea that i just suggested,spawning from above.In what regards to immersion.I would think like the player was dropped from an airplane for whichever reason and well,got him self into the world of gta sa in a world full of zombies and other players.

1B0Y commented 7 years ago

It seems fall damage is not being accounted for in the damage code, and that no checks are being made for negative blood. Thanks for your findings, Gribix. This helps us a lot!

mtadayz commented 7 years ago

That's weird...fall damage is being accounted for, or else broken bones wouldn't appear as a condition. Check the very end of handlers/players/client/damage_player.lua. There's the condition for fall damage (damage type: 54).

GribixTugaZ commented 7 years ago

Little update:

Created a test account and the player spawned just fine.Hit the ground and the player didn't die.The fall damage only caused the character to break a leg and then the blood started counting negatively. Some zombies then started hitting me.The blood would just go around from something like 400 positive blood and then go back again to negative blood.Some seconds after,the character is laying on the ground.After a while my character came back to life and i was still able to walk just fine.Apart from the screen shacking and the broken leg.If needed i can record some footage and then send.It may be easier to demonstrate.

mtadayz commented 7 years ago

If you do a video, please enable /debugscript 3, so we can see just what exactly is going on. Thanks a lot.

GribixTugaZ commented 7 years ago

It would be easier for me if i could just share my screen on skype.It would be faster.If that isn't possible i can still make the video.

mtadayz commented 7 years ago

Just make a few screenshots in the following situations (with /debugscript 3 enabled):

Post them here then. Thanks, your help is much appreciated here.

GribixTugaZ commented 7 years ago

Here you go : http://imgur.com/a/HcUot

neves768 commented 7 years ago

In mine tests, i'm dying normally when i fall (tried with z values > 100 from ground).

mtadayz commented 7 years ago

Mind if you post your spawn_init.lua, @GribixTugaZ? Maybe there's the source of the bug. I just tested it, too, and I'm dying normally.

GribixTugaZ commented 7 years ago

Just gonna post the whole code here:

--[[

-----------------------------------------------------------------------------

---- MTA DayZ: spawn_init.lua ---- ---- Original Author: Marwin W., Germany, Lower Saxony, Otterndorf ----

---- This gamemode is being developed by L, CiBeR96, 1B0Y ---- ---- Type: SERVER ----

-----------------------------------------------------------------------------

]]

function spawnDayZPlayer(player) local number = math.random(table.size(spawnPositions)) local x,y,z = spawnPositions[number][1],spawnPositions[number][2],spawnPositions[number][3]

spawnPlayer (player, x,y,z, math.random(0,360), skin, 0, 0)
setElementFrozen(player, true)
fadeCamera (player, true)
setCameraTarget (player)
setTimer( function(player)
    if isElement(player) then
        setElementFrozen(player, false)
    end
end,500,1,player)
playerCol = createColSphere(x,y,z,1.5)
setElementData(player,"playerCol",playerCol)
attachElements ( playerCol, player, 0, 0, 0 )
setElementData(playerCol,"parent",player)
setElementData(playerCol,"player",true)
local account = getPlayerAccount(player)
setAccountData(account,"isDead",false)
setElementData(player,"isDead",false)
setElementData(player,"logedin",true)
setElementData(player,"bleeding", 0)
setElementData(player,"unconscious",false)
setElementData(player,"admin",getAccountData(account,"admin") or false)
setElementData(player,"supporter",getAccountData(account,"supporter") or false)
setPedStat(player, 21, math.random(200,400))
setElementData(player, "hoursalive", 0)

----------------------------------
--Player Items on Start
for i,data in ipairs(playerDataTable) do
    if data[1] == "Bandage" then
        setElementData(player,data[1],2)
    if data[1] == "Parachute" then
        setElementData(player,data[1],2)            
    elseif data[1] == "Painkiller" then
        setElementData(player,data[1],1)
    elseif data[1] == "Flashlight" then
        setElementData(player,data[1],1)
    elseif data[1] == "Beige Pants" then
        setElementData(player, data[1], 1)
    elseif data[1] == "Beige Vest" then
        setElementData(player, data[1], 1)
    elseif data[1] == "Black Shoe" then
        setElementData(player, data[1], 1)
    elseif data[1] == "MAX_Slots" then
        setElementData(player,data[1],8)
    elseif data[1] =="Item_Slots" then
        setElementData(player,data[1],12)
    elseif data[1] == "Weapon_Slots" then
        setElementData(player,data[1],1)
    elseif data[1] =="Backpack_Slots" then
        setElementData(player,data[1],8)
    elseif data[1] == "Backpack_Item_Slots" then
        setElementData(player,data[1],8)
    elseif data[1] =="Back_Weapon_Slots" then
        setElementData(player,data[1],0)
    elseif data[1] =="blood" then
        setElementData(player,data[1],12000)
    elseif data[1] =="temperature" then
        setElementData(player,data[1],37)
    elseif data[1] =="brokenbone" then
        setElementData(player,data[1],false)    
    elseif data[1] =="pain" then
        setElementData(player,data[1],false)
    elseif data[1] =="cold" then
        setElementData(player,data[1],false)
    elseif data[1] =="infection" then
        setElementData(player,data[1],false)
    elseif data[1] =="unconscious" then
        setElementData(player,data[1],false)
    elseif data[1] =="food" then
        setElementData(player,data[1],100)
    elseif data[1] =="thirst" then
        setElementData(player,data[1],100)
    elseif data[1] =="currentweapon_1" then
        setElementData(player,data[1],false)
    elseif data[1] =="currentweapon_2" then
        setElementData(player,data[1],false)    
    elseif data[1] =="currentweapon_3" then
        setElementData(player,data[1],false)    
    elseif data[1] =="bandit" then
        setElementData(player,data[1],false)
    elseif data[1] =="humanity" then
        setElementData(player,data[1],2500)
    elseif data[1] == "bloodtype" then
        determineBloodType(player)
    elseif data[1] == "bloodtypediscovered" then
        setElementData(player,"bloodtypediscovered","?")
    else
        setElementData(player,data[1],0)
    end
end
triggerEvent("onPlayerChangeClothes", player)
----------------------------------

end

function notifyAboutExplosion2() for i,player in pairs(getVehicleOccupants(source)) do triggerEvent("kilLDayZPlayer",player) end end addEventHandler("onVehicleExplode", getRootElement(), notifyAboutExplosion2)

function destroyDeadPlayer (ped,pedCol) local x,y,z = getElementPosition(ped) local tCol = createColCircle(x,y,z,20) for i, v in ipairs(getElementsByType("player")) do local detection = isElementWithinColShape(ped, tCol) if detection then setTimer(destroyDeadPlayer,300000,1,ped,pedCol) --If player found exit loop and re-check in 5 minutes. return end end destroyElement(ped) destroyElement(pedCol) destroyElement(tCol) end

function kilLDayZPlayer (killer,headshot,weapon) pedCol = false local account = getPlayerAccount(source) if not account then return end killPed(source) triggerClientEvent(source,"hideInventoryManual",source) if not isElementInWater(source) then local x,y,z = getElementPosition(source) if getDistanceBetweenPoints3D (x,y,z,6000,6000,0) > 200 then local x,y,z = getElementPosition(source) local rotX,rotY,rotZ = getElementRotation(source) local skin = getElementModel(source) ped = createPed(skin,x,y,z,rotZ) pedCol = createColSphere(x,y,z,1.5) killPed(ped) setTimer(destroyDeadPlayer,600000,1,ped,pedCol) -- 3600000*0.75 attachElements (pedCol,ped,0,0,0) setElementData(pedCol,"parent",ped) setElementData(pedCol,"playername",getPlayerName(source)) setElementData(pedCol,"deadman",true) setElementData(pedCol,"MAX_Slots",getElementData(source,"MAX_Slots")) local hours, minutes = getTime() if hours < 10 then hour = "0"..hours else hours = hours end if minutes < 10 then minutes = "0"..minutes else minutes = minutes end setElementData(pedCol,"deadreason"," name was "..tostring(getPlayerName(source))..", it appears died at "..hours..":"..minutes..".") end end triggerClientEvent(source,"onClientPlayerDeathInfo",source) if killer then setElementData(killer,"murders",getElementData(killer,"murders")+1) if getElementData(killer,"humanity") <= 0 then setElementData(killer,"bandit",true) end if getElementData(source,"bandit") == true then setElementData(killer,"banditskilled",getElementData(killer,"banditskilled")+1) end if headshot == true then setElementData(killer,"headshots",getElementData(killer,"headshots")+1) end end --SetElementDatas if pedCol then for i,data in ipairs(playerDataTable) do local plusData = getElementData(source,data[1]) if data[1] == "11.43x23mm Cartridge" then plusData = math.floor(getElementData(source,data[1])/7) elseif data[1] == "9x18mm Cartridge" then plusData = math.floor(getElementData(source,data[1])/8) elseif data[1] == "9x19mm Cartridge" then plusData = math.floor(getElementData(source,data[1])/17) elseif data[1] == ".303 British Cartridge" then plusData = math.floor(getElementData(source,data[1])/10) elseif data[1] == "5.45x39mm Cartridge" then plusData = math.floor(getElementData(source,data[1])/30) elseif data[1] == "7.62x39mm Cartridge" then plusData = math.floor(getElementData(source,data[1])/30) elseif data[1] == "7.62x51mm Cartridge" then plusData = math.floor(getElementData(source,data[1])/20) elseif data[1] == "5.56x45mm Cartridge" then plusData = math.floor(getElementData(source,data[1])/20) elseif data[1] == "7.62x54mm Cartridge" then plusData = math.floor(getElementData(source,data[1])/10) elseif data[1] == "1866 Slug" then plusData = math.floor(getElementData(source,data[1])/15) elseif data[1] == "Gauge 12 Pellet" then plusData = math.floor(getElementData(source,data[1])/7) elseif data[1] == "Bolt" then plusData = math.floor(getElementData(source,data[1])/7) end

        setElementData(pedCol,data[1],plusData)
    end
    --Skin
    --local skinID = getElementData(source,"skin")
    --local skin = getSkinNameFromID(skinID)
    --setElementData(pedCol,skin,1)
    --Backpack
    local backpackSlots = getElementData(source,"MAX_Slots")
    if backpackSlots == gameplayVariables["assaultpack_slots"] then
        setElementData(pedCol,"Assault Pack (ACU)",1)
    elseif backpackSlots == gameplayVariables["czechvest_slots"] then
        setElementData(pedCol,"Czech Vest Pouch",1)
    elseif backpackSlots == gameplayVariables["alice_slots"] then
        setElementData(pedCol,"ALICE Pack",1)
    elseif backpackSlots == gameplayVariables["survival_slots"] then
        setElementData(pedCol,"Survival ACU",1)
    elseif backpackSlots == gameplayVariables["britishassault_slots"] then
        setElementData(pedCol,"British Assault Pack",1)
    elseif backpackSlots == gameplayVariables["coyote_slots"] then
        setElementData(pedCol,"Backpack (Coyote)",1)
    elseif backpackSlots == gameplayVariables["czech_slots"] then
        setElementData(pedCol,"Czech Backpack",1)
    end
end
setTimer(setElementPosition,500,1,source,6000,6000,0)
setAccountData(account,"isDead",true)
setElementData(source,"isDead",true)
outputSideChat("Player "..getPlayerName(source).." was killed",root,255,255,255)
destroyElement(getElementData(source,"playerCol"))
setTimer(spawnDayZPlayer,30000,1,source)

end addEvent("kilLDayZPlayer",true) addEventHandler("kilLDayZPlayer",getRootElement(),kilLDayZPlayer)

GribixTugaZ commented 7 years ago

Maybe it has something to do with me spawning from above?The gm somehow corrupted?

0xCiBeR commented 7 years ago

Please post the code here: https://paste.mta-dayz.org/

GribixTugaZ commented 7 years ago

I've updated to the latest version of the gm and now it seems to be working just fine.

1B0Y commented 7 years ago

Solved. Closing...