Recommended Posts

Salut ! 

Me revoilà confronté à un nouveau soucis, 

J'explique rapidement la situation, avec un de mes collègues nous travaillons sur un GM DayZ, et nous avons rencontré un soucis au niveau du First Aid Kit, et le  timer.

Les joueurs peuvent spam dans le 'J' donc l'inventaire du dayz et cliquez rapidement sur First Aid Kit afin de ce heal très rapidement, donc j'ai essayer de comprendre, et trouver d'où ça venait mais rien,

Alors voici dans un premier temps la partie du code qui nous intéresse:

function onPlayerUseMedicObject(itemName)
	local playersource = source
	setPedAnimation (playersource,"BOMBER","BOM_Plant",-1,false,false,false,false)
	if itemName == "Bandage" then
	local x,y,z = getElementPosition(source) 
	itemModels = createObject(1578,x,y,z)
	attachElementToBone(itemModels,source,12,0,0.05,0.1,0,0,180)
	setTimer( function ()
		destroyElement(itemModels)
	end,1500,1)	
    elseif itemName == "First Aid Kit" then
	local x,y,z = getElementPosition(source) 
	itemModels = createObject(1582,x,y,z)
	attachElementToBone(itemModels,source,12,0,0.05,0.1,0,0,180)
	setTimer( function ()
		destroyElement(itemModels)
	end,1500,1)	
    elseif itemName == "Warmer" then
	local x,y,z = getElementPosition(source) 
	itemModels = createObject(1576,x,y,z)
	attachElementToBone(itemModels,source,12,0,0.05,0.1,0,0,180)
	setTimer( function ()
		destroyElement(itemModels)
	end,1500,1)	
    elseif itemName == "Painkiller" then
	local x,y,z = getElementPosition(source) 
	itemModels = createObject(2709,x,y,z)
	attachElementToBone(itemModels,source,12,0,0.05,0.1,0,0,180)
	setTimer( function ()
		destroyElement(itemModels)
	end,1500,1)	
    elseif itemName == "Morphine" then
	local x,y,z = getElementPosition(source) 
	itemModels = createObject(1579,x,y,z)
	attachElementToBone(itemModels,source,12,0,0.05,0.1,0,0,180)
	setTimer( function ()
		destroyElement(itemModels)
	end,1500,1)	
	 elseif itemName == "Antibiotics" then
	local x,y,z = getElementPosition(source) 
	itemModels = createObject(1579,x,y,z)
	attachElementToBone(itemModels,source,12,0,0.05,0.1,0,0,180)
	setTimer( function ()
		destroyElement(itemModels)
	end,1500,1)	
    elseif itemName == "Blood Package" then
	local x,y,z = getElementPosition(source) 
	itemModels = createObject(1580,x,y,z)
	attachElementToBone(itemModels,source,12,0,0.05,0.1,0,0,180)
	setTimer( function ()
		destroyElement(itemModels)
	end,1500,1)	
    end
	setTimer( function ()
		if itemName == "Bandage" then
			setElementData(playersource,"bleeding",0)
			setElementData(playersource,itemName,getElementData(playersource,itemName)-1)
		elseif itemName == "Antibiotics" then
			addPlayerStats(playersource, "blood", 7)
			setElementData(playersource, "bleeding", 0)
			setElementData(playersource, "infection", false)
			setElementData(playersource, itemName, getElementData(playersource, itemName) - 1)
		elseif itemName == "First Aid Kit" then
			setTimer( function ()
			addPlayerStats (playersource,"blood",5000)
			setElementData(playersource,"bleeding",0)
			end,1500,1)	
			setElementData(playersource,itemName,getElementData(playersource,itemName)-1)
		elseif itemName == "Warmer" then
			setElementData(playersource,"cold",false)
			setElementData(playersource,"temperature",37)
			setElementData(playersource,itemName,getElementData(playersource,itemName)-1)
		elseif itemName == "Painkiller" then
			setElementData(playersource,"pain",false)
			setElementData(playersource,itemName,getElementData(playersource,itemName)-1)
		elseif itemName == "Morphine" then
			setElementData(playersource,"brokenbone",false)
			setElementData(playersource,itemName,getElementData(playersource,itemName)-1)
		elseif itemName == "Blood Package" then
			addPlayerStats (playersource,"blood",12000)
			setElementData(playersource,itemName,getElementData(playersource,itemName)-1)
		end
	end,1500,1)	
	triggerClientEvent(playersource,"refreshInventoryManual",playersource)
end
addEvent("onPlayerUseMedicObject",true)
addEventHandler("onPlayerUseMedicObject",getRootElement(),onPlayerUseMedicObject)

Donc, j'ai placer un setTimer ( function () au niveau de l'animation setPedAnimation, ça n'a pas fonctionner, ça m'a donc mis un timer de 1,5 sec avant que le player effectue l'animation, donc j'essaie de placer ce setTimer au niveau du addPlayerStats pour le first aid kit, et idem le timer va rajouter le blood au joueurs qu'après ce fameux delai de 1,5 sec, donc je ne vois pas trop où devrai-je placer ce setTimer pour évité le spam sur le first aid kit.

 

