Tokio

[HELP] Why not working this script?

Recommended Posts

CLIENT:

function cancelTazerDamage(attacker, weapon, bodypart, loss)
	if (weapon==24) then -- deagle
		local mode = getElementData(attacker, "handTaser")
		if (mode==true) then
			cancelEvent()
		end
	end
end
addEventHandler("onClientPlayerDamage", localPlayer, cancelTazerDamage)

local cFunc = {}
local cSetting = {}

cSetting["shots"] = {}
cSetting["shot_calcs"] = {}
local last_shot = 1

cFunc["draw_shot"] = function(x1, y1, z1, x2, y2, z2)
	table.insert(cSetting["shots"], last_shot, {x1, y1, z1, x2, y2, z2})
	local lastx, lasty, lastz = x1, y1, z1
	local dis = getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2)
	cSetting["shot_calcs"][last_shot] = {}

	last_shot = last_shot+1
end

cFunc["wait_shot"] = function()
	toggleControl("fire", false)
	setTimer(function()
		toggleControl("fire", true)
	end, 15000, 1)
end

cFunc["shot_check"] = function(wp, _, _, hitX, hitY, hitZ, element, startX, startY, startZ)
	if(wp == 24) and (getElementData(localPlayer,"handTaser"))then
		cFunc["shot_weapon"](hitX, hitY, hitZ, startX, startY, startZ)
		cancelEvent()
		if(source == localPlayer) then
			cFunc["wait_shot"]()
		end
	end
end

cFunc["anim_check"] = function(attacker, wep, bodypart,loss)
	if(wep == 24) and (getElementData(localPlayer,"handTaser"))then
		local playerX,playerY,playerZ = getElementPosition(localPlayer)
		local targetX,targetY,targetZ = getElementPosition(source)
		if getDistanceBetweenPoints3D(playerX,playerY,playerZ,targetX,targetY,targetZ) <= 12 then
			triggerServerEvent("tazerFired", getRootElement(), source) 
		end
	end
end

addEventHandler("onClientPlayerWeaponFire", getRootElement(), cFunc["shot_check"])
addEventHandler("onClientPedDamage", getRootElement(),cFunc["anim_check"])
addEventHandler("onClientPlayerDamage", getRootElement(),cFunc["anim_check"])

addEventHandler("onClientResourceStart",resourceRoot,function()
	setElementData(localPlayer, "tazed",0)
end)

addEventHandler("onClientRender",getRootElement(),function()
	if getElementData(localPlayer, "tazed") == 1 then
		toggleAllControls(false, false, false)
		toggleControl("fire", false)
		toggleControl("sprint", false)
		toggleControl("crouch", false)
		toggleControl("jump", false)
		toggleControl('next_weapon',false)
		toggleControl('previous_weapon',false)
		toggleControl('aim_weapon',false)
	end
end)

SERVER:
 

local cFunc = {}
local cSetting = {}

function tazerFired(target)
	if (isElement(target) and getElementType(target)=="player") then
		fadeCamera ( target, false, 1.0, 255, 255, 255 )
		setElementData(target, "tazed", 1)
		toggleAllControls(target, false, false, false)
		setPedAnimation(target, "ped", "FLOOR_hit_f", -1, false, false, true)
		setTimer(removeAnimation, 30000, 1, target)
	end
end
addEvent("tazerFired", true )
addEventHandler("tazerFired", getRootElement(), tazerFired)

function removeAnimation(thePlayer)
	if (isElement(thePlayer) and getElementType(thePlayer)=="player") then
		fadeCamera(thePlayer, true, 0.5)
		if getElementData(thePlayer,"isAnim") then
			setElementFrozen(thePlayer,true)
			setPedAnimation(thePlayer,"sweet","sweet_injuredloop",-1,false,false,false)
		else
			setPedAnimation(thePlayer,nil,nil)
			toggleAllControls(thePlayer, true, true, true)
		end
		setElementData(thePlayer, "tazed", 0)
	end
end

I do not get any errors/warnings in debugscript 3, just simply does not working the script.. What wrong in this codes? :s

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.