Jump to content

[HELP] playerDropAItem


Recommended Posts

triggered serverside event playerDropAItem, but event is not added serverside

 

This is DayZ check if "playerDropAItem" event exists in pickups.lua

 

Edited by Tekken
typo
Link to post

META.xml : 

<meta>
    <info author="Shady" description="DayZ MTA Version" version="a5.5.6" type="gamemode" />
    <script src="editor_server.lua" type="server" />
    <script src="editor_client.lua" type="client" />
    <script src="pickups.lua" type="server" />
    <script src="spawn.lua" type="server" />
    <script src="vehicle_spawns.lua" type="server" />
    <script src="survivorSystem.lua" type="server" />
    <script src="zombies.lua" type="server" />
    <script src="animals.lua" type="server" />
    <script src="weather.lua" type="server" />
    <script src="login.lua" type="server" />
    <script src="tools/jq_server.lua" type="server" />
    <script src="menu_client.lua" type="client" />
    <script src="inventory.lua" type="client" />
    <script src="survivorSystem_client.lua" type="client" />
    <script src="animals_client.lua" type="client" />
    <script src="tools/jq_client.lua" type="client" />
    <script src="textlib.lua" type="client" />
    <script src="addons.lua" type="server" />
    <script src="shader/motion/motion_c.lua" type="client" />
    <file src="shader/motion/motion.fx" />
    <script src="shader/blackwhite/blackwhite_c.lua" type="client" />
    <file src="shader/blackwhite/blackwhite.fx" />
    <file src="tools/images/c_info/rand.png" />
    <file src="tools/images/background.png" />
    <file src="tools/images/imageHolder.png" />
    <file src="tools/images/flags/died.png" />
    <file src="tools/images/flags/join.png" />
    <file src="tools/images/flags/quit.png" />
    <export function="addGang" type="server" />
    <!-- group folder -->
    <script src="group/group.lua" type="client"/>
    <script src="group/group.slua" type="server"/>
    <!-- Addon: Exported Functions -->
    <export function="addAddonInfo" type="server" />
    <settings>
    <setting name="*column_name" value="Group" />
    <setting name="*gang_list_command" value="gangs" />
    <setting name="*gang_create_command" value="creategang" />
    </settings>
    <file src="images/scrollmenu_1.png" />
    <file src="images/scrollmenu_2.png" />
    <file src="images/background_scoreboard.png" />
    <file src="images/white.png" />
    <file src="images/window_bg.png" />
    <file src="images/dead.jpg" />
    <file src="images/dayzicons/blood.png" />
    <file src="images/dayzicons/brokenbone.png" />
    <file src="images/dayzicons/food.png" />
    <file src="images/dayzicons/temperature.png" />
    <file src="images/dayzicons/thirsty.png" />
    <file src="images/dayzicons/medic.png" />
    <file src="sounds/mgroan1.ogg" />
    <file src="sounds/mgroan2.ogg" />
    <file src="sounds/mgroan3.ogg" />
    <file src="sounds/mgroan4.ogg" />
    <file src="sounds/mgroan5.ogg" />
    <file src="sounds/mgroan6.ogg" />
    <file src="sounds/mgroan7.ogg" />
    <file src="sounds/mgroan8.ogg" />
    <file src="sounds/mgroan9.ogg" />
    <file src="sounds/mgroan10.ogg" />
    <file src="sounds/hit1.mp3" />
    <file src="sounds/hit2.mp3" />
    <file src="sounds/hit3.mp3" />
    <file src="items/assault_ammo.txd" />
    <file src="items/assault_ammo.dff" />
    <file src="items/backpack_alice.txd" />
    <file src="items/backpack_alice.dff" />
    <file src="items/backpack_ghillie.txd" />
    <file src="items/backpack_ghillie.dff" />
    <file src="items/backpack_ospack.txd" />
    <file src="items/backpack_ospack.dff" />
    <file src="items/backpack_coyote.dff" />
    <file src="items/backpack_coyote.txd" />
    <file src="items/backpack_legendary.txd" />
    <file src="items/backpack_legendary.dff" />
    <file src="items/beans_can.txd" />
    <file src="items/beans_can.dff" />
    <file src="items/first_aid_kit.txd" />
    <file src="items/first_aid_kit.dff" />
    <file src="items/heat_pack.txd" />
    <file src="items/heat_pack.dff" />
    <file src="items/pain_killers.txd" />
    <file src="items/pain_killers.dff" />
    <file src="items/pasta_can.txd" />
    <file src="items/pasta_can.dff" />
    <file src="items/pistol_ammo.txd" />
    <file src="items/pistol_ammo.dff" />
    <file src="items/shotgun_ammo.txd" />
    <file src="items/shotgun_ammo.dff" />
    <file src="items/backpack_small.txd" />
    <file src="items/backpack_small.dff" />
    <file src="items/backpack_czech.txd" />
    <file src="items/backpack_czech.dff" />
    <file src="items/smg_ammo.txd" />
    <file src="items/smg_ammo.dff" />
    <file src="items/sniper_ammo.txd" />
    <file src="items/sniper_ammo.dff" />
    <file src="items/soda_can.txd" />
    <file src="items/soda_can.dff" />
    <file src="items/water_bottle.txd" />
    <file src="items/water_bottle.dff" />
    <file src="items/tent.txd" />
    <file src="items/tent.dff" />
    <file src="items/wirefence.txd" />
    <file src="items/wirefence.dff" />
    <file src="items/camera.txd" />
    <file src="items/camera.dff" />
    <file src="items/katana.txd" />
    <file src="items/katana.dff" />
    <script src="bone_attach/bone_attach.lua" />
    <script src="bone_attach/bone_attach_c.lua" type="client" />
    <script src="bone_attach/attach_func.lua" />
    <script src="bone_attach/attach_func.lua" type="client" />
    <script src="bone_attach/bone_pos_rot.lua" type="client" />