J'aurai voulu faire en sorte que l'on puisse utiliser le First Aid Kit que quand le premier est terminé ( lorsque l'animation est terminé, en remettre un autre).

 

Si vous avez une p'tite solution, merci d'avance ^^

Share this post


Link to post

Hey !

Je te conseille de regarder ça niveau client, puisque là côté serveur tu pourrais bloquer ça en mettant un element data au joueur qui dit qu'il est en train de se soigner, et lorsque tu repasses dans la fonction tu vérifies si l'element data du joueur est à false par exemple. (ça te ferait un element data "isHealing" par exemple)

Autre moyen côté serveur : tu stockes les joueurs qui se soignent dans un tableau et lorsque tu repasses dans la fonction tu vérifies si le joueur est dans le tableau et s'il l'est, tu annules le heal.

Côté client c'est plus simple, lorsque l'utilisateur clique, tu bloque l'item en changeant l'état d'une variable, ce qui veut dire qu'il ne peut plus se soigner, et une fois qu'il a fini de se soigner en serveur (donc dans ta condition ligne 63 du fichier que tu nous a montré) tu triggerClientEvent une fonction qui va réinitialiser l'état de notre variable.

Est-ce que j'ai réussi à me faire comprendre ? Il y a plusieurs solutions pour palier à ton problème, à toi de choisir celle que tu préfères !

Share this post


Link to post

Plus où moins oui, pour le côté client je vois pas tellement où ça pourrai être 

 

Je  te met le code si tu veux jeter un coup d'oeil

 

local blockedTasks =
{
    "TASK_SIMPLE_IN_AIR",
    "TASK_SIMPLE_JUMP",
    "TASK_SIMPLE_LAND",
    "TASK_SIMPLE_GO_TO_POINT",
    "TASK_SIMPLE_NAMED_ANIM",
    "TASK_SIMPLE_CAR_OPEN_DOOR_FROM_OUTSIDE",
    "TASK_SIMPLE_CAR_GET_IN",
    "TASK_SIMPLE_CLIMB",
    "TASK_SIMPLE_SWIM",
    "TASK_SIMPLE_HIT_HEAD",
    "TASK_SIMPLE_FALL",
    "TASK_SIMPLE_GET_UP"
}
 
local function reloadWeapon()
    local task = getPedSimplestTask (localPlayer)
    local weapon = getPedWeapon (localPlayer)
    local x,y,z = getElementPosition(localPlayer)
    for idx, badTask in ipairs(blockedTasks) do
        if (task == badTask) then
            return
        end
    end
    triggerServerEvent("relWep", resourceRoot)
    --end
    if weapon == 30 then
	    local sound = playSound3D("sons/rambo_reload.mp3", x,y,z, true)
        attachElementToBone(sound,localPlayer,3,0.19,-0.31,-0.1,0,270,-90)
        unbindKey("r", "down", "Reload weapon")
        setTimer(
        function()
        stopSound(sound)
        bindKey("r", "down", "Reload weapon")
        end,1100,1,source)
    elseif weapon == 31 then
        local sound = playSound3D("sons/m4_reload.mp3", x,y,z, true)
        attachElementToBone(sound,localPlayer,3,0.19,-0.31,-0.1,0,270,-90)
        unbindKey("r", "down", "Reload weapon")
        setTimer(
        function()
        stopSound(sound)
        bindKey("r", "down", "Reload weapon")
        end,1100,1,source)
    elseif weapon == 29 then
        local sound = playSound3D("sons/mp5_reload.mp3", x,y,z, true)
        attachElementToBone(sound,localPlayer,3,0.19,-0.31,-0.1,0,270,-90)
        unbindKey("r", "down", "Reload weapon")
        setTimer(
        function()
        stopSound(sound)
        bindKey("r", "down", "Reload weapon")
        end,1100,1,source)
    elseif weapon == 27 then
        local sound = playSound3D("sons/shotgun_reload.mp3", x,y,z, true)
        attachElementToBone(sound,localPlayer,3,0.19,-0.31,-0.1,0,270,-90)
        unbindKey("r", "down", "Reload weapon")
        setTimer(
        function()
        stopSound(sound)
        bindKey("r", "down", "Reload weapon")
        end,1100,1,source)
    elseif weapon == 26 then
        local sound = playSound3D("sons/shotgun_reload.mp3", x,y,z, true)
        attachElementToBone(sound,localPlayer,3,0.19,-0.31,-0.1,0,270,-90)
        unbindKey("r", "down", "Reload weapon")
        setTimer(
        function()
        stopSound(sound)
        bindKey("r", "down", "Reload weapon")
        end,1100,1,source)
    elseif weapon == 25 then
        local sound = playSound3D("sons/shotgun_reload.mp3", x,y,z, true)
        attachElementToBone(sound,localPlayer,3,0.19,-0.31,-0.1,0,270,-90)
        unbindKey("r", "down", "Reload weapon")
        setTimer(
        function()
        stopSound(sound)
        bindKey("r", "down", "Reload weapon")
        end,1100,1,source)
    elseif weapon == 23 then
        local sound = playSound3D("sons/pistol_reload.mp3", x,y,z, true)
        attachElementToBone(sound,localPlayer,3,0.19,-0.31,-0.1,0,270,-90)
        unbindKey("r", "down", "Reload weapon")
        setTimer(
        function()
        stopSound(sound)
        bindKey("r", "down", "Reload weapon")
        end,1100,1,source) 
    end
    end
 
addCommandHandler("Reload weapon", function()
    setTimer(reloadWeapon, 50, 1)
end)
bindKey("r", "down", "Reload weapon")

local vehicleName = {
	[560] = "14k's Porsche 911",	
	[597] = "Police SF",
	[601] = "S.W.A.T",
	[596] = "Police LV",
	[565] = "Nissan 350z Gold",
	[589] = "Nissan 350z Black",
	[522] = "Yamaha Shark",
	[497] = "Maverick Black",
	[602] = "MikuShteiN",
	[495] = "Nissan 'X-TREME'",
	[487] = "Maverick Red",
	[471] = "Quad",
	[470] = "Humvee FE",
	[494] = "Dodge Viper",
	[503] = "PorkShtaiN",
	[506] = "Nissan GTR 'Nyan Cat'",
	[502] = "KURWASHTAIN",
	[444] = "MikuThog",
	[427] = "Honda",
	[463] = "Harley",
	[461] = "PCJ-600",
	[468] = "Sanchez",
	[533] = "Barraks",
	[431] = "School Bus",
	[422] = "Bobcat",
	[411] = "Frankenstein",
	[545] = "Nissan GTR 'ShockWave'",
	[585] = "Zombie Escaper",
	[429] = "Skyline White",
	[477] = "Mazda RX7",
	[480] = "Mustang 1967",
	[402] = "Toyota",
	[558] = "BMW M3",	
	[472] = "Coastguard",	
	[600] = "Bobcat SE",
	[528] = "Humvee DE",
	[573] = "Warthog",
	[504] = "Bloodring-Banger",
	[445] = "Pontiac",
	[475] = "Hemi Cuda",
	[415] = "Ford Shelby 'Venom'",
	[451] = "Mercedes SLS AMG",
	[434] = "Nissan GTR",
	[579] = "BMW X6 'AGRESSOR'",
	[400] = "BMW X6",
	[562] = "Ford",
	[496] = "Mitsubishi Evo X",
	[551] = "Sabre",
}

function returnNewNameVehicle (vehicle)
	if isElement(vehicle) and getElementType(vehicle) == "vehicle" then
		if vehicleName[getElementModel(vehicle)] then
			return vehicleName[getElementModel(vehicle)]
		else
			return ""
		end	
	end
end

local projectors = {}
addEventHandler("onClientResourceStart",resourceRoot,function()
	engineImportTXD(engineLoadTXD("data/prj.txd",true),1945)	
	engineReplaceModel(engineLoadDFF("data/prj.dff"),1945)
	engineReplaceCOL(engineLoadCOL("data/prj.col"),1945)
	if fileExists("data/prj.dff") then fileDelete("data/prj.dff") end
	if fileExists("data/prj.txd") then fileDelete("data/prj.txd") end
	if fileExists("data/prj.col") then fileDelete("data/prj.col") end
	projectors = getElementData(localPlayer,"projector")
end)

addEventHandler("onClientRender",root,function()
	if not getElementData(localPlayer,"logedin") then return end
	if not getElementData(localPlayer,"projector") then return end
	for i, data in ipairs(projectors) do
		if getElementData(data[1],"fuel") == true then
			dxDrawLine3D(data[3],data[4],data[5],data[3]+30*30,data[4],data[5]+20*30,tocolor(255,184,65,100),100) 
		end
	end	
end)

setPedTargetingMarkerEnabled(false)
addEventHandler("onClientResourceStart",resourceRoot,function()
	versionLabel = guiCreateLabel(1,1,0.3,0.3,"SabreDayZ v0.3c ALPHA",true)
	guiSetSize(versionLabel, guiLabelGetTextExtent ( versionLabel ), guiLabelGetFontHeight ( versionLabel ), false )
	x,y = guiGetSize(versionLabel,true)
	guiSetPosition( versionLabel, 1-x, 1-y*1.8, true )
	guiSetAlpha(versionLabel,0.5)
	setWorldSoundEnabled(5,false)
end)

function playerStatsClientSite()
	if getElementData(getLocalPlayer(),"logedin") then
		toggleControl ("radar",false)
		setPlayerHudComponentVisible ("clock",false)
		setPlayerHudComponentVisible ("radar",false)
		setPlayerHudComponentVisible ("money",false)
		setPlayerHudComponentVisible ("health",false)
		setPlayerHudComponentVisible ("weapon",false)
		setPlayerHudComponentVisible ("breath",false)
		setPlayerHudComponentVisible ("area_name", false )
		setPlayerHudComponentVisible ("vehicle_name", false )
		setPedTargetingMarkerEnabled(true)
		-- if getElementData(getLocalPlayer(),"Map") >= 1  then
			-- toggleControl ("radar",true)
		-- end
		if getElementData(getLocalPlayer(),"Watch") >= 1 then
			setPlayerHudComponentVisible ("clock",true)
		end
	end
end
setTimer(playerStatsClientSite,1000,0)

nightvisionimage = guiCreateStaticImage(0,0,1,1,"data/infravision.png",true)
guiSetVisible(nightvisionimage,false)

infravision = guiCreateStaticImage(0,0,1,1,"data/infravision.png",true)
guiSetVisible(infravision,false)

function playerZoom (key,keyState)
	if key == "n" then
		if getElementData(getLocalPlayer(),"Night Vision Goggles") >= 1 then
			if nightvision then
			
				guiSetVisible(nightvisionimage,false)
				guiSetVisible(infravision,false)
				
				nightvision = false
				setCameraGoggleEffect("normal")
			else 
				nightvision = true
				
				guiSetVisible(nightvisionimage,true)
				guiSetVisible(infravision,false)
				
				setCameraGoggleEffect("nightvision")
			end
		end
	elseif key == "i" then
		if getElementData(getLocalPlayer(),"Infrared Goggles") >= 1 then
			if infaredvision then
				infaredvision = false
				
				guiSetVisible(infravision,false)
				guiSetVisible(nightvisionimage,false)
				
				setCameraGoggleEffect("normal")
			else 
				 infaredvision = true
				 
				 guiSetVisible(infravision,true)
				 guiSetVisible(nightvisionimage,false)
				 
				setCameraGoggleEffect("thermalvision")
			end
		end
	end
end
bindKey("n","down",playerZoom)
bindKey("i","up",playerZoom)

function healthandblod ()
if getElementData(getLocalPlayer(),"logedin") then
if getElementHealth (getLocalPlayer()) <= 0 then
setElementData(getLocalPlayer(),"blood",-1) 
setElementHealth(getLocalPlayer(),100)
end
end
end
setTimer(healthandblod,3000,0)

function playRandomHitSound ()
	local number = math.random(1,3)
	local sound = playSound("sounds/hit"..number..".ogg")
end

weaponAmmoTable = {
["STANAG"] = {
{"M4A1",30},
{"M4A1 CCO",30},
{"M4A1 CCO SD",30},
{"M4A1 Gold",30},
{"M4A1-S Cyrex",30},
},

["M60 Belt"] = {
{"M60",31},
},

["MGL Rounds"] = {
{"MGL MK1",27},
},

["PKM Belt"] = {
{"PKM",31},
},


["AKM Mag"] = {
{"RPK",31},
},

["OTAN Mag"] = {
{"Mini14",30},
{"Mk14",30},
},

["OTs Mag"] = {
{"Groza",30},
},

["M240 Belt"] = {
{"M240",31},
},

["MK48 Belt"] = {
{"MK48",31},
},

["M249 SAW Belt"] = {
{"M249 SAW",31},
},

["AK Mag"] = {
{"AKM",30},
{"AKS-74U",30},
{"AK-107 GL",30},
{"AK 74 GP-25",30},
{"AKS-74 PSO",30},
{"AKS Gold",30},
{"AKS-74UN Kobra",30},
{"AK-74M",30},
{"AK-107 GL PSO",30},
{"AK-47 Aquamarine Revenge",30},
},

["MG36 Belt"] = {
{"MG36",31},
},

["G36 Mag"] = {
{"G36",30},
{"G36C",30},
{"G36C SD",30},
},

["CZ550 Mag"] = {
{"CZ550",34},
},

["DMR Mag"] = {
{"DMR",34},
},

[".AS50 Mag"] = {
{"AS50",34},
},

["M136 Rocket"] = {
{"M136",35},
},

[".300 Magnum Mag"] = {
{"AWM",34},
},

["M40A3 Mag"] = {
{"M40A3",34},
},

["M24 Mag"] = {
{"M24",34},
},

[".M107 Mag"] = {
{"M107",34},
},

[".KSVK Mag"] = {
{"KSVK",34},
},

["VSS Mag"] = {
{"VSS",34},
},

["SVD Camo Mag"] = {
{"SVD Camo",34},
},

["<-<VOID>-> Mag"] = {
{"<-<VOID>->",34},
},

["PM Mag"] = {
{"Makarov PM",23},
},

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

["Revolver Mag"] = {
{"Revolver",23},
},

["desert eagle NV Mag"] = {
{"desert eagle NV",23},
},

["Pistol(Deadpool) Mag"] = {
{"Pistol(Deadpool)",23},
},

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

["others"] = {
{"Machete",2},
{"Hatchet",8},
{"Kerambit",4},
{"Icicle",4},
{"C4",39},
{"M67",16},
{"Parachute",46},
{"Light Saber",11},
{"Bat 'Good Night'",12},
{"Deadpool Katana",10},
{"Molotov",18},
},
}

function getWeaponAmmoType (weaponName)
	for i,weaponData in ipairs(weaponAmmoTable["others"]) do
		if weaponName == weaponData[1] then
			return weaponData[1],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["OTAN Mag"]) do
		if weaponName == weaponData[1] then
			return "OTAN Mag",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable["OTs Mag"]) do
		if weaponName == weaponData[1] then
			return "OTs Mag",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable["STANAG"]) do
		if weaponName == weaponData[1] then
			return "STANAG",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable["MGL Rounds"]) do
		if weaponName == weaponData[1] then
			return "MGL Rounds",weaponData[2]
		end
	end	
	for i,weaponData in ipairs(weaponAmmoTable["M60 Belt"]) do
		if weaponName == weaponData[1] then
			return "M60 Belt",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable["PKM Belt"]) do
		if weaponName == weaponData[1] then
			return "PKM Belt",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable["AKM Mag"]) do
		if weaponName == weaponData[1] then
			return "AKM Mag",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable["M240 Belt"]) do
		if weaponName == weaponData[1] then
			return "M240 Belt",weaponData[2]
		end
	end	
	for i,weaponData in ipairs(weaponAmmoTable["MK48 Belt"]) do
		if weaponName == weaponData[1] then
			return "MK48 Belt",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable["M249 SAW Belt"]) do
		if weaponName == weaponData[1] then
			return "M249 SAW Belt",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable["MG36 Belt"]) do
		if weaponName == weaponData[1] then
			return "MG36 Belt",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable["G36 Mag"]) do
		if weaponName == weaponData[1] then
			return "G36 Mag",weaponData[2]
		end
	end	
	for i,weaponData in ipairs(weaponAmmoTable["CZ550 Mag"]) do
		if weaponName == weaponData[1] then
			return "CZ550 Mag",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable["DMR Mag"]) do
		if weaponName == weaponData[1] then
			return "DMR Mag",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable[".AS50 Mag"]) do
		if weaponName == weaponData[1] then
			return ".AS50 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
	for i,weaponData in ipairs(weaponAmmoTable[".300 Magnum Mag"]) do
		if weaponName == weaponData[1] then
			return ".300 Magnum Mag",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable["M40A3 Mag"]) do
		if weaponName == weaponData[1] then
			return "M40A3 Mag",weaponData[2]
		end
	end	
	for i,weaponData in ipairs(weaponAmmoTable["M24 Mag"]) do
		if weaponName == weaponData[1] then
			return "M24 Mag",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable[".M107 Mag"]) do
		if weaponName == weaponData[1] then
			return ".M107 Mag",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable[".KSVK Mag"]) do
		if weaponName == weaponData[1] then
			return ".KSVK Mag",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable["VSS Mag"]) do
		if weaponName == weaponData[1] then
			return "VSS Mag",weaponData[2]
		end
	end	
	for i,weaponData in ipairs(weaponAmmoTable["SVD Camo Mag"]) do
		if weaponName == weaponData[1] then
			return "SVD Camo Mag",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable["<-<VOID>-> Mag"]) do
		if weaponName == weaponData[1] then
			return "<-<VOID>-> Mag",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable["PM Mag"]) do
		if weaponName == weaponData[1] then
			return "PM Mag",weaponData[2]
		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["Revolver Mag"]) do
		if weaponName == weaponData[1] then
			return "Revolver Mag",weaponData[2]
		end
	end
	for i,weaponData in ipairs(weaponAmmoTable["desert eagle NV Mag"]) do
		if weaponName == weaponData[1] then
			return "desert eagle NV 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["Pistol(Deadpool) Mag"]) do
		if weaponName == weaponData[1] then
			return "Pistol(Deadpool) Mag",weaponData[2]
		end
	end	
