look i put all code here u can check
local weaponAmmoTable = {
["Weapons"] ={
{"M1911 Mag", "M1911", 22, 346},
{"M9 SD Mag", "M9 SD", 23, 347},
{"Desert Eagle Mag", "Desert Eagle", 24, 348},
{"PDW Mag", "PDW", 28, 352},
{"MP5A5 Mag", "MP5A5", 29, 353},
{"AKS-74U Mag", "AKS-74U", 31, 1839},
{"AK-107 Mag", "AK-107", 31, 1834},
{"AKS Gold Mag", "AKS Gold", 31, 1835},
{"M4A1 Holo Mag", "M4A1 Holo", 31, 1830},
{"MK 48 Mod 0 Mag", "MK 48 Mod 0", 30, 1880},
{"MG36 Mag", "MG36", 30, 1832},
{"PKP Mag", "PKP", 30, 1833},
{"SA-58V ACOG Mag", "SA-58V ACOG", 31, 1838},
{"1866 Slug", "Winchester 1866", 25, 349},
{"2Rnd. Slug", "Sawn-Off Shotgun", 26, 350},
{"SPAZ-12 Pellet", "SPAZ-12 Combat Shotgun", 27, 351},
{"DMR Mag", "DMR", 34, 1869},
{"KVSK Mag", "KVSK", 34, 1870},
{"AS50 Mag", "AS50", 34, 1871},
{"CZ550 Mag", "CZ550", 34, 1872},
{"Mosin 9130 Mag", "Mosin 9130", 34, 1873},
{"M24 Mag", "M24", 34, 1874},
{"M107 Mag", "M107", 34, 1875},
{"SVD Dragunov Camo Mag", "SVD Dragunov Camo", 34, 1876},
{"SKS-45 Mag", "SKS-45", 33, 357}
},
["others"] = {
{"Tear Gas", 17, 343, "Tear Gas (Equipped)"},
{"Grenade", 16, 342, "Grenade (Equipped)"},
{"Hunting Knife", 4, 335, "Hunting Knife (Equipped)"},
{"Hatchet", 8, 339, "Hatchet (Equipped)"},
{"Binoculars", 43, 367, "Binoculars (Equipped)"},
{"Baseball Bat", 5, 336, "Baseball Bat (Equipped)"},
{"Shovel", 6, 337, "Shovel (Equipped)"},
{"Golf Club", 2, 333, "Golf Club (Equipped)"}
}
};
function getWeaponAmmoType(name)
for _,v in ipairs(weaponAmmoTable["Weapons"]) do
if (name == v[2]) then return v[1], v[3], v[4]; end
end
for _,v in ipairs(weaponAmmoTable["others"]) do
if (name == v[1]) then return v[4], v[2], v[3]; end
end
return false, false, false;
end
local skinTable = {
{"Camouflage Clothing", 287},
{"Spec.Force Sniper Clothing", 83},
{"Civilian Clothing", 179},
{"Ghillie Suit", 285},
{"Survivor Clothing", 73}
};
local animalsSpawns = {
{-1350.775390625, -1070.8291015625, 160.71176147461},
{-1369.1123046875, -1094.70703125, 163.45556640625},
{-1431.8876953125, -1093.189453125, 162.88122558594},
{-1456.1787109375, -1064.6630859375, 168.23822021484},
{-1483.6357421875, -1024.376953125, 170.4222869873},
{-1468.3408203125, -988.3291015625, 192.51156616211},
{-1431.3173828125, -934.0478515625, 201.39248657227},
{-1577.904296875, -1020.0693359375, 143.08142089844},
{-1587.375, -1018.236328125, 141.72036743164},
{-1590.380859375, -1040.8505859375, 134.61396789551},
{-1581.958984375, -1072.4111328125, 133.2043762207},
{-1584.595703125, -1106.2001953125, 138.63221740723},
{-1550.591796875, -1137.1181640625, 136.79585266113},
{-1498.1083984375, -1180.9814453125, 125.67600250244},
{-1428.4541015625, -1225.892578125, 106.43696594238},
{-411.271484375, -1338.080078125, 25.689184188843},
{-373.59375, -1307.2568359375, 26.628273010254},
{-372.1689453125, -1259.75, 31.759468078613},
{-393.7333984375, -1195.427734375, 60.393005371094},
{-417.9150390625, -1180.4599609375, 63.334930419922},
{-433.0888671875, -1156.3349609375, 61.920516967773},
{-336.744140625, -1267.5693359375, 23.735641479492},
{-303.19140625, -1275.9599609375, 10.24838924408},
{-233.025390625, -1235.2373046875, 6.5470447540283},
{-193.0166015625, -1232.7568359375, 10.130974769592},
{-176.25, -1223.6298828125, 8.0039596557617},
{-166.5498046875, -1286.111328125, 3.5691347122192},
{-969.5048828125, -1738.703125, 77.557479858398},
{-966.748046875, -1776.2470703125, 80.165809631348},
{-976.7177734375, -1808.9462890625, 90.694877624512},
{-978.0849609375, -1827.4521484375, 93.413543701172},
{-986.23046875, -1855.9130859375, 85.224227905273},
{-1095.68359375, -1869.5302734375, 86.347923278809},
{-1168.853515625, -1864.869140625, 79.263336181641},
{-1221.1416015625, -1859.6591796875, 76.356552124023},
{-650.044921875, -2077.580078125, 28.14298248291},
{-632.34765625, -2062.50390625, 32.527751922607},
{-537.833984375, -1992.03515625, 47.49878692627},
{-498.4375, -1957.61328125, 38.346961975098}
};
local weatherTable = {
[1] = 5,
[2] = 8,
[3] = 7,
[4] = 10
};
local backpackSlots = {
["NTS"] = {
["Violet Taloon Backpack"] = 58,
["Hunting Backpack"] = 44,
["Coyote Backpack"] = 36,
["Czech Backpack"] = 26,
["Alice Pack"] = 16,
["Assault Pack (ACU)"] = 12
},
["STN"] = {
[58] = "Violet Taloon Backpack",
[44] = "Hunting Backpack",
[36] = "Coyote Backpack",
[26] = "Czech Backpack",
[16] = "Alice Pack",
[12] = "Assault Pack (ACU)"
}
};
local elementBackpack = {};
local elementWeaponBack = {};
local elementWeaponBack2 = {};
local elementWeaponRaplace = {};
local handsUp = false;
local siting = false;
local lying = false;
addEvent("relWep", true);
addEvent("createDeadAnimal", true);
addEvent("onPlayerHideBody", true);
addEvent("onPlayerRearmWeapon", true);
addEvent("removeBackWeaponOnDrop", true);
addEvent("kilLDayZPlayer", true);
addEvent("onPlayerRequestChangingStats", true);
addEvent("onPlayerUseMedicObject", true);
addEvent("onPlayerGiveMedicObject", true);
addEvent("onPlayerChangeSkin", true);
addEvent("onPlayerRefillWaterBottle", true);
addEvent("onPlayerPitchATent", true);
addEvent("onPlayerBuildAWireFence", true);
addEvent("removeWirefence", true);
addEvent("addPlayerCookMeat", true);
addEvent("removeTent" ,true);
addEvent("onPlayerMakeAFire", true);
addEvent("onPlayerPlaceRoadflare", true);
addEvent("kickPlayerOnHighPing", true);
addEvent("onPlayerEquipBackpack", true);
addEvent("onPlayerUnequipWeapon", true);
addEventHandler("onResourceStart", resourceRoot, function()
setGameType("United DayZ LT#1"); --[[ Multi Theft Auto DayZ Revision 3 ]]
local realTime = getRealTime();
setTime(realTime.hour, realTime.minute);
setMinuteDuration(60000);
setFarClipDistance(600);
setFogDistance(300);
setTrafficLightState("disabled");
setTimer(setTrafficLightState, 10000, 0, "disabled");
setWeaponProperty(30, "pro", "maximum_clip_ammo", 100);
setWeaponProperty(30, "std", "maximum_clip_ammo", 100);
setWeaponProperty(30, "poor", "maximum_clip_ammo", 100);
setWeaponProperty(31, "pro", "maximum_clip_ammo", 30);
setWeaponProperty(31, "std", "maximum_clip_ammo", 30);
setWeaponProperty(31, "poor", "maximum_clip_ammo", 30);
setWeaponProperty(29, "pro", "maximum_clip_ammo", 20);
setWeaponProperty(29, "std", "maximum_clip_ammo", 20);
setWeaponProperty(29, "poor", "maximum_clip_ammo", 20);
end);
function getBackpackNameFromSlots(slots)
if (slots > 8) then
return backpackSlots["STN"][slots];
end
return "None";
end
function getBackpackSlotsFromName(name)
if name then
return backpackSlots["NTS"][name];
end
return false;
end
function removeBackpack(source)
if elementBackpack[source] then
detachElementFromBone(elementBackpack[source]);
destroyElement(elementBackpack[source]);
elementBackpack[source] = false;
setElementData(source, "tohide2", "NONE");
end
end
function removeWeaponBack(source)
if elementWeaponBack[source] then
detachElementFromBone(elementWeaponBack[source]);
destroyElement(elementWeaponBack[source]);
elementWeaponBack[source] = false;
setElementData(source, "tohide3", "NONE");
end
end
function removeWeaponBack2(source)
if elementWeaponBack2[source] then
detachElementFromBone(elementWeaponBack2[source]);
destroyElement(elementWeaponBack2[source]);
elementWeaponBack2[source] = false;
setElementData(source, "tohide4", "NONE");
end
end
function removeWeaponReplace(source)
if elementWeaponRaplace[source] then
detachElementFromBone(elementWeaponRaplace[source]);
destroyElement(elementWeaponRaplace[source]);
elementWeaponRaplace[source] = false;
setElementData(source, "tohide1", "NONE");
end
end
addEventHandler("onPlayerEquipBackpack", root, function(backpack)
local nSlots = getBackpackSlotsFromName(backpack);
local oSlots = getElementData(source, "MAX_Slots");
if (nSlots > oSlots) then
setElementData(source, "MAX_Slots", nSlots);
setElementData(source, backpack, getElementData(source, backpack) - 1);
local oName = getBackpackNameFromSlots(oSlots);
setElementData(source, oName, getElementData(source, oName) + 1);
triggerClientEvent(source, "refreshInventoryManual", source);
else
triggerClientEvent(source, "displayClientInfo", source, "You already have a biger or equal backpack!", 255, 22, 0);
end
end);
addEventHandler("onPlayerUnequipWeapon", root, function(eweapon, slot)
local weap = getElementData(source, "currentweapon_"..tostring(slot));
local name,id,model = getWeaponAmmoType(weap);
takeWeapon(source, id);
if (slot < 3) then
setElementData(source, weap, getElementData(source, weap) + 1);
setElementData(source, eweapon, getElementData(source, eweapon) - 1);
setElementData(source, "currentweapon_"..tostring(slot), "");
if (slot == 1) then
removeWeaponBack(source);
removeWeaponReplace(source);
else
removeWeaponBack2(source);
end
else
setElementData(source, weap, getElementData(source, weap.." (Equipped)"));
setElementData(source, eweapon, 0);
setElementData(source, "currentweapon_"..tostring(slot), "");
end
triggerClientEvent(source, "refreshInventoryManual", source);
end);
addEventHandler("onPlayerRearmWeapon", root, function(weapon, slot)
takeAllWeapons(source);
local wAmmo,id,_ = getWeaponAmmoType(weapon);
local ammos = wAmmo;
if (id ~= 8 or id ~= 5 or id ~= 6 or id ~= 2) then
ammos = 1;
end
if (slot < 3 and ammos < 1) then
triggerClientEvent(source, "displayClientInfo", source, "No mags left for this weapon!", 255, 22, 0);
else
local old = getElementData(source, "currentweapon_"..tostring(slot));
if (weapon == old) then
equipThem(source, slot);
return;
end
if (slot < 3) then
if (old ~= "") then
setElementData(source, old, getElementData(source, old) + 1);
setElementData(source, old.." (Equipped)", 0);
end
setElementData(source, weapon, getElementData(source, weapon) - 1);
setElementData(source, weapon.." (Equipped)", 1);
setElementData(source, "currentweapon_"..tostring(slot), weapon);
else
if (old ~= "") then
local oldq = getElementData(source, old);
if (oldq > 0) then
setElementData(source, old, oldq);
end
end
setElementData(source, weapon.." (Equipped)", getElementData(source, weapon));
setElementData(source, "currentweapon_"..tostring(slot), weapon);
setElementData(source, weapon, 0);
end
end
triggerClientEvent(source, "refreshInventoryManual", source);
equipThem(source, slot);
end);
function equipThem(player, slot)
removeWeaponBack(player);
removeWeaponBack2(player);
removeWeaponReplace(player);
for i = 1, 3 do
local weapon = getElementData(player, "currentweapon_"..tostring(i));
if (weapon ~= "") then
if (i == slot) then bool = true; else bool = false; end
local ammo,id,_ = getWeaponAmmoType(weapon);
if (i == 3) then
giveWeapon(player, id, getElementData(player, weapon.." (Equipped)"), bool);
else
if (id == 8) then
giveWeapon(player, id, 1, bool);
else
local wam = getElementData(player, ammo);
giveWeapon(player, id, wam, bool);
setWeaponAmmo(player, id, wam);
end
end
end
end
if (slot == 1) then
local weap2 = getElementData(player, "currentweapon_2");
if (weap2 ~= "") then
local _,id,model2 = getWeaponAmmoType(weap2);
if model2 then
attachWeaponBack2(player, model2, id);
end
end
elseif (slot == 2) then
local weap1 = getElementData(player, "currentweapon_1");
if (weap1 ~= "") then
local _,_,model1 = getWeaponAmmoType(weap1);
if model1 then
attachWeaponBack(player, model1);
end
end
else
local weap1 = getElementData(player, "currentweapon_1");
if (weap1 ~= "") then
local _,_,model1 = getWeaponAmmoType(weap1);
if model1 then
attachWeaponBack(player, model1);
end
end
local weap2 = getElementData(player, "currentweapon_2");
if (weap2 ~= "") then
local _,id,model2 = getWeaponAmmoType(weap2);
if model2 then
attachWeaponBack2(player, model2, id);
end
end
if (slot == 0) then
setPedWeaponSlot(player, 0);
end
end
end
function attachWeaponReplace(source, model)
removeWeaponReplace(source);
local x,y,z = getElementPosition(source);
if (model > 1000) then
elementWeaponRaplace[source] = createObject(model, x, y, z);
if elementWeaponRaplace[source] then
setElementData(source, "tohide1", elementWeaponRaplace[source]);
end
if elementBackpack[source] then
attachElementToBone(elementWeaponRaplace[source], source, 12, 0, 0, 0, 180, 90, 180);
else
attachElementToBone(elementWeaponRaplace[source], source, 12, 0, 0, 0, 180, 90, 180);
end
end
end
function attachWeaponBack(source, model)
removeWeaponBack(source);
local x,y,z = getElementPosition(source);
elementWeaponBack[source] = createObject(model, x, y, z);
if elementWeaponBack[source] then
setObjectScale(elementWeaponBack[source], 0.8);
setElementData(source, "tohide3", elementWeaponBack[source]);
end
if elementBackpack[source] then
attachElementToBone(elementWeaponBack[source], source, 3, 0.19, -0.31, -0.1, 0, 270, -90);
else
attachElementToBone(elementWeaponBack[source], source, 3, 0.19, -0.11, -0.1, 0, 270, 10);
end
end
function attachWeaponBack2(source, model, id)
removeWeaponBack2(source);
local x,y,z = getElementPosition(source);
elementWeaponBack2[source] = createObject(model, x, y, z);
if elementWeaponBack2[source] then
setObjectScale(elementWeaponBack2[source], 1);
if (id == 6) then
setObjectScale(elementWeaponBack2[source], 0.7);
elseif (id == 8) then
setObjectScale(elementWeaponBack2[source], 0.8);
end
setElementData(source, "tohide4", elementWeaponBack2[source]);
end
if elementBackpack[source] then
if (id == 8) then
attachElementToBone(elementWeaponBack2[source], source, 3, -0.18, -0.12, 0.22, 180, 0, -90);
elseif (id == 2 or id == 4 or id == 6 or id == 5) then
attachElementToBone(elementWeaponBack2[source], source, 3, -0.18, -0.18, -0.1, 0, 0, -90);
else
attachElementToBone(elementWeaponBack2[source], source, 3, -0.18, -0.31, -0.1, 0, 270, -90);
end
else
if (id == 8) then
attachElementToBone(elementWeaponBack2[source], source, 3, -0.07 -0.14, -0.1, -0.1, 0, -8);
elseif (id == 2 or id == 4) then
attachElementToBone(elementWeaponBack2[source], source, 3, -0.20, -0.11, -0.1, -0.1, 0, -11);
elseif (id == 6 or id == 5) then
attachElementToBone(elementWeaponBack2[source], source, 3, -0.15, -0.11, -0.1, -0.1, 0, 70);
else
attachElementToBone(elementWeaponBack2[source], source, 3, -0.22, -0.11, -0.1, -0.1, -270, -11);
end
end
end
addEventHandler("onPlayerWeaponSwitch", root, function(previousWeaponID, currentWeaponID)
local weapon = getElementData(source, "currentweapon_1");
local weapon2 = getElementData(source, "currentweapon_2");
if not weapon then return; end
local _,weapID,model = getWeaponAmmoType(weapon);
if (currentWeaponID == weapID) then
removeWeaponBack(source);
attachWeaponReplace(source, model);
elseif (previousWeaponID == weapID) then
removeWeaponReplace(source);
attachWeaponBack(source, model);
end
if not weapon2 then return; end
local _,id2,model2 = getWeaponAmmoType(weapon2);
if (previousWeaponID == id2) then
attachWeaponBack2(source, model2, id2);
elseif (currentWeaponID == id2) then
removeWeaponBack2(source);
end
end);
addEventHandler("removeBackWeaponOnDrop", root, function(check, slot)
if (slot == 1) then
removeWeaponBack(source);
removeWeaponReplace(source);
elseif (slot == 2) then
removeWeaponBack2(source);
end
if check then
local weapon = getElementData(source, "currentweapon_"..tostring(slot));
local _,id,_ = getWeaponAmmoType(weapon);
takeWeapon(source, id);
if (slot == 3) then
takeWeapon(client, id);
local weapon = getElementData(client, "currentweapon_3");
if weapon then
setElementData(client, weapon.." (Equipped)", getElementData(client, weapon.." (Equipped)") - 1);
setElementData(client, "currentweapon_3", "");
end
end
setElementData(source, "currentweapon_"..tostring(slot), "");
triggerClientEvent(source, "refreshInventoryManual", source);
end
end);
addEventHandler("onPlayerQuit", root, function()
removeBackpack(source);
removeWeaponBack(source);
removeWeaponReplace(source);
removeWeaponBack2(source);
end);
addEventHandler("kilLDayZPlayer", root, function()
removeBackpack(source);
removeWeaponBack(source);
removeWeaponReplace(source);
removeWeaponBack2(source);
end);
addEventHandler("onElementDataChange", root, function(dataName, oldValue)
if not oldValue then oldValue = 0; end
if (getElementType(source) == "player") then
if (dataName == "MAX_Slots") then
local newValue = getElementData(source, dataName);
removeBackpack(source);
local x,y,z = getElementPosition(source);
if (newValue == 12) then elementBackpack[source] = createObject(3026, x, y, z); -- Assault Pack (ACU)
elseif (newValue == 16) then elementBackpack[source] = createObject(1248, x, y, z); -- Alice Pack
elseif (newValue == 26) then elementBackpack[source] = createObject(1575, x, y, z); -- Czech Backpack
elseif (newValue == 36) then elementBackpack[source] = createObject(1252, x, y, z); -- Coyote Backpack
elseif (newValue == 44) then elementBackpack[source] = createObject(2734, x, y, z); -- Hunting Backpack
elseif (newValue >= 58) then elementBackpack[source] = createObject(371, x, y, z); -- violet Backpack
elseif (newValue == 8) then return; end
if elementBackpack[source] then
setElementData(source, "tohide2", elementBackpack[source]);
if (newValue >= 58) then
setObjectScale(elementBackpack[source], 0.95);
end
end
if (newValue == 26) then
attachElementToBone(elementBackpack[source], source, 3, 0, -0.16, 0.05, 270, 0, 180);
else
attachElementToBone(elementBackpack[source], source, 3, 0, -0.225, 0.05, 90, 0, 0);
end
elseif (dataName == "Map") then
if (getElementData(source, "Map") >= 1) then
toggleControl(source, "radar", true);
else
toggleControl(source, "radar", false);
end
elseif (dataName == "GPS") then
if (getElementData(source, "GPS") >= 1) then
setPlayerHudComponentVisible(source, "radar", true);
else
setPlayerHudComponentVisible(source, "radar", false);
end
end
local weapon1 = getElementData(source, "currentweapon_1");
local weapon2 = getElementData(source, "currentweapon_2");
local weapon3 = getElementData(source, "currentweapon_3");
if (dataName == weapon1 or dataName == weapon2 or dataName == weapon3) then
if (getElementData(source, dataName) == 0) then
local ammoData,weapID = getWeaponAmmoType(dataName);
takeWeapon(source, weapID);
end
end
local ammoData1,weapID1 = getWeaponAmmoType(weapon1);
if (dataName == ammoData1) then
local newammo = (oldValue-getElementData(source, dataName));
if (newammo == 1) then return; end
if (getElementData(source, dataName) < oldValue) then
takeWeapon(source, weapID1, newammo);
removeWeaponBack(source);
elseif (getElementData(source, dataName) > oldValue) then
giveWeapon(source, weapID1, getElementData(source, dataName)-oldValue, false);
end
end
local ammoData2,weapID2 = getWeaponAmmoType(weapon2);
if (dataName == ammoData2) then
local newammo = oldValue-getElementData(source, dataName);
if (newammo == 1) then return; end
if (getElementData(source, dataName) < oldValue) then
takeWeapon(source, weapID2, newammo);
elseif (getElementData(source,dataName) > oldValue) then
giveWeapon(source, weapID2, getElementData(source, dataName)-oldValue, false);
end
end
local ammoData3,weapID3 = getWeaponAmmoType(weapon3);
if (dataName == ammoData3) then
local newammo = oldValue-getElementData(source, dataName);
if (newammo == 1) then return; end
if (getElementData(source, dataName) < oldValue) then
takeWeapon(source, weapID3, newammo);
elseif (getElementData(source, dataName) > oldValue) then
giveWeapon(source, weapID3, getElementData(source, dataName)-oldValue, false);
end
end
end
end);
addEventHandler("onPlayerStealthKill", root, function(target)
if (target and getElementType(target) == "player") then
triggerEvent("kilLDayZPlayer", target, source, false, false);
end
end);
function addPlayerStats(player, data, value)
if (data == "food") then
local current = getElementData(player, data);
if (current + value > 100) then
setElementData(player, data, 100);
elseif (current + value < 1) then
setElementData(player, data, 0);
setElementData(player, "blood", (getElementData(player, "blood") - math.random(50, 120)));
else
setElementData(player, data, (current + value));
end
elseif (data == "thirst") then
local current = getElementData(player, data);
if (current + value > 100) then
setElementData(player, data, 100);
elseif (current + value < 1) then
setElementData(player, data, 0);
setElementData(player, "blood", (getElementData(player, "blood") - math.random(50, 120)));
else
setElementData(player, data, (current + value));
end
elseif (data == "blood") then
local current = getElementData(player, data);
if (current + value > 12000) then
setElementData(player, data, 12000);
elseif (current + value < 1) then
setElementData(player, data, 0);
else
setElementData(player, data, (current + value));
end
elseif (data == "temperature") then
local current = getElementData(player, data);
if (current + value > 41) then
setElementData(player, data, 41);
elseif (current + value <= 31) then
setElementData(player, data, 31);
else
setElementData(player, data, (current + value));
end
elseif (data == "humanity") then
local current = getElementData(player, data);
local new = current + value;
if (new > 5000) then
setElementData(player, data, 5000);
setElementData(player, "htype", "Hero");
else
setElementData(player, data, new);
if (new <= 0) then
setElementData(player, "htype", "Bandit");
elseif new >= 2000 then
setElementData(player, "htype", "Survivor");
end
end
end
end
setTimer(function()
for _,v in ipairs(getElementsByType("player")) do
if getElementData(v, "logedin") then
local value = 0;
if isElementInWater(v) then
value = -0.01;
end
if getControlState(v, "sprint") then
value = (value + 0.005);
addPlayerStats(v, "thirst", -0.2);
end
local weather = getWeather();
if (weather == 5) then
value = (value + 0.005);
elseif (weather == 8) then
value = (value - 0.05);
elseif (weather == 7) then
value = (value - 0.01);
elseif (weather == 10) then
value = (value + 0.05);
end
if (getElementData(v, "humanity") < 2500) then
addPlayerStats(v, "humanity", 30);
end
addPlayerStats(v, "temperature", value);
addPlayerStats(v, "food", -1.5);
addPlayerStats(v, "thirst", -1.5);
end
end
end, 60000, 0);
addEventHandler("onPlayerRequestChangingStats", root, function(itemName, itemInfo, data)
if (data == "food") then
if (itemName == "Burger") then blood = math.random(200, 300);
elseif (itemName == "Pizza") then blood = math.random(300, 350);
elseif (itemName == "Cooked Meat") then blood = math.random(600, 800);
elseif (itemName == "Beans Can") then blood = math.random(150, 250);
elseif (itemName == "Pasta Can") then blood = math.random(320, 400); end
setPedAnimation(source, "FOOD", "EAT_Burger", -1, false, false, nil, false);
setElementData(source, itemName, getElementData(source, itemName)-1);
addPlayerStats(source, "blood", blood);
addPlayerStats(source, data, math.random(60, 100));
elseif (data == "thirst") then
setElementData(source, itemName, getElementData(source, itemName)-1);
addPlayerStats(source, data, math.random(60, 100));
setPedAnimation(source, "VENDING", "VEND_Drink2_P", -1, false, false, nil, false);
if (itemName == "Water Bottle") then
setElementData(source, "Empty Water Bottle", getElementData(source, "Empty Water Bottle") + 1);
end
end
triggerClientEvent(source, "displayClientInfo", source, "You consumed "..itemName, 22, 255, 0);
triggerClientEvent(source, "refreshInventoryManual", source);
end);
addEventHandler("onPlayerUseMedicObject", root, function(itemName)
setPedAnimation(source, "BOMBER", "BOM_Plant", -1, false, false, nil, false);
setTimer(function(source)
if (itemName == "Bandage") then
setElementData(source, "bleeding", 0);
setElementData(source, itemName, getElementData(source, itemName) - 1);
elseif (itemName == "Medic Kit") then
addPlayerStats(source, "blood", 7000);
setElementData(source, "bleeding", 0);
setElementData(source, itemName, getElementData(source, itemName) - 1);
elseif (itemName == "Heat Pack") then
setElementData(source, "cold", false);
setElementData(source, "temperature", 37);
setElementData(source, itemName, getElementData(source, itemName) - 1);
elseif (itemName == "Painkiller") then
setElementData(source, "pain", false);
setElementData(source, itemName, getElementData(source, itemName) - 1);
elseif (itemName == "Morphine") then
setElementData(source, "brokenbone", false)
setElementData(source, itemName, getElementData(source, itemName) - 1);
elseif (itemName == "Blood Bag") then
addPlayerStats(source, "blood", 12000);
setElementData(source, itemName, getElementData(source, itemName) - 1);
end
triggerClientEvent(source, "refreshInventoryManual", source);
end, 1500, 1, source);
end);
addEventHandler("onPlayerGiveMedicObject", root, function(itemName, player)
setPedAnimation(source, "BOMBER", "BOM_Plant", -1, false, false, nil, false);
setTimer(function(source)
if (itemName == "givebandage") then
setElementData(player, "bleeding", 0);
setElementData(source, "Bandage", getElementData(source, "Bandage") - 1);
addPlayerStats(source, "humanity", 40);
elseif (itemName == "giveblood") then
addPlayerStats(player, "blood", 12000);
setElementData(source, "Blood Bag", getElementData(source, "Blood Bag") - 1);
addPlayerStats(source, "humanity", 250);
end
triggerClientEvent(source, "refreshInventoryManual", source);
end, 1500, 1, source);
end);
function getSkinIDFromName(name)
for _,v in ipairs(skinTable) do
if (name == v[1]) then return v[2]; end
end
end
function getSkinNameFromID(id)
for _,v in ipairs(skinTable) do
if (id == v[2]) then return v[1]; end
end
end
addEventHandler("onPlayerChangeSkin", root, function(skin)
local name = getSkinNameFromID(getElementData(source, "skin"));
setElementData(source, name, getElementData(source, name)+1);
setElementData(source, skin, getElementData(source, skin)-1);
local id = getSkinIDFromName(skin);
setElementData(source, "skin", id);
setElementModel(source, id);
triggerClientEvent(source, "refreshInventoryManual", source);
end);
addEventHandler("onPlayerRefillWaterBottle", root, function(itemName)
if isElementInWater(source) then
setElementData(source, "Water Bottle", getElementData(source, "Water Bottle") + 1);
setElementData(source, itemName, getElementData(source, itemName) - 1);
triggerClientEvent(source, "refreshInventoryManual", source);
triggerClientEvent(source, "displayClientInfo", source, "You filled 1 x "..itemName, 22, 255, 0);
else
triggerClientEvent(source, "displayClientInfo", source, "You must be in water!", 255, 22, 0);
end
end);
addEventHandler("onPlayerPitchATent", root, function(itemName)
setElementData(source, itemName, getElementData(source, itemName) - 1);
setPedAnimation(source, "BOMBER", "BOM_Plant", -1, false, false, nil, false);
setTimer(function(source)
local x,y,z = getElementPosition(source);
local xr,yr,zr = getElementRotation(source);
local offsetRot = math.rad(zr+90);
local vx = x+5*math.cos(offsetRot);
local vy = y+5*math.sin(offsetRot);
local vrot = zr+180;
local tent = createObject(3243, vx, vy, (z-1), 0, 0, vrot);
setObjectScale(tent, 1.3);
local tentCol = createColSphere(x, y, z, 4);
attachElements(tentCol, tent, 0, 0, 0);
setElementData(tentCol, "parent", tent);
setElementData(tent, "parent", tentCol);
setElementData(tentCol, "tent", true);
setElementData(tentCol, "MAX_Slots", 100);
triggerClientEvent(source, "refreshInventoryManual", source);
end, 2000, 1, source);
end);
addEventHandler("onPlayerBuildAWireFence", root, function(itemName)
setElementData(source, itemName, getElementData(source, itemName)-1);
setPedAnimation(source, "BOMBER", "BOM_Plant", -1, false, false, nil, false);
setTimer(function(source)
local x,y,z = getElementPosition(source);
local xr,yr,zr = getElementRotation(source);
local offsetRot = math.rad(zr+90);
local vx = x+1*math.cos(offsetRot);
local vy = y+1*math.sin(offsetRot);
local vrot = zr+90;
local wFence = createObject(983, vx, vy, z, xr, yr, vrot);
setObjectScale(wFence, 1);
local wFenceCol = createColSphere(x, y, z, 2);
attachElements(wFenceCol, wFence, 0, 0, 0);
setElementData(wFenceCol, "parent", wFence);
setElementData(wFence, "parent", wFenceCol);
setElementData(wFenceCol, "wirefence", true);
triggerClientEvent(source, "refreshInventoryManual", source);
end, 2000, 1, source);
end);
addEventHandler("removeWirefence", root, function(object)
setTimer(function(object)
destroyElement(getElementData(object, "parent"));
destroyElement(object);
end, 2000, 1, object);
end);
addEventHandler("removeTent",root, function(object)
local col = getElementData(object, "parent");
setTimer(function(col, object)
local x,y,z = getElementPosition(col);
local item,itemString = getItemTablePosition("Tent");
local itemPickup = createItemPickup(item, x, y, (z+1), itemString);
if col then destroyElement(col); end
if object then destroyElement(object); end
end, 2000, 1, col, object);
end);
addEventHandler("addPlayerCookMeat", root, function()
setPedAnimation(source, "BOMBER", "BOM_Plant", -1, false, false, nil, false);
local meat = getElementData(source, "Raw Meat");
setTimer(function(source)
setElementData(source, "Raw Meat", 0);
setElementData(source, "Cooked Meat", getElementData(source, "Cooked Meat") + meat);
triggerClientEvent(source, "displayClientInfo", source, "You cooked "..tostring(meat).." Raw Meat.", 22, 255, 0);
end, 5000, 1, source);
end);
addEventHandler("onPlayerMakeAFire", root, function(itemName)
setElementData(source, "Wood Pile", getElementData(source, "Wood Pile")-1);
local x,y,z = getElementPosition(source);
local xr,yr,zr = getElementRotation(source);
local offsetRot = math.rad(zr+90);
local vx = x+1*math.cos(offsetRot);
local vy = y+1*math.sin(offsetRot);
local vrot = zr+90;
local wood = createObject(1463, vx, vy, (z-0.75), xr, yr, vrot);
setObjectScale(wood, 0.55);
setElementCollisionsEnabled(wood, false);
setElementFrozen(wood, true);
local fire = createObject(3525, vx, vy, (z-0.75), xr, yr, vrot);
setObjectScale(fire, 0);
local fireCol = createColSphere(x, y, z, 2);
setElementData(fireCol, "parent", wood);
setElementData(wood, "parent", fireCol);
setElementData(fireCol, "fireplace", true);
triggerClientEvent(source, "refreshInventoryManual", source);
setPedAnimation(source, "BOMBER","BOM_Plant", -1, false, false, nil, false);
setTimer(function(fireCol, fire, wood)
if fireCol then destroyElement(fireCol); end
if fire then destroyElement(fire); end
if wood then destroyElement(wood); end
end, (2*60000), 1, fireCol, fire, wood);
end);
addEventHandler("onPlayerPlaceRoadflare", root, function(itemName)
setElementData(source, itemName, getElementData(source, itemName)-1);
local x,y,z = getElementPosition(source);
local object = createObject(354, x, y, (z-0.6));
setTimer(destroyElement, 300000, 1, object);
triggerClientEvent(source, "refreshInventoryManual", source);
end);
addEventHandler("onPlayerChat", root, function(message, mType)
if (mType == 0 or mType == 1) then
cancelEvent();
end
if (mType == 0) then
local x,y,z = getElementPosition(source);
local chatSphere = createColSphere(x, y, z, 15);
local nearbyPlayers = getElementsWithinColShape(chatSphere, "player");
destroyElement(chatSphere);
for _,v in ipairs(nearbyPlayers) do
outputChatBox("#D3D3D3[Local] #D3D3D3"..string.gsub((getPlayerName(source).." : #D3D3D3"..message), '#%x%x%x%x%x%x', ''), v, 211, 211, 211, true);
end
end
end);
addCommandHandler("radiochat", function(player, _, ...)
if (getElementData(player, "Radio Device") >= 1) then
for _,v in ipairs(getElementsByType("player")) do
if (getElementData(v, "Radio Device") >= 1) then
if (getElementData(v, "radiochannel") == getElementData(player, "radiochannel")) then
outputChatBox("#FFFF00[Radio] "..getPlayerName(player):gsub("#%x%x%x%x%x%x", "").." : #FFFFFF"..table.concat({...}, " "):gsub("#%x%x%x%x%x%x", ""), v, 255, 255, 255, true);
end
end
end
else
triggerClientEvent(source, "displayClientInfo", source, "You don't have a Radio Device!", 255, 0, 0);
end
end);
setTimer(function()
for _,v in ipairs(getElementsByType("player")) do
if getElementData(v, "logedin") then
local current = getElementData(v, "skin");
if (getElementData(v, "htype") == "Bandit") then
if (current == 179 or current == 287) then
setElementModel(v, 288);
elseif (current == 73) then
setElementModel(v, 180);
end
elseif (getElementData(v, "humanity") == 5000) then
if (current == 73 or current == 179 or current == 287) then
setElementModel(v, 210);
end
else
setElementModel(v, getElementData(v, "skin"));
end
end
end
end, 20000, 0);
addCommandHandler("kickall", function(player)
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then
for _,v in ipairs(getElementsByType("player")) do
if (v ~= player) then
kickPlayer(v, "#Hotfix!");
end
end
end
end);
addEventHandler("onPlayerCommand", root, function(cmd)
if (cmd == "login" or cmd == "logout") then
cancelEvent();
end
end);
addEventHandler("kickPlayerOnHighPing", root, function()
kickPlayer(source, "Ping > 400!");
end);
function funcBindHandsup(player, key, keyState)
if (handsUp) then
setPedAnimation(player, false);
handsUp = false;
else
if (getElementData(player, "repairvehicle") == true) then return false; end
if isPedInVehicle(player) then return false; end
setPedAnimation(player, "BEACH", "ParkSit_M_loop", -1, true, false, false, false);
handsUp = true;
end
end
function funcBindSit(player, key, keyState)
if (siting) then
setPedAnimation(player, false);
siting = false;
else
if (getElementData(player, "repairvehicle") == true) then return false; end
if isPedInVehicle(player) then return false; end
setPedAnimation(player, "SHOP", "SHP_Rob_HandsUp", -1, true, true, false, false);
siting = true
end
end
function funcBindLie(player, key, keyState)
if (lying) then
setPedAnimation(player, false);
lying = false;
else
if (getElementData(player, "repairvehicle") == true) then return false; end
if isPedInVehicle(player) then return false; end
setPedAnimation(player, "WUZI", "CS_Dead_Guy", -1, true, false, false, true);
lying = true;
end
end
addEventHandler("relWep", resourceRoot, function()
reloadPedWeapon(client);
end);
function changeWeather(weather)
if (weather) then
setWeather(weather);
return;
else
setWeather(weatherTable[math.random(4)]);
setTimer(changeWeather, (30*60000), 1);
end
end
addEventHandler("onPlayerLogin", root, function()
bindKey(source, ",", "down", funcBindHandsup);
bindKey(source, ".", "down", funcBindSit);
bindKey(source, "l", "down", funcBindLie);
end);
addEventHandler("onPlayerHideBody", root, function()
local cCol = getElementData(source, "currentCol");
if (getElementData(source, "Bandage") >= 1) then
if cCol then
if getElementData(cCol, "deadman") then
setElementData(source, "loot", false);
setElementData(source, "Bandage", getElementData(source, "Bandage") - 1);
setElementData(source, "currentCol", false);
setTimer(function(cCol)
if cCol then
destroyElement(getElementData(cCol, "parent"));
end
destroyElement(cCol);
end, 2000, 1, cCol);
end
end
end
end);
function spawnDayZAnimals()
for _,v in ipairs(animalsSpawns) do
local ped = createPed(math.random(12, 14), v[1], v[2], v[3]);
setElementData(ped, "animal", true);
end
end
function destroyDeadAnimalAndRespawn(ped, pedCol, x, y, z)
if (ped and pedCol) then
destroyElement(ped);
destroyElement(pedCol);
local ped = createPed(math.random(12, 14), x, y, z);
setElementData(ped, "animal", true);
setPedAnimation(ped, "ped", "pikcup_box");
setElementSyncer(ped, getRandomPlayer());
end
end
addEventHandler("createDeadAnimal", root, function()
local x,y,z = getElementPosition(source);
local skin = getElementModel(source);
local ped = createPed(skin, x, y, z);
local pedCol = createColSphere(x, y, z, 1.5);
killPed(ped);
setElementData(pedCol, "parent", ped);
setElementData(pedCol, "playername", "Animal");
setElementData(pedCol, "deadman", true);
setElementData(pedCol, "MAX_Slots", 8);
local time = getRealTime();
setElementData(pedCol, "deadreason", "This animal was killed around "..time.hour..":"..time.minute.." o'clock.");
if (getElementModel(source) == 12) then setElementData(pedCol, "Raw Meat", math.random(8));
elseif (getElementModel(source) == 13) then setElementData(pedCol, "Raw Meat", math.random(4));
elseif (getElementModel(source) == 14) then setElementData(pedCol, "Raw Meat", math.random(2)); end
destroyElement(source);
setTimer(destroyDeadAnimalAndRespawn, 1800000, 1, ped, pedCol, x, y, z);
end);
addEventHandler("onPlayerQuit", root, function(quitType, reason)
if not reason then
outputChatBox("#FFFFFF"..getPlayerName(source):gsub("#%x%x%x%x%x%x", "").." #FF0000has left the server ["..quitType.."]", root, 255, 255, 255, true);
else
outputChatBox("#FFFFFF"..getPlayerName(source):gsub("#%x%x%x%x%x%x", "").." #FF0000has left the server [#FFFFFF"..quitType.."#FF0000, #FFFFFF"..reason.."#FF0000]", root, 255, 255, 255, true);
end
end);
addEventHandler("onPlayerChangeNick", root, function(oldNick, newNick)
outputChatBox("#FFFFFF"..oldNick:gsub("#%x%x%x%x%x%x", "").." #FF0000is now known as #FFFFFF"..newNick:gsub("#%x%x%x%x%x%x", ""), root, 255, 255, 255, true);
end);
addEventHandler("onPlayerJoin", root, function()
setPlayerNametagShowing(source, false);
outputChatBox("#FFFFFF"..getPlayerName(source):gsub("#%x%x%x%x%x%x", "").." #FF0000has joined the server!", root, 255, 255, 255, true);
for i = 70, 79 do
if (i ~= 73) then
setPedStat(source, i, 999);
end
end
end);
addEventHandler("onPlayerLogin", root, function()
triggerClientEvent("displayClientInfo", root, getPlayerName(source):gsub("#%x%x%x%x%x%x", "").." #FFFFFFhas logged in!", 255, 255, 255);
setElementData(source, "clientdata", {getServerName(), getMaxPlayers()});
end);
setTimer(function()
for _,v in ipairs(getElementsByType("ped")) do
if getElementData(v, "animal") then return; end
if getElementData(v, "zombie") then
if getElementData(v, "deadzombie") then return; end
if isPedDead(v) then return; end
local x,y,z = getElementPosition(v);
local path = "sounds/mgroan"..math.random(1, 10)..".ogg";
triggerClientEvent("playPedSound", root, v, path, x, y, z);
end
end
end, 5000, 0);
spawnDayZAnimals();
changeWeather(7); -- '7' means you use the weather 7 delete it to make a random weather.