</meta>


pickups.lua :

 

local itemTable = {
----------------------
["farm"] = {
{"Wood Pile",1463,0.4,0,13},
{"Bandage",1578,0.5,0,4},
{"Water Bottle",2683,1,0,6},
{"Pasta Can",2770,1,0,6},
{"Beans Can",2601,1,0,6},
{"Burger",2768,1,0,6},
{"Empty Soda Cans",2673,0.5,0,12},
{"Scruffy Burgers",2675,0.5,0,12},
{"Soda Bottle",2647,1,0,9},
{"Empty Gas Canister",1650,1,0,10},
{"Hunting Knife",335,1,90,4},
{"Box of Matches",328,0.4,90,8},
{"Desert Eagle",348,1,90,0.2},
{"Morphine",1579,1,0,4},
{"Tent",1279,1,0,0.5},
{"M1911",346,1,90,4},
{"Painkiller",2709,3,0,3.5},
{"Lee Enfield",357,1,90,0.3},
{"Winchester 1866",349,1,90,0.3},
{"Tire",1073,1,0,2},
{"Blooded Woman",1247,2,0,2.5},
{"Map",1277,0.8,90,6},
{"GPS",2976,0.15,0,2},
{"Czech Backpack",1239,1,0,2},
{"OS Backpack",1240,1,0,0.4}, 
{"Coyote Backpack",1242,1,0,0.7},
{"Ghillie Backpack",1253,1,0,0.8},
},
----------------------
["residential"] = {
{"Box of Matches",328,0.4,90,5},
{"Wood Pile",1463,0.4,0,5},
{"M1911",346,1,90,1.5},
{"M9 SD",347,1,90,1.9},
{"Winchester 1866",349,1,90,0.1},
{"PDW",352,1,90,1},
{"Hunting Knife",335,1,90,3},
{"Hatchet",339,1,90,1},
{"Pizza",1582,1,0,7},
{"Soda Bottle",2647,1,0,7},
{"Empty Gas Canister",1650,1,0,9},
{"Roadflare",324,1,90,9},
{"Milk",2856,1,0,7},
{"Assault Pack (ACU)",3026,1,0,6},
{"Painkiller",2709,3,0,7},
{"Empty Soda Cans",2673,0.5,0,12},
{"Scruffy Burgers",2675,0.5,0,12},
{"Grenade",342,1,0,0.01},
{"Desert Eagle",348,1,90,0.4},
{"Sawn-Off Shotgun",350,1,90,0.3},
{"SPAZ-12 Combat Shotgun",351,1,90,0.4},
{"MP5A5",353,1,90,0.4},
{"Watch",2710,1,0,3},
{"Heat Pack",1576,5,0,6},
{"Wire Fence",933,0.25,0,1},
{"Lee Enfield",357,1,90,0.3},
{"Alice Pack",1248,1,0,1.5},
{"Tire",1073,1,0,1},
{"Morphine",1579,1,0,2},
{"Blooded Woman",1241,2,0,9},
{"Map",1277,0.8,90,10},
{"GPS",2976,0.15,0,3},
{"Pasta Can",2770,1,0,7},
{"Beans Can",2601,1,0,7},
--{"TEC-9",372,1,90,0},
{"Burger",2768,1,0,7},
{"Golf Club",333,1,90,3},
{"Baseball Bat",336,1,90,3},
{"Shovel",337,1,90,3},
{"Czech Backpack",1239,1,0,2}, 
{"OS Backpack",1240,1,0,0.4},
{"Coyote Backpack",1242,1,0,0.7},
{"Ghillie Backpack",1253,1,0,0.8},
},
----------------------
["military"] = {
{"Box of Matches",328,0.4,90,2},
{"M1911",346,1,90,5},
{"M9 SD",347,1,90,4},
{"Winchester 1866",349,1,90,3},
{"PDW",352,1,90,4},
{"Hunting Knife",335,1,90,2.4},
{"Hatchet",339,1,90,2.1},
{"Pizza",1582,1,0,2},
{"Soda Bottle",2647,1,0,2},
{"Empty Gas Canister",1650,1,0,4},
{"Roadflare",324,1,90,4},
{"Milk",2856,1,0,1},
{"Painkiller",2709,3,0,4},
{"Empty Soda Cans",2673,0.5,0,12},
{"Scruffy Burgers",2675,0.5,0,12},
{"Grenade",342,1,0,0.5},
{"Sawn-Off Shotgun",350,1,90,2.3},
{"SPAZ-12 Combat Shotgun",351,1,90,2.3},
{"MP5A5",353,1,90,2.8},
{"Watch",2710,1,0,4},
{"Heat Pack",1576,5,0,3},
{"Wire Fence",933,0.25,0,1},
{"Lee Enfield",357,1,90,3.5},
{"Alice Pack",1248,1,0,4},
{"Night Vision Goggles",368,1,90,4},
{"Binoculars",369,1,0,4},
{"Tire",1073,1,0,2},
{"Morphine",1579,1,0,4},
{"Camouflage Clothing",2060,2,0,4.5},
{"Bandit Clothing",1247,2,0,4.5},
{"Ghost Camouflage",1247,2,0,4.5},
{"Ghost Clothing",1247,2,0,4.5},
{"Camouflage Clothing F",1247,2,0,4.5},
{"Civilian Clothing F",1247,2,0,4.5},
{"Rebel Terrorist",1247,2,0,4.5},
{"Ghillie Woman",1247,2,0,4.5},
{"Ghillie Suit 2",1247,2,0,4.5},
{"Jungle Ghillie Suit",1247,2,0,4.5},
{"Jocker Suit",1247,2,0,4.5},
{"Blooded Woman",1247,2,0,3},
{"Isis Clothing",1247,2,0,3},
--{"TEC-9",372,1,90,3},
{"AK-47",355,1,90,3.8},
{"GPS",2976,0.15,0,3},
{"Map",1277,0.8,90,7},
{"Toolbox",2969,0.5,0,1},
{"Engine",929,0.3,0,2},
{"Tank Parts",1008,0.3,0,2.1},
{"Tent",1279,1,0,4.5},
{"Ghillie Suit 1",1213,2,0,0.3},
{"M4",356,1,90,2.4},
{"CZ 550",358,1,90,0.4},
{"Infrared Goggles",369,1,90,3},
{"Assault Pack (ACU)",3026,1,0,5},
{"Czech Backpack",1239,1,0,2}, 
{"Radio Device",330,1,0,6},
{"Legendary Backpack",1252,1,0,0.9},
{"OS Backpack",1240,1,0,0.4},
{"Coyote Backpack",1242,1,0,0.7},
{"Ghillie Backpack",1253,1,0,0.8},
--{"Thermal GPS",2976,0.2,0,4},
--{"GPS Jammer",2976,0.2,0,3},
{"Shovel",337,1,90,1},
},
----------------------
["industrial"] = {
{"Wire Fence",933,0.25,0,7},
{"Toolbox",2969,0.5,0,3},
{"Tire",1073,1,0,4},
{"Engine",929,0.3,0,3.5},
{"Tank Parts",929,0.3,0,3.6},
{"Winchester 1866",349,1,90,3},
{"Water Bottle",2683,1,0,4},
{"Pasta Can",2770,1,0,4},
{"Beans Can",2601,1,0,4},
{"Burger",2768,1,0,4},
{"Empty Soda Cans",2673,0.5,0,12},
{"Scruffy Burgers",2675,0.5,0,10},
{"Soda Bottle",2647,1,0,4},
{"Empty Gas Canister",1650,1,0,6},
{"Full Gas Canister",1650,1,0,1.5},
{"Map",1277,0.8,90,3},
{"Watch",2710,1,0,2},
{"Box of Matches",328,0.4,90,5},
{"Wood Pile",1463,0.4,0,2},
{"M1911",346,1,90,1.5},
{"PDW",352,1,90,2},
{"Hunting Knife",335,1,90,2},
{"Czech Backpack",1239,1,0,2}, 
{"Hatchet",339,1,90,1.5},
{"Pizza",1582,1,0,4},
{"Roadflare",324,1,90,5},
{"Milk",2856,1,0,4},
{"Assault Pack (ACU)",3026,1,0,6},
{"Legendary Backpack",1252,1,0,0.5},
{"Radio Device",330,1,0,6},
--{"Thermal GPS",2976,0.2,0,1},
--{"GPS Jammer",2976,0.2,0,1},
{"Golf Club",333,1,90,1.5},
{"Baseball Bat",336,1,90,1.5},
{"Shovel",337,1,90,1.5},
{"Night Vision Goggles",368,1,90,1.5},
{"Czech Backpack",1239,1,0,2},
{"OS Backpack",1240,1,0,0.4},
{"Coyote Backpack",1242,1,0,0.7},
{"Ghillie Backpack",1253,1,0,0.8},
},
----------------------
["supermarket"] = {
{"Raw Meat",2804,0.5,90,8},
{"Box of Matches",328,0.4,90,5},
{"Wood Pile",1463,0.4,0,5},
{"M1911",346,1,90,3.5},
{"PDW",352,1,90,2},
{"Hunting Knife",335,1,90,3},
{"Hatchet",339,1,90,2.1},
{"Pizza",1582,1,0,7},
{"Soda Bottle",2647,1,0,7},
{"Empty Gas Canister",1650,1,0,5},
{"Roadflare",324,1,90,6},
{"Milk",2856,1,0,7},
{"Assault Pack (ACU)",3026,1,0,6},
{"Pasta Can",2770,1,0,7},
{"Beans Can",2601,1,0,7},
{"Burger",2768,1,0,7},
{"Painkiller",2709,3,0,7},
{"Empty Soda Cans",2673,0.5,0,12},
{"Scruffy Burgers",2675,0.5,0,12},
{"MP5A5",353,1,90,0.5},
{"Watch",2710,1,0,3},
{"Heat Pack",1576,5,0,6},
{"Wire Fence",933,0.25,0,1},
{"Lee Enfield",357,1,90,0.2},
{"Alice Pack",1248,1,0,0.5},
{"Tire",1073,1,0,1},
{"Morphine",1579,1,0,2},
{"Blooded Woman",1241,2,0,3.5},
{"Map",1277,0.8,90,4},
{"GPS",2976,0.15,0,1},
{"Radio Device",330,1,0,6},
{"Golf Club",333,1,90,1.9},
{"Baseball Bat",336,1,90,1.4},
{"Shovel",337,1,90,0.3},
{"OS Backpack",1240,1,0,0.4},
{"Coyote Backpack",1242,1,0,0.7},
{"Ghillie Backpack",1253,1,0,0.8},
},
["other"] = {
{"Raw Meat",2804,0.5,90},
{"Cooked Meat",2806,0.5,90},
{"Full Gas Canister",1650,1,0},
{"Empty Water Bottle",2683,1,0},
{"Survivor Clothing",1247,2,0},
{"Night Vision Goggles",368,1,90},
{"Infrared Goggles",369,1,90},
{"1866 Slug",2358,2,0},
{"2Rnd. Slug",2358,2,0},
{"SPAZ-12 Pellet",2358,2,0},
{"MP5A5 Mag",2358,2,0},
{"AK Mag",327,2,0},
{"M4 Mag",327,2,0},
{"M1911 Mag",3013,2,0},
{"M9 SD Mag",3013,2,0},
{"Desert Eagle Mag",3013,2,0},
--{"M136 Rocket",3082,0.7,90},
{"CZ 550 Mag",2358,2,0},
{"Lee Enfield Mag",2358,2,0},
{"PDW Mag",2041,2,0},
{"MP5A5 Mag",2041,2,0},
{"Box of Matches",328,0.4,90,5},
{"Wood Pile",1463,0.4,0,5},
{"M1911",346,1,90,3.5},
{"PDW",352,1,90,2},
{"Hunting Knife",335,1,90,2.5},
{"Hatchet",339,1,90,1.8},
{"Pizza",1582,1,0,7},
{"Soda Bottle",2647,1,0,7},
{"Empty Gas Canister",1650,1,0,5},
{"Roadflare",324,1,90,6},
{"Milk",2856,1,0,5},
{"Assault Pack (ACU)",3026,1,0,6},
{"Painkiller",2709,3,0,7},
{"Empty Soda Cans",2673,0.5,0,12},
{"Scruffy Burgers",2675,0.5,0,12},
{"MP5A5",353,1,90,1.5},
{"Watch",2710,1,0,3},
{"Heat Pack",1576,5,0,6},
{"Wire Fence",933,0.25,0,1},
{"Lee Enfield",357,1,90,1.5},
{"Alice Pack",1248,1,0,1.5},
{"Legendary Backpack",1252,1,0,0.7},
{"Tire",1073,1,0,1},
{"Morphine",1579,1,0,2},
{"Blooded Woman",1247,2,0,3.5},
{"Map",1277,0.8,90,4},
{"Toolbox",2969,0.5,0,3},
{"Engine",929,0.3,0,3.5},
{"Tank Parts",929,0.3,0,3.6},
{"Winchester 1866",349,1,90,2},
{"Water Bottle",2683,1,0,4},
{"M9 SD",347,1,90,5},
{"Grenade",342,1,0,0.5},
{"Sawn-Off Shotgun",350,1,90,2},
{"SPAZ-12 Combat Shotgun",351,1,90,1.9},
{"Binoculars",369,1,0,4},
{"Camouflage Clothing",1247,2,0,4.5},
{"Bandit Clothing",1247,2,0,4.5},
{"Bandit Clothing 2",1247,2,0,4.5},
{"Anonymous Clothing",1247,2,0,4.5},
{"Camouflage Clothing F",1247,2,0,4.5},
{"Civilian Clothing F",1247,2,0,4.5},
{"Ghost Camouflage",1247,2,0,4.5},
{"Ghost Clothing",1247,2,0,4.5},
{"Ghillie Suit 1",1247,2,0,4.5},
{"Jungle Ghillie Suit",1247,2,0,4.5},
{"Jocker Suit",1247,2,0,4.5},
{"Isis Clothing",1247,2,0,4.5},
{"Rebel Terrorist",1247,2,0,4.5},
{"Ghillie Woman",1247,2,0,4.5},
{"Ghillie Suit 2",1247,2,0,4.5},
{"Bandit Clothing 3",1247,2,0,4.5},
{"Army Clothing",1247,2,0,4.5},
--{"TEC-9",372,1,90,4},
{"AK-47",355,1,90,0.9},
{"M136 Rocket Launcher",359,1,90,0},
{"Ghillie Suit",1213,2,0,0.01},
{"M4",356,1,90,0.9},
{"CZ 550",358,1,90,0.3},
{"Heat-Seeking RPG",360,1,90,0},
{"Bandage",1578,0.5,0,4},
{"Pasta Can",2770,1,0,5},
{"Beans Can",2601,1,0,6},
{"Burger",2768,1,0,2},
{"Tent",1279,1,0,0.5},
{"M1911",346,1,90,3},
{"Desert Eagle",348,1,90,3},
{"GPS",2976,0.15,0,1},
{"Medic Kit",2891,2.2,0},
{"Blood Bag",1580,1,0},
{"Radio Device",2966,0.5,0,5},
--{"Radio Amplifier",330,1,0,6},
--{"Thermal GPS",2976,0.2,0,1},
--{"GPS Jammer",2976,0.2,0,2},
{"Golf Club",333,1,90,1.9},
{"Baseball Bat",336,1,90,1.4},
{"Shovel",337,1,90,1.5},
{"Czech Backpack",1239,1,0,2}, 
{"OS Backpack",1240,1,0,0.4},
{"Coyote Backpack",1242,1,0,0.7},
{"Ghillie Backpack",1253,1,0,0.8},
},
}