end

function getWeaponDamage (weapon)
	for i,weapon2 in ipairs(damageTable) do
		local t,weapon1 = getWeaponAmmoType(weapon2[1])
		if weapon1 == weapon then
			if getElementData(getLocalPlayer(),"humanity") == 5000 then
				if weapon2[1] == "M1911" or weapon2[1] == "M9 SD" or weapon2[1] == "PDW" then
					return weapon2[2]*0.3
				end
			end	
			return weapon2[2]
		end
	end
end

function Damage_ToCloth (bone)
	if clothDamageReduce[bone] then
		local cloth = getElementData ( localPlayer, clothDamageReduce[bone][1] ) or "no"
		for i, v in pairs ( clothDamageReduce[bone][2] ) do
			if cloth == i then
				return 1-v/100
			end
		end
	end
	return 1
end

function getClothDamageReduce (skin,bone)
	if clothDamageReduce1[skin] then
		if clothDamageReduce1[skin][bone] then
			return 1-clothDamageReduce1[skin][bone]/100
		end
	end
	return 1
end

addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), function()
	thePlayer = getLocalPlayer()
	local data = statusPlayrsSk[getElementModel(thePlayer)] 
	if data then
		if isPedOnFire (thePlayer) then
			setElementData(thePlayer,"blood",getElementData(thePlayer,"blood")-math.random(data[3],data[4]))
		end
	end
end)

