View difference between Paste ID: fpjKrZuV and 0Dzc92NZ
SHOW: | | - or go back to the newest paste.
1
-------------------------------------------------  SERVER SIDE ------------------------------------------------- 
2-
addEventHandler("onPlayerTarget",root,
2+
addEvent("onAimHandler",true)
3-
	function(target)
3+
function onAim()
4-
		if target and isElement(target) and getElementType(target) == "ped" and target == ped then
4+
	local name = getPlayerName(source)
5-
			local sourceName = getPlayerName(source)
5+
	outputChatBox(name.." got 1 star for aiming at the staff ped!",root,255,0,0)
6-
			outputChatBox(sourceName.." got warned for aiming at the staff ped!",root,255,158,0)
6+
	outputChatBox("You got wanted for aiming at the staff ped!",source,255,0,0)
7-
			outputChatBox("You got wanted for aiming at the staff ped!",source,255,0,0)
7+
	local wantedLevel = getPlayerWantedLevel(source)
8-
			local wantedLevel = getPlayerWantedLevel(source)
8+
	setPlayerWantedLevel(source,wantedLevel+1 or 1)
9-
			setPlayerWantedLevel(source,wantedLevel+1 or 1)
9+
end
10-
		end
10+
addEventHandler("onAimHandler,resourceRoot,onAim)
11
12-
)
12+
------------------------------------------------- CLIENT SIDE ------------------------------------------------- 
13
14
local ped = createPed(217,0,0,3)
15
function onClientJoin()
16
	bindKey(source,"aim_weapon","down",onPlayerAim)
17
end
18
addEventHandler("onClientPlayerJoin",root,onClientJoin)
19
20
function onPlayerAim()
21
	local target = getPedTarget(localPlayer)
22
	if target and isElement(target) and getElementType(target) == "ped" and target == ped then
23
		triggerServerEvent("onAimHandler",localPlayer)
24
	end
25
end