weaponAmmoTable = {


--[[
["Pistol Ammo"] = {
{"Pistol",22},
{"Silenced Pistol",23},
{"Desert Eagle",24},
},
]]--


["M1911 Mag"] = {
{"M1911",22},
},

["M9 SD Mag"] = {
{"M9 SD",23},
},

["Desert Eagle Mag"] = {
{"Desert Eagle",24},
},


--[[
["Smg Ammo"] = {
{"Uzi",28},
{"TEC-9",32},
{"MP5",29},
},
]]--


["PDW Mag"] = {
{"PDW",28},
},

["MP5A5 Mag"] = {
{"MP5A5",29},
},


--[[["Assault Ammo"] = {
{"AK-47",30},
{"M4",31},
},
]]--


["AK Mag"] = {
{"AK-47",30},
},

["M4 Mag"] = {
{"M4",31},
},


--[[
["Shotgun Ammo"] = {
{"Shotgun",25},
{"Sawn-Off Shotgun",26},
{"SPAZ-12 Combat Shotgun",27},
},
]]--

["1866 Slug"] = {
{"Winchester 1866",25},
},

["2Rnd. Slug"] = {
{"Sawn-Off Shotgun",26},
},

["SPAZ-12 Pellet"] = {
{"SPAZ-12 Combat Shotgun",27},
},


--[[
["Sniper Ammo"] = {
{"Country Rifle",33},
{"Sniper Rifle",34},
},
]]--

["CZ 550 Mag"] = {
{"CZ 550",34},
},

["Lee Enfield Mag"] = {
{"Lee Enfield",33},
},


--[[
["Rocket Ammo"] = {
{"Heat-Seeking RPG",36},
{"Rocket Launcher",35},
},
]]--


["M136 Rocket"] = {
{"Heat-Seeking RPG",36},
{"M136 Rocket Launcher",35},
},


["others"] = {
{"Parachute",46},
{"Satchel",39},
{"Tear Gas",17},
{"Grenade",16},
{"Hunting Knife",4},
{"Hatchet",8},
{"Binoculars",43},
{"Baseball Bat",5},
{"Golf Club",2},
{"Shovel",6},
{"Radio Device",1},
--[[
{"Diary, Page 1",1},
{"Diary, Page 2",1},
{"Diary, Page 3",1},
{"Diary, Page 4",1},
{"Diary, Page 5",1},
{"Diary, Page 6",1},
{"Diary, Page 7",1},
{"Diary, Page 8",1},
{"Small Note 1",1},
{"Small Note 2",1},
{"Small Note 3",1},
{"Research Report 1",1},
{"Research Report 2",1},
{"Letter to Mum",1},
]]
},
}