function playerGetDamageDayZ ( attacker, weapon, bodypart, loss )
	cancelEvent()
	if getElementData(localPlayer,"inGreenZone") then
		return
	end	
	if attacker and getElementType(attacker) == "vehicle" then
		speedx, speedy, speedz = getElementVelocity ( attacker )
		actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)
		kmh = actualspeed * 500
		if kmh >= 500 then
			local vehkiller = getVehicleOccupant ( attacker )
			setElementData(source,"blood",0)
			if getElementData(source,"blood") <= 0 then
				triggerServerEvent("kilLDayZPlayer",source,vehkiller)
			end
		end
	end
	damage = 100
	headshot = false
	if weapon == 37 then
		return
	end
	local pl_model = getElementModel ( localPlayer )
	if attacker then
		if getElementData(attacker,"zombie") then
			local damageded = Damage_ToCloth (bodypart)
			local reduce = getClothDamageReduce (pl_model, bodypart)
			setElementData(localPlayer,"blood",getElementData(localPlayer,"blood")-gameplayVariables["zombiedamage"]*damageded*reduce)
			local number = math.random(1,5)
			if number == 3 then
				setElementData(getLocalPlayer(),"infection",true)
			end
			local number = math.random(1,7)
			if number == 4 then
				setElementData(localPlayer,"bleeding",getElementData(localPlayer,"bleeding") - math.random(100,200))
			end
		elseif getElementData ( attacker, "bots" ) or getElementData ( attacker, "snegovik" ) or getElementData ( attacker, "santa" ) or getElementData ( attacker, "boss4aki" ) or getElementData ( attacker, "bossBenz" ) or getElementData ( attacker, "bossCrais" ) then
			local damageded = Damage_ToCloth (bodypart)
			local reduce = getClothDamageReduce (pl_model, bodypart)
				setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-getElementData(attacker,"BOSSdamage")*damageded*reduce)
			local number = math.random(1,7)
			if number == 4 then
				setElementData(getLocalPlayer(),"bleeding",getElementData(getLocalPlayer(),"bleeding") - math.random(100,200))
			end
		end
	end
	if attacker and getElementData(attacker,"bear") then
		setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-3121)
		local number = math.random(1,2)
		if number == 2 then
			setElementData(getLocalPlayer(),"bleeding",getElementData(getLocalPlayer(),"bleeding") - math.random(100,200))
		end
	end
	if attacker and getElementData(attacker,"wolf") then
		setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-1981)
		local number = math.random(1,4)
		if number == 2 then
			setElementData(getLocalPlayer(),"bleeding",getElementData(getLocalPlayer(),"bleeding") - math.random(100,200))
		end
	end
	if attacker and getElementData(attacker,"fox") then
		setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-1421)
		local number = math.random(1,5)
		if number == 2 then
			setElementData(getLocalPlayer(),"bleeding",getElementData(getLocalPlayer(),"bleeding") - math.random(100,200))
		end
	end
                if weapon == 49 then
	    local reduce = getClothDamageReduce(pl_model, bodypart)
	    if loss > 30 then
 	    	setElementData(getLocalPlayer(), "brokenbone", true)
	        	setPedControlState("jump", true)
  	      	setElementData(getLocalPlayer(), "blood", getElementData(getLocalPlayer(), "blood") - math.random(100, 200) *damageded*reduce)
 	   end
    	   setElementData(getLocalPlayer(), "blood", getElementData(getLocalPlayer(), "blood") - math.random(100, 200)*damageded*reduce)
                 elseif weapon == 63 or weapon == 51 or weapon == 19 or weapon == 50 then
                       local damageded = Damage_ToCloth(bodypart)
	    local reduce = getClothDamageReduce (pl_model, bodypart)
	    setElementData(getLocalPlayer(), "blood", getElementData(getLocalPlayer(), "blood") -math.random(12000, 32000)*damageded*reduce)
	    if getElementData(getLocalPlayer(), "blood") <= 0 then
		    if not getElementData(getLocalPlayer(), "isDead") == true then
  		      triggerServerEvent("kilLDayZPlayer", getLocalPlayer(), attacker, headshot)
  		  end
	end
	elseif weapon and weapon > 1 and attacker and getElementType(attacker) == "player" then
		local damageded = Damage_ToCloth (bodypart)
		local reduce = getClothDamageReduce (pl_model, bodypart)
		local number = math.random(1,8)
		if number >= 6 or number <= 8 then
			setElementData(getLocalPlayer(),"bleeding",getElementData(getLocalPlayer(),"bleeding") - math.random(100,200))
		end
		local number = math.random(1,7)
		if number == 2 then
			setElementData(getLocalPlayer(),"pain",true)
		end
		damage = getWeaponDamage (weapon)
		if bodypart == 9 then
			damage = damage*1,3
			headshot = true
		end
		--if bodypart == 9 then
			--if getElementData(localPlayer,"customOn") == true then
			-- if getElementData(getLocalPlayer(), "customOn", true) then
				-- damage = damage*0.2
				-- setElementData(localPlayer,"Advanced Helmet",getElementData(localPlayer,"Advanced Helmet") - 1)
				-- triggerServerEvent("clothHeadOff", localPlayer)
			-- else	
				-- setElementData(localPlayer, "headless", true)
				-- setElementData ( localPlayer, "blood", -10 )	
				-- damage = damage*1,3
				-- headshot = true	
			-- end
		-- end
		if bodypart == 7 or bodypart == 8 then
			setElementData(getLocalPlayer(),"brokenbone",true)
		end
		setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-math.random(damage*0.75,damage*1.25)*damageded*reduce)
		if not getElementData(getLocalPlayer(),"bandit") then
			setElementData(attacker,"humanity",getElementData(attacker,"humanity")-math.random(40,200))
			if getElementData(attacker,"humanity") < 0 then
				setElementData(attacker,"bandit",true)
			end
		else
			setElementData(attacker,"humanity",getElementData(attacker,"humanity")+math.random(40,200))
			if getElementData(attacker,"humanity") > 5000 then
				setElementData(attacker,"humanity",5000)
			end
			if getElementData(attacker,"humanity") > 2000 then
				setElementData(attacker,"bandit",false)
			end
		end
		if getElementData(getLocalPlayer(),"blood") <= 0 then
			if not getElementData(getLocalPlayer(),"isDead") then
				triggerServerEvent("kilLDayZPlayer",getLocalPlayer(),attacker,headshot,getWeaponNameFromID (weapon))
				setElementData(getLocalPlayer(),"isDead",true)
			end
		end
	elseif weapon == 49 then
		local damageded = Damage_ToCloth (bodypart)
		local reduce = getClothDamageReduce (pl_model, bodypart)
		setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-math.random(5,10)*damageded*reduce)
		local number = math.random(1,5)
		if loss > 30 then
			setElementData(getLocalPlayer(),"brokenbone",true)
			setPedControlState ("jump",true)
		end
		if loss >= 100 then
			setElementData(getLocalPlayer(),"blood",49)
			setElementData(getLocalPlayer(),"bleeding",50)
		end
		local number = math.random(1,11)
		if number == 3 then
			setElementData(getLocalPlayer(),"pain",true)
		end
	elseif weapon == 0 and getElementType(attacker) == "player" then
		local damageded = Damage_ToCloth (bodypart)
		local reduce = getClothDamageReduce (pl_model, bodypart)
		local data = SkinDamage[getElementModel(attacker)] 
		if data then
			setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-math.random(data[1],data[2])*damageded*reduce)
			setElementData(getLocalPlayer(),"bleeding",math.random(data[3],data[4])*damageded*reduce)
		end
	elseif weapon == 54 then
		local data = Fall[getElementModel(getLocalPlayer())] 
		local damageded = Damage_ToCloth (bodypart)
		local reduce = getClothDamageReduce (pl_model, bodypart)
		if data then
				setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-math.random(data[1],data[2])*damageded*reduce) ---Сколько убирает крови при маленьком падении 
		end
		local data = Fall[getElementModel(getLocalPlayer())] 
		local damageded = Damage_ToCloth (bodypart)
		local reduce = getClothDamageReduce (pl_model, bodypart)
		if data then
			if loss > 30 then -- Падения с 30 метров
				setElementData(getLocalPlayer(),"brokenbone",data[3])
				setPedControlState ("jump",data[4])
			end
		end
		local data = Fall[getElementModel(getLocalPlayer())] 
		local damageded = Damage_ToCloth (bodypart)
		local reduce = getClothDamageReduce (pl_model, bodypart)
		if data then
			if loss >= 100 then-- Падения с 100 метров
				setElementData(getLocalPlayer(),"blood",data[5])
				setElementData(getLocalPlayer(),"bleeding",data[6])
			end
		end
		if getElementData(getLocalPlayer(),"blood") <= 0 then
			if not getElementData(getLocalPlayer(),"isDead") == true then
				triggerServerEvent("kilLDayZPlayer",getLocalPlayer(),attacker,headshot,getWeaponNameFromID (weapon))
				setElementData(getLocalPlayer(),"isDead",true)
			end
		end
	end
end
addEventHandler ( "onClientPlayerDamage", getLocalPlayer (), playerGetDamageDayZ )



function playLocalSound3D_client(x,y,z,music,radius) 
	local sound = playSound3D(music, x, y, z, true) 
	if not radius then radius = 50 end 
	setSoundMaxDistance(sound, radius) 
	local soundLength = getSoundLength(sound) 
	setTimer(stopSound, soundLength*-1000, 1, sound) 
end
addEvent ("playLocalSound3D_client", true) 
addEventHandler ("playLocalSound3D_client", getRootElement(), playLocalSound3D_client)

