Jump to content

help with error mta dayz spawn kill


SkyDow

Recommended Posts

function spawnDayZPlayer(player)
    if player then
        local x,y,z = unpack(spawnPositions[math.random(#spawnPositions)]);
        spawnPlayer(player, x, y, (z+0.5), math.random(360), 73, 0, 0);
        setCameraTarget(player, player);
        fadeCamera(player, true);
        local 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);
        setAccountData(getPlayerAccount(player), "isDead", false);
        setElementData(player, "isDead", false);
        setElementData(player, "logedin", true);
        for _,v in ipairs(playerDataTable) do
            if (v[1] ~= "radiochannel" and v[1] ~= "gpschannel") then
                setElementData(player, v[1], v[2]);
            end
        end
        setElementData(player, "logedin", true);
        setTimer(checkBuggedAccont, (25*1000), 1, player);
        setElementData(player, "spawnedzombies", 0);
    end
end

addEventHandler("kilLDayZPlayer", root, function(killer, headshot, weapon)
    local account = getPlayerAccount(source);
    if not account then return; end
    triggerClientEvent(source, "onClientPlayerDeathInfo", source);
    killPed(source);
    triggerClientEvent(source, "hideInventoryManual", source);
    if not isElementInWater(source) then
        if (getElementData(source, "alivetime") > 5) then -- If alivetime is bigger than 5 mins, to avoid haveing too much corpses at spawn.
            local x,y,z = getElementPosition(source);
            if (getDistanceBetweenPoints3D(x, y, z, 6000, 6000, 0) > 200) then
                local x,y,z = getElementPosition(source);
                local _,_,rotz = getElementRotation(source);
                local skin = getElementModel(source);
                local ped = createPed(skin, x, y, z, rotz);
                local pedCol = createColSphere(x, y, z, 1.5);
                killPed(ped);
                setTimer(function(ped, pedCol)
                    if ped then destroyElement(ped); end
                    if pedCol then destroyElement(pedCol); end
                end, (10*60000), 1, ped, pedCol);
                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 time = getRealTime();
                setElementData(pedCol, "deadreason", getPlayerName(source).." is dead. Cause of death: "..(weapon or "Unknown")..". Time of death: "..time.hour..":"..time.minute.." o'clock.");
                if pedCol then
                    for _,v in ipairs(playerDataTable) do
                        local itemPlus = getElementData(source, v[1]);
                        if (v[1] == "M1911 Mag") then itemPlus = math.floor(getElementData(source, v[1])/10);
                        elseif (v[1] == "M9 SD Mag") then itemPlus = math.floor(getElementData(source, v[1])/15);
                        elseif (v[1] == "Desert Eagle Mag") then itemPlus = math.floor(getElementData(source, v[1])/7);
                        elseif (v[1] == "PDW Mag") then itemPlus = math.floor(getElementData(source, v[1])/30);
                        elseif (v[1] == "MP5A5 Mag") then itemPlus = math.floor(getElementData(source, v[1])/20);
                        elseif (v[1] == "AS50 Mag") then itemPlus = math.floor(getElementData(source, v[1])/40);
                        elseif (v[1] == "CZ550 Mag") then itemPlus = math.floor(getElementData(source, v[1])/10);
                        elseif (v[1] == "Mosin 9130 Mag") then itemPlus = math.floor(getElementData(source, v[1])/35);
                        elseif (v[1] == "M24 Mag") then itemPlus = math.floor(getElementData(source, v[1])/10);
                        elseif (v[1] == "KVSK Mag") then itemPlus = math.floor(getElementData(source, v[1])/15);
                        elseif (v[1] == "M107 Mag") then itemPlus = math.floor(getElementData(source, v[1])/5);
                        elseif (v[1] == "SVD Dragunov Camo Mag") then itemPlus = math.floor(getElementData(source, v[1])/25);
                        elseif (v[1] == "MK 48 Mod 0 Mag") then itemPlus = math.floor(getElementData(source, v[1])/100);
                        elseif (v[1] == "MG36 Mag") then itemPlus = math.floor(getElementData(source, v[1])/100);
                        elseif (v[1] == "PKP Mag") then itemPlus = math.floor(getElementData(source, v[1])/100);
                        elseif (v[1] == "AK-107 Mag") then itemPlus = math.floor(getElementData(source, v[1])/30);
                        elseif (v[1] == "AKS Gold Mag") then itemPlus = math.floor(getElementData(source, v[1])/30);
                        elseif (v[1] == "SA-58V ACOG Mag") then itemPlus = math.floor(getElementData(source, v[1])/30);
                        elseif (v[1] == "AKS-74U Mag") then itemPlus = math.floor(getElementData(source, v[1])/30);
                        elseif (v[1] == "M4A1 Holo Mag") then itemPlus = math.floor(getElementData(source, v[1])/20);
                        elseif (v[1] == "1866 Slug") then itemPlus = math.floor(getElementData(source, v[1])/7);
                        elseif (v[1] == "2Rnd. Slug") then itemPlus = math.floor(getElementData(source, v[1])/2);
                        elseif (v[1] == "SPAZ-12 Pellet") then itemPlus = math.floor(getElementData(source, v[1])/7);
                        elseif (v[1] == "DMR Mag") then itemPlus = math.floor(getElementData(source, v[1])/5);
                        elseif (v[1] == "SKS-45 Mag") then itemPlus = math.floor(getElementData(source, v[1])/10);
                        end
                        if not string.find(v[1], "(Equipped)") then
                            setElementData(pedCol, v[1], itemPlus);
                        end
                        for i = 1, 3 do
                            local item = getElementData(source, "currentweapon_"..tostring(i));
                            if (item ~= "") then
                                setElementData(pedCol, item, 1);
                            end
                        end
                    end
                    local skin = getSkinNameFromID(getElementData(source, "skin"));
                    setElementData(pedCol, skin, getElementData(pedCol, skin) + 1);
                    local backpack = getBackpackNameFromSlots(getElementData(source, "MAX_Slots"));
                    setElementData(pedCol, backpack, (getElementData(pedCol, backpack) or 0) + 1);
                end
            end
        end
    end
    if (killer and killer ~= source and getElementType(killer) == "player") then
        if (getElementData(source, "htype") ~= "Bandit") then
            addPlayerStats(killer, "humanity", math.random(-2500, -1000));
        else
            addPlayerStats(killer, "humanity", math.random(1000, 2500));
        end
        setElementData(killer, "murders", getElementData(killer, "murders") + 1);
        if (getElementData(source, "htype") == "Bandit") then
            setElementData(killer, "banditskilled", getElementData(killer, "banditskilled") + 1);
        end
        if headshot then
            setElementData(killer, "headshots", getElementData(killer, "headshots") + 1);
        end
        triggerClientEvent("displayClientInfo", root, "#FFFFFF"..getPlayerName(source).." #FFFFFFwas killed by "..getPlayerName(killer), 0, 22, 255);
    else
        triggerClientEvent("displayClientInfo", root, "#FFFFFF"..getPlayerName(source).." #FFFFFFwas killed", 0, 22, 255);
    end
    setTimer(setElementPosition, 500, 1, source, 6000, 6000, 0);
    setAccountData(account, "isDead", true);
    setElementData(source, "isDead", true);
    setTimer(spawnDayZPlayer, 10000, 1, source);
end);

addEventHandler("onPlayerQuit", root, function()
    savePlayerData(source);
end);

addEventHandler("onResourceStop", root, function()
    for _,v in pairs(getElementsByType("player")) do
        savePlayerData(v);
    end
end);

[2019-10-30 18:32:05] ERROR: [DayZ-MTA]/DayZ/accounts.Lua:344: attempt to perform arithmetic on a boolean value
[2019-10-30 18:32:06] WARNING: [DayZ-MTA]/DayZ/accounts.Lua:344: Bad argument @ 'getElementData' [Expected string at argument 2, got nil]
[2019-10-30 18:32:06] ERROR: [DayZ-MTA]/DayZ/accounts.Lua:344: attempt to perform arithmetic on a boolean value

[2019-10-30 18:31:02] ERROR: [DayZ-MTA]/DayZ/accounts.Lua:307: attempt to perform arithmetic on a boolean value
[2019-10-30 18:31:08] WARNING: [DayZ-MTA]/DayZ/accounts.Lua:307: Bad argument @ 'getElementData' [Expected string at argument 2, got nil]
[2019-10-30 18:31:08] ERROR: [DayZ-MTA]/DayZ/accounts.Lua:307: attempt to perform arithmetic on a boolean value

https://imgur.com/a/rRBCOHf

when I give /kill it kills me and my screen floats and does not respawn me

Edited by SparkySky
Link to comment

 

make new script to fix the problem
 

spawnPositions={

{1300,200,11},

{800,100,11},

}

function respwan(plr)

          if ( isPedDead (plr ) ) then

        local x,y,z = unpack(spawnPositions[math.random(#spawnPositions)]);

                       spawnPlayer ( plr, x,y,z)

        end

end


addEventHandler( "onPlayerWasted", getRootElement( ),
    function()
        setTimer(respwan,10000, 1, source)
    end
)

 

Link to comment

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.
×
×
  • Create New...