function getWeaponAmmoType (weaponName,notOthers)
if not notOthers then
    for i,weaponData in ipairs(weaponAmmoTable["others"]) do
        if weaponName == weaponData[1] then
            return weaponData[1],weaponData[2]
        end
    end
end 
    for i,weaponData in ipairs(weaponAmmoTable["M1911 Mag"]) do
        if weaponName == weaponData[1] then
            return "M1911 Mag",weaponData[2]
        end
    end
    for i,weaponData in ipairs(weaponAmmoTable["M9 SD Mag"]) do
        if weaponName == weaponData[1] then
            return "M9 SD Mag",weaponData[2]
        end
    end
    for i,weaponData in ipairs(weaponAmmoTable["Desert Eagle Mag"]) do
        if weaponName == weaponData[1] then
            return "Desert Eagle Mag",weaponData[2]
        end
    end
    for i,weaponData in ipairs(weaponAmmoTable["PDW Mag"]) do
        if weaponName == weaponData[1] then
            return "PDW Mag",weaponData[2]
        end
    end
    for i,weaponData in ipairs(weaponAmmoTable["MP5A5 Mag"]) do
        if weaponName == weaponData[1] then
            return "MP5A5 Mag",weaponData[2]
        end
    end
    for i,weaponData in ipairs(weaponAmmoTable["AK Mag"]) do
        if weaponName == weaponData[1] then
            return "AK Mag",weaponData[2]
        end
    end
    for i,weaponData in ipairs(weaponAmmoTable["M4 Mag"]) do
        if weaponName == weaponData[1] then
            return "M4 Mag",weaponData[2]
        end
    end
    for i,weaponData in ipairs(weaponAmmoTable["1866 Slug"]) do
        if weaponName == weaponData[1] then
            return "1866 Slug",weaponData[2]
        end
    end
    for i,weaponData in ipairs(weaponAmmoTable["2Rnd. Slug"]) do
        if weaponName == weaponData[1] then
            return "2Rnd. Slug",weaponData[2]
        end
    end
    for i,weaponData in ipairs(weaponAmmoTable["SPAZ-12 Pellet"]) do
        if weaponName == weaponData[1] then
            return "SPAZ-12 Pellet",weaponData[2]
        end
    end
    for i,weaponData in ipairs(weaponAmmoTable["CZ 550 Mag"]) do
        if weaponName == weaponData[1] then
            return "CZ 550 Mag",weaponData[2]
        end
    end
    for i,weaponData in ipairs(weaponAmmoTable["Lee Enfield Mag"]) do
        if weaponName == weaponData[1] then
            return "Lee Enfield Mag",weaponData[2]
        end
    end
    for i,weaponData in ipairs(weaponAmmoTable["M136 Rocket"]) do
        if weaponName == weaponData[1] then
            return "M136 Rocket",weaponData[2]
        end
    end
    return false