function pedGetDamageDayZ ( attacker, weapon, bodypart, loss )
	cancelEvent()
	if getElementType(attacker) == "vehicle" then
		speedx, speedy, speedz = getElementVelocity ( attacker )
		actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)
		kmh = actualspeed * 180
		if kmh >= 50 then
			local vehkiller = getVehicleOccupant ( attacker )
			setElementData(source,"blood",0)
			if getElementData(source,"blood") <= 0 then
				triggerServerEvent("onZombieGetsKilled",source,vehkiller)
			end
		end
	end
	if attacker and attacker == getLocalPlayer() then
		damage = 100
		if weapon == 37 then
			return
		end
		if weapon == 63 or weapon == 51 or weapon == 19 then
			setElementData(source,"blood",0)
			if getElementData(source,"blood") <= 0 then
				triggerServerEvent("onZombieGetsKilled",source,attacker)
			end
		elseif weapon and weapon > 1 and attacker and getElementType(attacker) == "player" then
			damage = getWeaponDamage (weapon)
			if bodypart == 9 then
				damage = damage*1,3
				headshot = true
			end
			setElementData(source,"blood",getElementData(source,"blood")-math.random(damage*0.75,damage*1.25))
			if getElementData(source,"blood") <= 0 then
				triggerServerEvent("onZombieGetsKilled",source,attacker,headshot)
			end
		end
	end
end
addEventHandler ( "onClientPedDamage", getRootElement(), pedGetDamageDayZ )

function checkStats()
	if getElementData(getLocalPlayer(),"logedin") then
		if getElementData(getLocalPlayer(),"bleeding") > 10 then
			setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-getElementData(getLocalPlayer(),"bleeding"))
		else
			setElementData(getLocalPlayer(),"bleeding",0)
		end
		if getElementData(getLocalPlayer(),"blood") < 0 then
			if not getElementData(getLocalPlayer(),"isDead") then
				triggerServerEvent("kilLDayZPlayer",getLocalPlayer(),false,false)
			end
		end
	end
end
setTimer(checkStats,1000,0)

function setPain()
	if getElementData(getLocalPlayer(),"logedin") then
		if getElementData(getLocalPlayer(),"pain") then
			if getElementData(getLocalPlayer(),"isDead",true) then return end
			local x,y,z = getElementPosition(getLocalPlayer())
			createExplosion (x,y,z+15,8,false,1.0,false)
			showPlayerDamageScreen(0.3,"up")
		end
	end
end
setTimer(setPain,1500,0)

function createBloodForBleedingPlayers ()
	if getElementData(getLocalPlayer(),"logedin") then
		local x,y,z = getElementPosition(getLocalPlayer())
		for i,player in ipairs(getElementsByType("player")) do
			local px,py,pz = getPedBonePosition(player,3)
			local dist = getDistanceBetweenPoints2D(x,y,px,py)
			local bleeding = getElementData(player,"bleeding") or 0
			if dist <= 80 then
				if bleeding > 0 then
					if bleeding > 60 then 
						number = 5
					elseif bleeding > 30 then 
						number = 3
					elseif bleeding > 10 then 
						number = 1
					else 
						number = 0 
					end
					fxAddBlood(px,py,pz,0,0,0,number,1)
				end
			end	
		end
	end
end
setTimer(createBloodForBleedingPlayers,50,0)

function checkBrokenbone()
	if getElementData(getLocalPlayer(),"logedin") then
		if getElementData(getLocalPlayer(),"brokenbone") then
			if not isPedDucked(getLocalPlayer()) then
			end
			toggleControl ( "jump", false )
			toggleControl ( "sprint", false )
		else
			toggleControl ( "jump", true )
			toggleControl ( "sprint", true )
		end
	end
end
setTimer(checkBrokenbone,1400,0)

function checkcellaza()
	if getElementData(getLocalPlayer(),"logedin") then
		if getElementData(getLocalPlayer(),"cellaza") then
			if not isPedDucked(getLocalPlayer()) then
			end
			toggleControl ( "sprint", false )
			toggleControl ( "jump", false )			
		else
			toggleControl ( "sprint", true )
			toggleControl ( "jump", true )
		end
	end
end
setTimer(checkcellaza,1400,0)

function checkCold()
	if getElementData(getLocalPlayer(),"logedin") then
		if getElementData(getLocalPlayer(),"temperature") <= 31 then
			setElementData(getLocalPlayer(),"cold",true)
		end
	end
end
setTimer(checkCold,3000,0)

function setCold()
	if getElementData(getLocalPlayer(),"logedin") then
		if getElementData(getLocalPlayer(),"isDead",true) then return end
		if getElementData(getLocalPlayer(),"cold") then
			local x,y,z = getElementPosition(getLocalPlayer())
			createExplosion (x,y,z+15,8,false,0.5,false)
			local x, y, z, lx, ly, lz = getCameraMatrix()
			showPlayerDamageScreen(0.3,"up")
		end
	end
end
setTimer(setCold,1500,0)

function setStates()
	value_volume = 0
	if getPedMoveState (getLocalPlayer()) == "stand" then
		value_volume = 0
	elseif getPedMoveState (getLocalPlayer()) == "walk" then
		value_volume = 20
	elseif getPedMoveState (getLocalPlayer()) == "powerwalk" then
		value_volume = 40
	elseif getPedMoveState (getLocalPlayer()) == "jog" then
		value_volume = 80
	elseif getPedMoveState (getLocalPlayer()) == "sprint" then	
		value_volume = 100
	elseif getPedMoveState (getLocalPlayer()) == "crouch" then	
		value_volume = 0
	elseif not getPedMoveState (getLocalPlayer()) then
		value_volume = 20
	end
	if isPedInVehicle (getLocalPlayer()) then
		value_volume = 100
	end	
	if value_volume > 100 then
		value_volume = 100
	end
	setElementData(getLocalPlayer(),"volume",value_volume)
	local value_visibly = 0
	if getPedMoveState (getLocalPlayer()) == "stand" then
		value_visibly = 60
	elseif getPedMoveState (getLocalPlayer()) == "walk" then
		value_visibly = 60
	elseif getPedMoveState (getLocalPlayer()) == "powerwalk" then
		value_visibly = 60
	elseif getPedMoveState (getLocalPlayer()) == "jog" then
		value_visibly = 60
	elseif getPedMoveState (getLocalPlayer()) == "sprint" then	
		value_visibly = 60
	elseif getPedMoveState (getLocalPlayer()) == "crouch" then	
		value_visibly = 20
	elseif not getPedMoveState (getLocalPlayer()) then	
		value_visibly = 20
	end
	if isPedInVehicle (getLocalPlayer()) then
		value_visibly = 0
	end	
	setElementData(getLocalPlayer(),"visibly",value_visibly)
end
setTimer(setStates,400,0)

local screenWidth,screenHeight = guiGetScreenSize()
local playerTarget = false

function targetingActivated ( target )
	if (target) and getElementType(target) == "player" then
		playerTarget = target
	else
		playerTarget = false
	end
end
addEventHandler ("onClientPlayerTarget",getRootElement(),targetingActivated)

weaponNoiseTable = {
	{22,20},
	{23,0},
	{24,60},
	{28,40},
	{32,40},
	{29,40},
	{30,60},
	{31,60},
	{25,40},
	{26,60},
	{27,60},
	{33,40},
	{34,60},
	{36,60},
	{35,60},
}

function getWeaponNoise(weapon)
	for i,weapon2 in ipairs(weaponNoiseTable) do
		if weapon == weapon2[1] then
			return weapon2[2]
		end
	end
	return 0
end

-- function updateIcons ()
	-- if getElementData(getLocalPlayer(),"logedin") then
		-- if playerTarget then 
			-- local x,y,z = getElementPosition(playerTarget)
			-- local x,y,distance = getScreenFromWorldPosition (x,y,z+0.5)
			-- if x and y and z and distance then
				-- if getElementData(playerTarget,"bandit") then
					-- text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' ).." (Бандит)"
				-- else
					-- text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' )
				-- end
				-- local w = dxGetTextWidth(text,20*0.033,"default-bold")
				-- dxDrawText (text,x-(w/2),y,x-(w/2), y, tocolor ( 100, 255, 100, 200 ),20*0.033, "default-bold" )
			-- end	
		-- end	
	-- end
-- end
-- addEventHandler ("onClientRender",getRootElement(),updateIcons)