end

function createItemPickup(item,x,y,z,tableStringName)
if item and x and y and z then
    local object = createObject(itemTable[tostring(tableStringName)][item][2],x,y,z-0.875,itemTable[tostring(tableStringName)][item][4],0,math.random(0,360))
    setObjectScale(object,itemTable[tostring(tableStringName)][item][3])
    setElementCollisionsEnabled(object, false)
    setElementFrozen (object,true)
    local col = createColSphere(x,y,z,0.75)
    setElementData(col,"item",itemTable[tostring(tableStringName)][item][1])
    setElementData(col,"parent",object)
    setTimer(function()
        if isElement(col) then
            destroyElement(col)
            destroyElement(object)
        end 
    end,900000,1)
    return object
end
end

function table.size(tab)
    local length = 0
    for _ in pairs(tab) do length = length + 1 end
    return length
end

function math.percentChance (percent,repeatTime)
local hits = 0
    for i = 1, repeatTime do
    local number = math.random(0,200)/2
        if number <= percent then
            hits = hits+1
        end
    end
    return hits
end

function createItemLoot (lootPlace,x,y,z,id)
    col = createColSphere(x,y,z,1.25)
    setElementData(col,"itemloot",true)
    setElementData(col,"parent",lootPlace)
    setElementData(col,"MAX_Slots",12)
    --Items
    for i, item in ipairs(itemTable[lootPlace]) do
        local value =  math.percentChance (item[5],math.random(1,2))
        setElementData(col,item[1],value)
        --weapon Ammo
        local ammoData,weapID = getWeaponAmmoType (item[1],true)
        if ammoData and value > 0 then
            setElementData(col,ammoData,math.random(1,2))
        end
    end
        --itemLoot
        refre:~emLoot (col,lootPlace)
        
        return col
end


function refre:~emLoot (col,place)
    local objects = getElementData(col,"objectsINloot")
        if objects then
            if objects[1] ~= nil then
                destroyElement(objects[1])
            end
            if objects[2] ~= nil then
                destroyElement(objects[2])
            end
            if objects[3] ~= nil then
                destroyElement(objects[3])
            end
        end
            --setting objects
            local counter = 0
            local obejctItem = {}
        --Tables
            for i, item in ipairs(itemTable["other"]) do
                if getElementData(col,item[1]) and getElementData(col,item[1]) > 0 then
                    if counter == 3 then
                        break
                    end 
                    counter = counter + 1
                    local x,y,z = getElementPosition(col)
                    obejctItem[counter] = createObject(item[2],x+math.random(-1,1),y+math.random(-1,1),z-0.875,item[4])
                    setObjectScale(obejctItem[counter],item[3])
                    setElementCollisionsEnabled(obejctItem[counter], false)
                    setElementFrozen (obejctItem[counter],true)
                end
            end
        -------Debug
            if obejctItem[1] == nil then
                local x,y,z = getElementPosition(col)
                    obejctItem[1] = createObject(1463,x+math.random(-1,1),y+math.random(-1,1),z-0.875,0)
                    setObjectScale(obejctItem[1],0)
                    setElementCollisionsEnabled(obejctItem[1], false)
                    setElementFrozen (obejctItem[1],true)
            end
            if obejctItem[2] == nil then
                local x,y,z = getElementPosition(col)
                    obejctItem[2] = createObject(1463,x+math.random(-1,1),y+math.random(-1,1),z-0.875,0)
                    setObjectScale(obejctItem[2],0)
                    setElementCollisionsEnabled(obejctItem[2], false)
                    setElementFrozen (obejctItem[2],true)
            end
            if obejctItem[3] == nil then
                local x,y,z = getElementPosition(col)
                    obejctItem[3] = createObject(1463,x+math.random(-1,1),y+math.random(-1,1),z-0.875,0)
                    setObjectScale(obejctItem[3],0)
                    setElementCollisionsEnabled(obejctItem[3], false)
                    setElementFrozen (obejctItem[3],true)
            end
            setElementData(col,"objectsINloot",{obejctItem[1], obejctItem[2], obejctItem[3]})
end
addEvent( "refre:~emLoot", true )
addEventHandler( "refre:~emLoot", getRootElement(), refre:~emLoot )

function createPickupsOnServerStart()
iPickup = 0
    for i,pos in ipairs(pickupPositions["residential"]) do
        iPickup = iPickup + 1
        createItemLoot("residential",pos[1],pos[2],pos[3],iPickup)
    end
    setTimer(createPickupsOnServerStart2,5000,1)
end

function createPickupsOnServerStart2()
    for i,pos in ipairs(pickupPositions["industrial"]) do
        iPickup = iPickup + 1
        createItemLoot("industrial",pos[1],pos[2],pos[3],iPickup)
    end
    setTimer(createPickupsOnServerStart3,5000,1)
end

function createPickupsOnServerStart3()
    for i,pos in ipairs(pickupPositions["farm"]) do
        iPickup = iPickup + 1
        createItemLoot("farm",pos[1],pos[2],pos[3],iPickup)
    end
    setTimer(createPickupsOnServerStart4,5000,1)
end

function createPickupsOnServerStart4()
    for i,pos in ipairs(pickupPositions["supermarket"]) do
        iPickup = iPickup + 1
        createItemLoot("supermarket",pos[1],pos[2],pos[3],iPickup)
    end
    setTimer(createPickupsOnServerStart5,5000,1)
end

function createPickupsOnServerStart5()
    for i,pos in ipairs(pickupPositions["military"]) do
        iPickup = iPickup + 1
        createItemLoot("military",pos[1],pos[2],pos[3],iPickup)
    end
end


createPickupsOnServerStart()

------------------------------------------------------------------------------
--OTHER ITEM STUFF
vehicleFuelTable = {
{422,60},
{603,60},
{541,60},
{411,90},
{429,60},
{470,80},
{468,30},
{433,90},
{437,90},
{490,60},
{487,60},
{497,60},
{593,60},
{453,60},
{560,60},
{451,60},
{522,60},
{562,60},
{542,60},
{410,60},
{489,40},
{402,60},
{546,60},
{602,60},
{568,40},
{495,50},
{400,60},
{596,60},
{520,60},
}

function getVehicleMaxFuel(loot)
    local modelID = getElementModel(getElementData(loot,"parent"))
    for i,vehicle in ipairs(vehicleFuelTable) do
        if modelID == vehicle[1] then
             return vehicle[2]
        end
    end
    return false