function updateIcons( )
if not playerTarget then return end
local x,y,z = getElementPosition(playerTarget)
local x,y,distance = getScreenFromWorldPosition (x,y,z+0.95)
distance = 20
if getElementData(playerTarget,"bandit") then
	if getElementData(playerTarget,"armyfraction") == 1 then
			text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' ).." (Bandit)"
			local w = dxGetTextWidth(text,1,"default-bold")
			dxDrawImage(((x-(w/2))+1)-27,y-3,24, 24, "images/weapon.png", 0, 0, 0)
			dxDrawText (text,(x-(w/2))+1,y+1,x-(w/2), y, tocolor ( 0, 0, 0), 1, "default-bold" )
			dxDrawText (text,x-(w/2),y,x-(w/2), y, tocolor ( 255, 0, 0, 200), 1, "default-bold" )
		elseif getElementData ( playerTarget, "CELL" ) and getElementData ( playerTarget, "CELL" ) ~= 0 then
			text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' ).." (Bandit)"
			local w = dxGetTextWidth(text,1,"default-bold")
			dxDrawImage(((x-(w/2))+5)-27,y-3,18, 18, "data/shield.png", 0, 0, 0, tocolor(92, 141, 71))
			dxDrawText (text,(x-(w/2))+1,y+1,x-(w/2), y, tocolor ( 0, 0, 0), 1, "default-bold" )
			dxDrawText (text,x-(w/2),y,x-(w/2), y, tocolor ( 255, 0, 0, 200), 1, "default-bold" )
		elseif getElementData(playerTarget,"raiderfraction") == 1 then
			text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' ).." (Bandit)"
			local w = dxGetTextWidth(text,1,"default-bold")
			dxDrawImage(((x-(w/2))+1)-27,y-3,24, 24, "images/wheel.png", 0, 0, 0)
			dxDrawText (text,(x-(w/2))+1,y+1,x-(w/2), y, tocolor ( 0, 0, 0), 1, "default-bold" )
			dxDrawText (text,x-(w/2),y,x-(w/2), y, tocolor ( 255, 0, 0, 200), 1, "default-bold" )
		else
			text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' ).." (Bandit)"
			local w = dxGetTextWidth(text,1,"default-bold")
			dxDrawText (text,(x-(w/2))+1,y+1,x-(w/2), y, tocolor ( 0, 0, 0), 1, "default-bold" )
			dxDrawText (text,x-(w/2),y,x-(w/2), y, tocolor ( 255, 0, 0, 200), 1, "default-bold" )
			end
		else
		if getElementData(playerTarget,"armyfraction") == 1 then
			text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' )
			local w = dxGetTextWidth(text,1,"default-bold")
			dxDrawImage(((x-(w/2))+1)-27,y-3,24, 24, "images/weapon.png", 0, 0, 0)
			dxDrawText (text,(x-(w/2))+1,y+1,x-(w/2), y, tocolor ( 0, 0, 0), 1, "default-bold" )
			dxDrawText (text,x-(w/2),y,x-(w/2), y, tocolor ( 100, 255, 100, 200 ), 1, "default-bold" )
		elseif getElementData ( playerTarget, "CELL" ) and getElementData ( playerTarget, "CELL" ) ~= 0 then
			text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' )
			local w = dxGetTextWidth(text,1,"default-bold")
			dxDrawImage(((x-(w/2))+5)-27,y-3,18, 18, "data/shield.png", 0, 0, 0, tocolor(92, 141, 71))
			dxDrawText (text,(x-(w/2))+1,y+1,x-(w/2), y, tocolor ( 0, 0, 0), 1, "default-bold" )
			dxDrawText (text,x-(w/2),y,x-(w/2), y, tocolor ( 100, 255, 100, 200 ), 1, "default-bold" )
		elseif getElementData(playerTarget,"raiderfraction") == 1 then
			text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' )
			local w = dxGetTextWidth(text,1,"default-bold")
			dxDrawImage(((x-(w/2))+1)-27,y-3,24, 24, "images/wheel.png", 0, 0, 0)
			dxDrawText (text,(x-(w/2))+1,y+1,x-(w/2), y, tocolor ( 0, 0, 0), 1, "default-bold" )
			dxDrawText (text,x-(w/2),y,x-(w/2), y, tocolor ( 100, 255, 100, 200 ), 1, "default-bold" )
		else
			text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' )
			local w = dxGetTextWidth(text,1,"default-bold")
			dxDrawText (text,(x-(w/2))+1,y+1,x-(w/2), y, tocolor ( 0, 0, 0), 1, "default-bold" )
			dxDrawText (text,x-(w/2),y,x-(w/2), y, tocolor ( 100, 255, 100, 200 ), 1, "default-bold" )
		end
	end
end	
addEventHandler ("onClientRender",getRootElement(),updateIcons)

function dayZDeathInfo ()
	local x, y, z, lx, ly, lz = getCameraMatrix ()
	lz = lz + 180
	setCameraMatrix (x, y, z, lx, ly, lz)
	--playSound("sounds/panic_0.ogg")
end
addEvent("onClientPlayerDeathInfo",true)
addEventHandler("onClientPlayerDeathInfo",getRootElement(),dayZDeathInfo)

whiteWindow = guiCreateStaticImage(0,0,1,1,"data/white.png",true)
guiSetVisible(whiteWindow,false)

function showPlayerDamageScreen (visibly2,stateControle2)
	guiSetVisible(whiteWindow,true)
	visibly = visibly2 or visibly
	stateControle = stateControle2 or stateControle
	if visibly >= 6*0.025 and stateControle == "up" then
		stateControle = "down"
	end
	if visibly < 0 then
		guiSetVisible(whiteWindow,false)
		return
	end
	if stateControle == "up" then
		visibly = visibly + 0.025
	elseif stateControle == "down" then
		visibly = visibly - 0.025
	end
	guiSetAlpha(whiteWindow,visibly)
	setTimer(showPlayerDamageScreen,50,1)
end

function showWhiteScreen ( attacker, weapon, bodypart )
	showPlayerDamageScreen(0,"up")
end
addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), showWhiteScreen )

function updatePlayTime()
	if getElementData(getLocalPlayer(),"logedin") then
		local playtime = getElementData(getLocalPlayer(),"alivetime")
		setElementData(getLocalPlayer(),"alivetime",playtime+1)
	end
end
setTimer(updatePlayTime, 60000, 0)

function checkVehicleInWaterClient ()
	
	-- --[[vehiclesInWater = {}
	-- for i,veh in ipairs(getElementsByType("vehicle")) do
		-- if isElementInWater(veh) then
            -- if getElementHealth(veh) >= 1 then
				-- table.insert(vehiclesInWater,veh)
			-- end
		-- end
	-- end
	-- triggerServerEvent("respawnVehiclesInWater",getLocalPlayer(),vehiclesInWater)]]
end
addEvent("checkVehicleInWaterClient",true)
addEventHandler("checkVehicleInWaterClient",getRootElement(),checkVehicleInWaterClient)

local pingFails = 0
function playerPingCheck ()
	if getPlayerPing(getLocalPlayer()) > gameplayVariables["ping"] then
		pingFails = pingFails +1
		if pingFails == 3 then
			triggerServerEvent("kickPlayerOnHighPing",getLocalPlayer())
			return
		end
		startRollMessage2("Ping", "[PingKicker] Your ping is over 200! (: "..gameplayVariables["ping"]..") warning ("..pingFails.."/3)", 255, 0, 0 )
		if isTimer(pingTimer) then return end
		pingTimer = setTimer(function()
			pingFails = 0
		end,30000,1)
	end
end
setTimer(playerPingCheck,4000,0)

bindKey ( 'aim_weapon', 'both', 
    function ( _, state ) 
        if getPedWeaponSlot ( localPlayer ) == 6 then 
        if ( state == 'down' ) then 
            alpha = 0 
        elseif ( state == 'up' ) then 
        alpha = 255 
    end 
    for _, v in ipairs ( getElementsByType ( 'object', root, true ) ) do 
        if isElementAttachedToBone ( v ) then 
            local id = getElementModel ( v ) 
                if ( id == 1854 ) then 
                    setElementAlpha ( v, alpha ) 
	            elseif ( id == 2125 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 2763 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 2776 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 2123 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 1820 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 2708 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 2405 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 1513 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 1902 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 1903 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 14802 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 1907 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 1909 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 1910 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 14753 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 3921 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 14752 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 14788 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 14779 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 1905 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 1906 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 1550 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 18055 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 2383 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 2053 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 14837 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 1242 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 1952 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 1920 ) then
                    setElementAlpha ( v, alpha )
				elseif ( id == 15036 ) then
                    setElementAlpha ( v, alpha )
	            end 
            end 
        end 
    end 
end 
)

theTexts = {}
theTextTimer = {}
function startRollMessage(text, r, g, b)
	if #theTexts == 4 then
		destroyTextItem()
	end
	table.insert(theTexts,{text,r,g,b})
	checkTimers()
end
addEvent("onRollMessageStart", true)
addEventHandler("onRollMessageStart", getLocalPlayer(), startRollMessage)

function startRollMessage2(head,text, r, g, b)
	if #theTexts == 4 then
		destroyTextItem()
	end
	table.insert(theTexts,{text,r,g,b})
	checkTimers()
end
addEvent("displayClientInfo", true)
addEventHandler("displayClientInfo", getLocalPlayer(), startRollMessage2)

function destroyTextItem ()
	table.remove(theTexts,1)
end