end
--[[
function onPlayerMoveItemOutOFInventory (itemName,loot)
local itemPlus = 1
if itemName == "Pistol Ammo" then
    itemPlus = 17
elseif itemName == "Smg Ammo" then
    itemPlus = 40
elseif itemName == "Assault Ammo" then
    itemPlus = 30
elseif itemName == "Sniper Ammo" then
    itemPlus = 10
elseif itemName == "Shotgun Ammo" then
    itemPlus = 7
elseif itemName == "M4" or itemName == "AK-47" or itemName == "Sniper Rifle" or itemName == "Shotgun" or itemName == "SPAZ-12 Combat Shotgun" or itemName == "Sawn-Off Shotgun" or itemName == "Heat-Seeking RPG" or itemName == "Rocket Launcher" or itemName == "Country Rifle" then
    removeBackWeaponOnDrop()
end
if loot then 
if not getElementData(loot,"itemloot") and getElementType(getElementData(loot,"parent")) == "vehicle" then
    if itemName == "Full Gas Canister" then
        if getElementData(loot,"fuel")+20 < getVehicleMaxFuel(loot) then
            addingfuel = 20
        elseif getElementData(loot,"fuel")+20 > getVehicleMaxFuel(loot)+15 then
            triggerClientEvent (source, "displayClientInfo", source,"Vehicle","The tank is full",255,22,0)
            return
        else
            addingfuel = getVehicleMaxFuel(loot)-getElementData(loot,"fuel")
        end
        setElementData(loot,"fuel",getElementData(loot,"fuel")+addingfuel)
        setElementData(source,itemName,getElementData(source,itemName)-itemPlus)
        setElementData(source,"Empty Gas Canister",(getElementData(source,"Empty Gas Canister") or 0)+itemPlus)
        triggerClientEvent (source, "displayClientInfo", source,"Vehicle","Filled up the vehicles Fuel",22,255,0)
        isVehicleReadyToStart2(getElementData(loot,"parent"))
        return
    end
end
end
itemName2 = itemName
if itemName == "Tire_inVehicle" then itemName2 = "Tire" end
if itemName == "Engine_inVehicle" then itemName2 = "Engine" end
if itemName == "Parts_inVehicle" then itemName2 = "Tank Parts" end
if (getElementData(source,itemName2) or 0)/itemPlus < 1 then
    triggerClientEvent (source, "displayClientInfo", source,"Inventory","You dont got a full Magazine to drop",255,22,0)
return
end
    if loot then
        setElementData(loot,itemName,(getElementData(loot,itemName) or 0)+1)
        onPlayerChangeLoot(loot)    
        if not getElementData(loot,"itemloot") and getElementType(getElementData(loot,"parent")) == "vehicle" then
            isVehicleReadyToStart2(getElementData(loot,"parent"))
        end
    else
        local x,y,z = getElementPosition(source)
        local item,itemString = getItemTablePosition(itemName)
        local itemPickup = createItemPickup(item,x+math.random(-1.25,1.25),y+math.random(-1.25,1.25),z,itemString)
    end
    if itemName == "Tire_inVehicle" then itemName = "Tire" end
    if itemName == "Engine_inVehicle" then itemName = "Engine" end
    if itemName == "Parts_inVehicle" then itemName = "Tank Parts" end
    setElementData(source,itemName,getElementData(source,itemName)-itemPlus)
    if loot and getElementData(loot,"itemloot") then
        refre:~emLoot (loot,getElementData(loot,"parent"))
    end
end
addEvent( "onPlayerMoveItemOutOFInventory", true )
addEventHandler( "onPlayerMoveItemOutOFInventory", getRootElement(), onPlayerMoveItemOutOFInventory )
]]
--[[
function onPlayerMoveItemInInventory (itemName,loot)
local itemPlus = 1
if itemName == "Pistol Ammo" then
    itemPlus = 17
elseif itemName == "Smg Ammo" then
    itemPlus = 40
elseif itemName == "Assault Ammo" then
    itemPlus = 30
elseif itemName == "Sniper Ammo" then
    itemPlus = 10
elseif itemName == "Shotgun Ammo" then
    itemPlus = 7
elseif itemName == "Small Backpack" then
    if getElementData(source,"MAX_Slots") == 16 then triggerClientEvent (source, "displayClientInfo", source,"Inventory","You allready got a Small Backpack",255,22,0) return end
    if getElementData(source,"MAX_Slots") == 28 then triggerClientEvent (source, "displayClientInfo", source,"Inventory","You allready got a bigger Backpack",255,22,0) return end
    setElementData(source,"MAX_Slots",16)
    setElementData(loot,itemName,getElementData(loot,itemName)-1)
    itemPlus = 0
elseif itemName == "Alice Backpack" then
    if getElementData(source,"MAX_Slots") == 28 then triggerClientEvent (source, "displayClientInfo", source,"Inventory","You allready got a Alice Backpack",255,22,0) return end
    if getElementData(source,"MAX_Slots") == 36 then triggerClientEvent (source, "displayClientInfo", source,"Inventory","You allready got a bigger Backpack",255,22,0) return end
    setElementData(source,"MAX_Slots",28)
    setElementData(loot,itemName,getElementData(loot,itemName)-1)
    itemPlus = 0
elseif itemName == "Coyote Backpack" then
    if getElementData(source,"MAX_Slots") == 50 then triggerClientEvent (source, "displayClientInfo", source,"Inventory","You allready got a Coyote Backpack",255,22,0) return end
    setElementData(source,"MAX_Slots",50)
    setElementData(loot,itemName,getElementData(loot,itemName)-1)
    itemPlus = 0    
elseif itemName == "Ghillie Backpack" then
    if getElementData(source,"MAX_Slots") == 70 then triggerClientEvent (source, "displayClientInfo", source,"Inventory","You allready got a Ghillie Backpack",255,22,0) return end
    if getElementData(source,"MAX_Slots") == 70 then triggerClientEvent (source, "displayClientInfo", source,"Inventory","You allready got a bigger Backpack",255,22,0) return end
    setElementData(source,"MAX_Slots",70)
    setElementData(loot,itemName,getElementData(loot,itemName)-1)
    itemPlus = 0
elseif itemName == "OS Backpack" then
    if getElementData(source,"MAX_Slots") == 90 then triggerClientEvent (source, "displayClientInfo", source,"Inventory","You allready got a OS Backpack",255,22,0) return end
    if getElementData(source,"MAX_Slots") == 90 then triggerClientEvent (source, "displayClientInfo", source,"Inventory","You allready got a bigger Backpack",255,22,0) return end
    setElementData(source,"MAX_Slots",90)
    setElementData(loot,itemName,getElementData(loot,itemName)-1)
    itemPlus = 0
elseif itemName == "Legendary Backpack" then
    if getElementData(source,"MAX_Slots") == 36 then triggerClientEvent (source, "displayClientInfo", source,"Inventory","You allready got a Legendary Backpack",255,22,0) return end
    setElementData(source,"MAX_Slots",36)
    setElementData(loot,itemName,getElementData(loot,itemName)-1)
    itemPlus = 0    
end
    if loot then
        --if itemPlus > (getElementData(loot,itemName) or 0) then
            --itemPlus = getElementData(loot,itemName) 
        --end
            setElementData(source,itemName,(getElementData(source,itemName) or 0)+itemPlus) 
            if itemPlus == 0 then
                setElementData(loot,itemName,getElementData(loot,itemName)-0)
            else
                setElementData(loot,itemName,getElementData(loot,itemName)-1)
            end
            onPlayerChangeLoot(loot)
    end
    if getElementData(loot,"itemloot") then
        refre:~emLoot (loot,getElementData(loot,"parent"))
    end
end
addEvent( "onPlayerMoveItemInInventory", true )
addEventHandler( "onPlayerMoveItemInInventory", getRootElement(), onPlayerMoveItemInInventory )
]]
function onPlayerTakeItemFromGround (itemName,col)
itemPlus = 1
if itemName == "M1911 Mag" then
    itemPlus = 7