function checkTimers ()
	if isTimer(theTextTimer["destroy"]) then
		killTimer(theTextTimer["destroy"])
	end
	theTextTimer["destroy"] = setTimer(destroyTextItem,4000,4)
end

local screenWidth, screenHeight = guiGetScreenSize()
local boxSpace = dxGetFontHeight(1,"default-bold")+dxGetFontHeight(1,"default-bold")*0.3
local screenWidth, screenHeight = guiGetScreenSize()
local sW, sH =  (screenWidth/1280), (screenHeight/720)
local boxSpace = dxGetFontHeight(1, "default-bold")+dxGetFontHeight(1, "default-bold")*0.3

addEventHandler("onClientRender", root, 
	function()
		for id, value in pairs(theTexts) do
			local length = dxGetTextWidth(value[1], 1, "default-bold")
            dxDrawText(value[1], 690*sW, 697*sH-id*boxSpace, length*1.1, screenHeight-(id-1)*boxSpace, tocolor(0, 0, 0, 170), 1, "default-bold", "center", "center")			
			dxDrawText(value[1], 688*sW, 695*sH-id*boxSpace, length*1.1, screenHeight-(id-1)*boxSpace, tocolor(value[2], value[3], value[4], 170), 1, "default-bold", "center", "center")
		end
	end
)

bindKey ( "aim_weapon", "both",function(_,state) 
	if getPedWeaponSlot ( localPlayer ) == 6 then 
		if ( state == "down" ) then alpha = 0 
		elseif ( state == "up" ) then alpha = 255 end 
		for i,v in pairs (clothSlots) do
			local object = getElementData (localPlayer, i.."Object")
			if object and isElement ( object ) then
				setElementAlpha ( object, alpha ) 
			end
		end
	end 
end)

local althVehicles = {
	[592] = true,[577] = true,[511] = true,[548] = true,
	[512] = true,[593] = true,[425] = true,[520] = true,
	[417] = true,[487] = true,[553] = true,[488] = true,
	[497] = true,[563] = true,[476] = true,[447] = true,
	[519] = true,[460] = true,[469] = true,[513] = true,
}

local screenSize = { guiGetScreenSize() }
addEventHandler("onClientRender",root,function()
	local veh = getPedOccupiedVehicle(getLocalPlayer())
	if veh then
		-- speed
		if (getElementData (localPlayer, "hideTable") or {}).spid then return true end
		local speed = getElementSpeed(veh,"km/h")
		dxDrawBox(screenSize[1] * 0.400-1, screenSize[2] * 0.025+1, screenSize[1] * 0.03, screenSize[2] * 0.03,tocolor(0,0,0,255))
		dxDrawBox(screenSize[1] * 0.400, screenSize[2] * 0.025, screenSize[1] * 0.03, screenSize[2] * 0.03,tocolor(120,171,114,255))
		dxDrawTextShadow(""..math.floor(speed).."",screenSize[1] * 0.404, screenSize[2] * 0.031,screenSize[1] * 0.04, screenSize[2] * 0.04,tocolor(120,171,114,255),1.0,"default-bold")
		dxDrawTextShadow("SPD:",screenSize[1] * 0.375, screenSize[2] * 0.031,screenSize[1] * 0.04, screenSize[2] * 0.04,tocolor(120,171,114,255),1.0,"default-bold")
		-- health
		local health = (math.floor(getElementHealth(veh))/10)
		dxDrawTextShadow("V-HP: "..health.."%",screenSize[1] * 0.375, screenSize[2] * 0.065,screenSize[1] * 0.04, screenSize[2] * 0.04,tocolor(120,171,114,255),1.0,"default-bold")
		-- alt
		if althVehicles[getElementModel(veh)] then
			local vPos = { getElementPosition(veh) }
			dxDrawBox(screenSize[1] * 0.470-1, screenSize[2] * 0.025+1, screenSize[1] * 0.03, screenSize[2] * 0.03,tocolor(0,0,0,255))
			dxDrawBox(screenSize[1] * 0.470, screenSize[2] * 0.025, screenSize[1] * 0.03, screenSize[2] * 0.03,tocolor(120,171,114,255))
			dxDrawTextShadow(""..math.floor(vPos[3]).."",screenSize[1] * 0.474, screenSize[2] * 0.031,screenSize[1] * 0.04, screenSize[2] * 0.04,tocolor(120,171,114,255),1.0,"default-bold")
			dxDrawTextShadow("ALT:",screenSize[1] * 0.445, screenSize[2] * 0.031, screenSize[1] * 0.04, screenSize[2] * 0.04, tocolor(120,171,114,255),1.0,"default-bold")
		end
	end	
end)

function getElementSpeed(theElement, unit)
    assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")")
    assert(getElementType(theElement) == "player" or getElementType(theElement) == "ped" or getElementType(theElement) == "object" or getElementType(theElement) == "vehicle", "Invalid element type @ getElementSpeed (player/ped/object/vehicle expected, got " .. getElementType(theElement) .. ")")
    assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)")
    unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit))
    local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456)
    return (Vector3(getElementVelocity(theElement)) * mult).length
end

function dxDrawBox(x,y,w,h,lcolor)
	dxDrawLine(x - 1, y - 1, x - 1, y + h, lcolor, 1)
	dxDrawLine(x + w, y - 1, x + w, y + h, lcolor, 1)
	dxDrawLine(x - 1, y + h, x + w, y + h, lcolor, 1)
	dxDrawLine(x - 1, y - 1, x + w, y - 1, lcolor, 1)
end

function dxDrawTextShadow(text,x,y,size1,size2,color,fontSize,font)
	dxDrawText(text,x-1,y+1,size1, size2,tocolor(0,0,0,255),fontSize,font)
	dxDrawText(text,x,y,size2,size2,color,fontSize,font)
end

function drawLine(x,y,w,h,lcolor)
    dxDrawLine(x - 1, y + h, x + w, y + h, lcolor, 1)
end

workingTrap = false 
function showTrapMenu () 
    if not workingTrap then 
        workingTrap = source 
        showCursor ( true ) 
        bagWindow = guiCreateWindow(0.44, 0.40, 0.16, 0.15, "Trap Menu", true) 
        guiWindowSetSizable(bagWindow, false) 
        guiSetAlpha(bagWindow, 1.00) 
        takeBag = guiCreateButton(0.07, 0.40, 0.86, 0.22, "Remove", true, bagWindow) 
        guiSetProperty(takeBag, "NormalTextColour", "FFAAAAAA") 
        closeBag = guiCreateButton(0.07, 0.70, 0.86, 0.22, "Close", true, bagWindow) 
        guiSetProperty(closeBag, "NormalTextColour", "FFAAAAAA") 
        guiSetVisible ( bagWindow, true ) 
        addEventHandler ( "onClientGUIClick", takeBag, takeTrapClicked, false ) 
        addEventHandler ( "onClientGUIClick", closeBag, function ()       
        setElementData ( workingTrap, "inUse", false ) 
        workingTrap = false 
        destroyElement ( bagWindow ) 
        showCursor ( false ) 
        end, false ) 
    end 
end           
addEvent( "showTrapMenuS", true ) 
addEventHandler( "showTrapMenuS", getRootElement(), showTrapMenu ) 

function openTrapClicked () 
    if isElement ( workingTrap ) then 
        setElementData ( workingTrap, "closed", false ) 
        triggerServerEvent ( "openTrapC", workingTrap ) 
    end 
    setElementData ( workingTrap, "inUse", false ) 
    workingTrap = false 
    destroyElement ( bagWindow ) 
    showCursor ( false ) 
end 

function takeTrapClicked () 
    if isElement ( workingTrap ) then 
        triggerServerEvent ( "takeTrapFromClient", localPlayer, workingTrap ) 
    end 
    setElementData ( workingTrap, "inUse", false ) 
    workingTrap = false 
    destroyElement ( bagWindow ) 
    showCursor ( false ) 
end

function playMusicNearMilitaryBoxes(pos)
	for i,v in ipairs(pos) do
		local sound = playSound3D("sounds/sirena.mp3",v[1],v[2],v[3])
		setSoundMaxDistance(sound,2000)
	end
end
addEvent("playMusicNearMilitaryBoxes",true) 
addEventHandler("playMusicNearMilitaryBoxes",getRootElement(),playMusicNearMilitaryBoxes)

addEventHandler("onClientRender",root,
function()
    local x,y,z = getElementPosition(localPlayer)
    for i,veh in ipairs(getElementsByType("vehicle",getRootElement(),true)) do
        if veh ~= getPedOccupiedVehicle(localPlayer) then
            local vx,vy,vz = getElementPosition(veh)
            if getDistanceBetweenPoints3D(x,y,z,vx,vy,vz) <= 4 then
                local sx,sy = getScreenFromWorldPosition(vx,vy,vz+0.95,0.06)
                if sx then
                    local vehicleName = returnNewNameVehicle(veh)
                    local w = dxGetTextWidth(vehicleName,1.02,"default-bold")
                    dxDrawText(vehicleName,sx-(w/2),sy,sx-(w/2),sy,tocolor(255,255,255,200),0.7,"bankgothic")
                end
            end
        end
    end
end)

function shakeCamera(weapon)
     x,y,z = getPedBonePosition ( getLocalPlayer(), 26 )
     if weapon == 22  then
     createExplosion ( x,y,z + 10,12,false,0.1,false)
        elseif weapon == 24  then
     createExplosion ( x,y,z + 10,12,false,0.2,false)
        elseif weapon == 25  then
     createExplosion ( x,y,z + 10,12,false,0.4,false)
        elseif weapon == 26  then
     createExplosion ( x,y,z + 10,12,false,0.5,false)
        elseif weapon == 27  then
     createExplosion ( x,y,z + 10,12,false,0.4,false)
        elseif weapon == 28  then
     createExplosion ( x,y,z + 10,12,false,0.1,false)
        elseif weapon == 29  then
     createExplosion ( x,y,z + 10,12,false,0.1,false)
        elseif weapon == 30  then
     createExplosion ( x,y,z+10,12,false,0.1,false)
        elseif weapon == 31  then
     createExplosion ( x,y,z + 10,12,false,0.1,false)
        elseif weapon == 32  then
     createExplosion ( x,y,z + 10,12,false,0.1,false)
        elseif weapon == 33  then
     createExplosion ( x,y,z + 10,12,false,0.1,false)
        elseif weapon == 38  then
     createExplosion ( x,y,z + 10,12,false,0.5,false)
   end
end
addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), shakeCamera ) 

playerBlibs1 = {}
amouunt1 = 0
function updateGPS2 ()
    if not getElementData(getLocalPlayer(),"logedin") then return end    
    amouunt1 = 0
    for i, blip in ipairs(playerBlibs1) do
        if isElement(blip) then
            destroyElement(blip)
        end
    end
    playerBlibs1 = {}    
    for i, player in ipairs(getElementsByType("player")) do
        if getElementData(localPlayer,"radiowave") == getElementData(player,"radiowave") and getElementData(player,"GPS") >= 1 and getElementData(localPlayer,"GPS") >= 1 and player ~= localPlayer then
            amouunt1 = amouunt1+1
            playerBlibs1[amouunt1] = createBlipAttachedTo(player,59,2,0,0,255)
            setBlipVisibleDistance(playerBlibs1[amouunt1],1000)
        end
    end
end
setTimer(updateGPS2,5000,0)

wx, hy = guiGetScreenSize()
local x, y = wx/2, hy/10

function drawXp()
	local start = 0
	local xp = getElementData ( localPlayer, "xp" ) or 0
	local level = getElementData ( localPlayer, "level" ) or 1
	local nextLevelXP = getElementData ( localPlayer, "nextLevelXP") or 100 
	local dw = math.floor(350/nextLevelXP*xp)
	if xp < 1 then
		dw = 0
	end
	if xp > nextLevelXP then
		dw = 100
	end
	if xp > 0 then
		r,g,b = 0,50,0
	end
	dxDrawRectangle(wx-1051, hy-26+start,351,16, tocolor(0,0,0, 190))
	dxDrawRectangle(wx-1050, hy-25+start,dw,14, tocolor(r,g,b,180)) 
	dxDrawText(xp.." XP",wx-920+52/2,hy-25+start,100,20,tocolor ( 255,255,255,255 ), 1, "default-bold" )
	dxDrawText ("Level: "..level, 15, hy-50, 200, hy, tocolor ( 255, 255, 255, 200 ), 1.1, "default-bold" )
	dxDrawText ("XP Remains before next level: "..tostring((getElementData ( localPlayer, "nextLevelXP") or 100 )-xp).."", 15, hy-25, 200, hy, tocolor ( 255, 255, 255, 200 ), 1.02, "default-bold" )
end

bindKey("lalt", "both", function(key, state)        
	if state == "down" then 
		addEventHandler("onClientRender", root, drawXp)
	else
		removeEventHandler("onClientRender", root, drawXp) 
	end 
end)

local htmlvehrep = {
	{value = 0, r = 255, g = 0, b = 0},
	{value = 100, r = 255, g = 0, b = 0},
	{value = 200, r = 255, g = 10, b = 0},
	{value = 300, r = 255, g = 20, b = 0},
	{value = 400, r = 200, g = 30, b = 0},
	{value = 500, r = 170, g = 40, b = 0},
	{value = 600, r = 150, g = 60, b = 10},
	{value = 700, r = 130, g = 80, b = 20},
	{value = 800, r = 120, g = 90, b = 30},
	{value = 900, r = 90, g = 123, b = 40},
	{value = 1000, r = 79, g = 133, b = 51},
}


function getColorWithPartvehrep(value)
	for i, htmlRgB in ipairs(htmlvehrep) do
		if value <= htmlRgB.value then
			return htmlRgB.r,htmlRgB.g,htmlRgB.b
		end
	end
end

bindKey("space","down",function()
	if getElementData(localPlayer,"repairerTab") == true then
		triggerServerEvent("onClientMovesWhileAnimation",localPlayer)
		setElementData(localPlayer,"repairerTab",false)
	end
end)

wx, hy = guiGetScreenSize()
local x, y = wx/2, hy/10
		   
addEventHandler("onClientRender",root,
function()
    local x,y,z = getElementPosition(localPlayer)
    for i,veh in ipairs(getElementsByType("vehicle",getRootElement(),true)) do
	if getElementData(localPlayer,"repairerTab") == true then
        if veh ~= getPedOccupiedVehicle(localPlayer) then
            local vx,vy,vz = getElementPosition(veh)
            if getDistanceBetweenPoints3D(x,y,z,vx,vy,vz) <= 7 then
                local sx,sy = getScreenFromWorldPosition(vx,vy,vz)
                if sx then
					local start = 0
					local dw = math.floor(100/255*getElementHealth(veh))
						if getElementHealth(veh) < 1 then
							dw = 0
						end
						if getElementHealth(veh) > 1000 then
							dw = 100
						end
						if ( getElementHealth(veh) or 0 ) > 0 then
							r,g,b = getColorWithPartvehrep(getElementHealth(veh))
						else
							r,g,b = 255,50,0
						end
						local dw2 = math.floor(100/1000*getElementHealth(veh))
						local twd =  dxGetTextWidth(tostring(dw2.."%"),1,"default-bold")
						dxDrawRectangle(wx/2-394/2-1, hy-141+start,394,16, tocolor(0,0,0, 190))
						dxDrawRectangle(wx/2-394/2, hy-140+start,dw,14, tocolor(r,g,b,180)) 
						dxDrawText(dw2.."%",wx/2-twd/2,hy-140+start,100,20,tocolor ( 255,255,255,255 ), 1, "default-bold" )
						local twd =  dxGetTextWidth("For cancel repair , press< space >!",1,"default-bold")
						dxDrawText("For cancel repair , press < space >!",wx/2-1-twd/2,hy-161+start,100,20,tocolor ( 0,0,0,255 ), 1, "default-bold" )
						dxDrawText("For cancel repair , press < space >!",wx/2-twd/2,hy-160+start,100,20,tocolor ( 255,255,255,255 ), 1, "default-bold" )
					end
               end
            end
        end
    end
end)

 

Share this post


Link to post

Le code que tu as mis n'a rien à voir avec ce que tu nous a montré en haut, essaie de faire l'une des méthodes que je t'ai dis.

Share this post


Link to post

Juste pour info évite de coller des milliers de lignes de codes ici. Perso chez moi ça me fait crasher Chrome sur mon téléphone et ça l'a bien fait freeze avant de me redonner la main sur mon pc.

Pour ton problème je suis d'accord avec Wumbaloo, il faut ajouter une condition avant d'exécuter le trigger de l'event onPlayerUseMedicObject et qui doit certainement être dans le code client de l'inventaire.

Un petit boolean isHealing ou isUsingMedic que tu initialises à false au démarrage du script. Puis lorsque que le joueur a fait l'action en choisissant son heal, tu vérifies si le boolean est toujours à false, si c'est le cas tu fais le trigger de onPlayerUseMedicObject, tu passes le boolean à true et également un setTimer de 1500 ms pour le remettre à false.
Et si ce n'est pas le cas (le boolean est à true) c'est qu'il y a déjà une action de heal en cours donc tu ne fais rien (tu ne fais pas -1 sur son item utilisé et tu ne fais pas le trigger de onPlayerUseMedicObject).

  • Like 1

Share this post


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.