elseif itemName == "M9 SD Mag" then
    itemPlus = 15
elseif itemName == "Desert Eagle Mag" then
    itemPlus = 7
elseif itemName == "PDW Mag" then
    itemPlus = 30
elseif itemName == "MP5A5 Mag" then
    itemPlus = 20
elseif itemName == "AK Mag" then
    itemPlus = 30
elseif itemName == "M4 Mag" then
    itemPlus = 20
elseif itemName == "1866 Slug" then
    itemPlus = 7
elseif itemName == "2Rnd. Slug" then
    itemPlus = 2
elseif itemName == "SPAZ-12 Pellet" then
    itemPlus = 7
elseif itemName == "CZ 550 Mag" then
    itemPlus = 5
elseif itemName == "Lee Enfield Mag" then
    itemPlus = 10
elseif itemName == "M136 Rocket" then
    itemPlus = 0
elseif itemName == "M4" or itemName == "AK-47" or itemName == "CZ 550" or itemName == "Winchester 1866" or itemName == "SPAZ-12 Combat Shotgun" or itemName == "Sawn-Off Shotgun" or itemName == "Heat-Seeking RPG" or itemName == "M136 Rocket Launcher" or itemName == "Lee Enfield" then
    removeBackWeaponOnDrop()    
end
    local x,y,z = getElementPosition(source)
    local id,ItemType = getItemTablePosition (itemName)
    setElementData(source,itemName,(getElementData(source,itemName) or 0)+itemPlus)
    destroyElement(getElementData(col,"parent"))
    destroyElement(col)
end
addEvent( "onPlayerTakeItemFromGround", true )
addEventHandler( "onPlayerTakeItemFromGround", getRootElement(), onPlayerTakeItemFromGround )

function onPlayerChangeLoot(loot)
local players = getElementsWithinColShape (loot,"player")
    for theKey,player in ipairs(players) do 
        triggerClientEvent(player,"refreshLootManual",player,loot)
    end 
end
addEvent( "onPlayerChangeLoot", true )
addEventHandler( "onPlayerChangeLoot", getRootElement(), onPlayerChangeLoot )

function playerDropAItem(itemName)
        local x,y,z = getElementPosition(source)
        local item,itemString = getItemTablePosition(itemName)
        local itemPickup = createItemPickup(item,x+math.random(-1.25,1.25),y+math.random(-1.25,1.25),z,itemString)
end
addEvent( "playerDropAItem", true )
addEventHandler( "playerDropAItem", getRootElement(), playerDropAItem )

function getItemTablePosition (itema)
for id, item in ipairs(itemTable[tostring("other")]) do
if itema == item[1] then
    return id,"other"
end
end

return item,itemString
end

function refre:~emLoots ()
    outputChatBox("#ffaa00WARNING! #ffffff - SPAWNPOINTS FOR ITEMS ARE BEING REFRESHED! BEWARE OF MASSIVE LAG!",getRootElement(),255,255,255,true)
    for i, loots in ipairs(getElementsByType("colshape")) do
        local itemloot = getElementData(loots,"itemloot")
        if itemloot then
        local objects = getElementData(loots,"objectsINloot")
        if objects then
            if objects[1] ~= nil then
                destroyElement(objects[1])
            end
            if objects[2] ~= nil then
                destroyElement(objects[2])
            end
            if objects[3] ~= nil then
                destroyElement(objects[3])
            end
        end
            destroyElement(loots)
        end 
    end
    createPickupsOnServerStart()
    setTimer(refre:~emLootPoints,gameplayVariables["itemrespawntimer"] ,1)
end


--Refresh items
function refre:~emLootPoints ()
local time = getRealTime()
local hour = time.hour
        outputChatBox("#ff2200WARNING! #ffffff - SPAWNPOINTS FOR ITEMS WILL BE REFRESHED IN 1 MINUTE! BEWARE OF MASSIVE LAG!",getRootElement(),255,255,255,true)
        setTimer(refre:~emLoots,60000,1)
end
setTimer(refre:~emLootPoints,gameplayVariables["itemrespawntimer"] ,1)

 

Link to post

You have an deprecated old copy of DayZ and the table structure is not the best (you loop through too many tables in a short period of time), that takes to much resources to load all items and server stops the script as that take way to much.

Your table structure is like this:

tableName = {

["WEAPON_MAG"] = {info1, info2, info3},

["WEAPON_MAG"] = {info1, info2, info3},

etc...

};

Searching in eatch table if  WEAPON_MAG == yourIndex and return WEAPON_MAG and info2 way to complicated for what you really need!

you'd better do something like this:

tableName  = {

{"WEAPON_MAG", info1, info2, info3}, 

{"WEAPON_MAG", info1, info2, info3},

etc...

};

Search if v[1] == yourindex then return v[1], v[2] way better, cleaner and simpler! And you will only have to loop through one single table!

That will be a little work and you might have to change some other scripts!

 

I WON'T do it for you it's your duty to learn! ;) Good luck, if you have questions feel free.

Link to post

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...