Jump to content

تصحيح كود


Recommended Posts

لاهنت الوحه ماتبي تفتح + ممكن تضيفو لزر الهنتر انه الزر ينقفل 5 دقايق مايقدر ينزل هنتر فيهم ؟ يعني ابي الهنتر تنزل كل 5 دقايق

الكود 

كلينت #


    triggerServerEvent ( "onServerIsRG", getLocalPlayer(),getLocalPlayer(), grp)
    if getElementData(getLocalPlayer(),"IsRG") == tostring(grp) then
    return true
    end
    return false
 
 
 guiAntiFlood(element, timer)
    if getElementType ( element ) == "gui-button" then
        local atimer = tonumber(timer)
        if atimer == nil or atimer == '' or not tonumber(atimer) then
            error("Bad Argument the Argument 2 must number")
        else
        end
        guiSetEnabled(element,false)
        setTimer(function()
        guiSetEnabled(element,true)
        end,tonumber(atimer),1)
    else
        error("Bad Argument 1 the element must button")
  end
end


GUIEditor = {
    button = {},
    progressbar = {},
    label = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
    function()
        vip_system = guiCreateWindow(67, 29, 671, 394, "VIP System", false)
        guiWindowSetSizable(vip_system, false)
        guiSetAlpha(vip_system, 1.00)
		guiSetVisible(vip_system,false)
        sb = guiCreateButton(10, 56, 159, 33, "Spawn BodyGard", false, vip_system,false)--lv 1
        guiSetProperty(sb, "NormalTextColour", "FF7DFD00")
        hunter = guiCreateButton(178, 271, 159, 33, "Hunter", false, vip_system,false)--lv 3
        guiSetProperty(hunter, "NormalTextColour", "FF04F7CC")
        maske = guiCreateButton(9, 271, 159, 33, "VIP Maske", false, vip_system,false)--lv 2
        guiSetProperty(maske, "NormalTextColour", "FF04F7CC")
        gm = guiCreateButton(178, 228, 159, 33, "+120 Minigun", false, vip_system,false)--lv 2
        guiSetProperty(gm, "NormalTextColour", "FF00FCE8")
        vs = guiCreateButton(9, 228, 159, 33, "VIP Style", false, vip_system)--lv 0
        guiSetProperty(vs, "NormalTextColour", "FF04F7CC")
        hc = guiCreateButton(179, 185, 159, 33, "Hover Car", false, vip_system,false)--lv 2
        guiSetProperty(hc, "NormalTextColour", "FF00FCE8")
        fc = guiCreateButton(9, 185, 159, 33, "Fly Car", false, vip_system,false)--lv 3
        guiSetProperty(fc, "NormalTextColour", "FF00FCE8")
        gl = guiCreateButton(178, 142, 159, 33, "+5 Launcher", false, vip_system,false)--lv 2
        guiSetProperty(gl, "NormalTextColour", "FF7DFD00")
        skin = guiCreateButton(10, 142, 159, 33, "VIP Skin", false, vip_system,false)--lv 1
        guiSetProperty(skin, "NormalTextColour", "FF7DFD00")
        hp = guiCreateButton(178, 99, 159, 33, "Heatlh +200", false, vip_system)--lv 0
        guiSetProperty(hp, "NormalTextColour", "FF7DFD00")
        armor = guiCreateButton(9, 99, 159, 33, "Armor +100", false, vip_system)--lv 0
        guiSetProperty(armor, "NormalTextColour", "FF7DFD00")
        rb = guiCreateButton(178, 56, 159, 33, "Remove BodyGard", false, vip_system,false)--lv 1
        guiSetProperty(rb, "NormalTextColour", "FF7DFD00")
        GUIEditor.label[1] = guiCreateLabel(8, 23, 658, 17, "==========================================================================================", false, vip_system)
        guiLabelSetColor(GUIEditor.label[1], 17, 64, 237)
        cl = guiCreateButton(575, 349, 86, 35, "X|Close|X", false, vip_system) --lv 0
        guiSetProperty(cl, "NormalTextColour", "FFFA0000")
        GUIEditor.progressbar[1] = guiCreateProgressBar(347, 40, 15, 344, false, vip_system)

        fc2 = guiCreateButton(393, 105, 114, 33, "Fix Car ", false, vip_system) --lv 0
        guiSetProperty(fc2, "NormalTextColour", "FF0808F1")
        sc = guiCreateButton(393, 62, 114, 33, "Spawn Car", false, vip_system,false)--lv 1
        guiSetProperty(sc, "NormalTextColour", "FF0808F1")    
    end
) 



show = false
addCommandHandler("vip",function()
if isPlayerGroupName("VIP") then
	if show == false then
		guiSetVisible(vip_system,true)
		showCursor(true)
		show = true
	else
		guiSetVisible(vip_system,false) 
		showCursor(false)
		show = false
	end
	VipFix()
else
	outputChatBox("You Dont Have VIP",255,0,0)
end
end)

addEventHandler("onClientGUIClick",root,function()
	if (source == cl) then
		guiSetVisible(vip_system,false)
		showCursor(false)
		show = false
	end
end)

addEventHandler("onClientGUIClick",root,function()
	if (source == armor) then
		triggerServerEvent("armorg",localPlayer)
			guiAntiFlood(armor,5*10000)
	elseif (source == hp) then
		triggerServerEvent("helathg",localPlayer)
			guiAntiFlood(hp,5*10000)
	elseif (source == hc) then
			hoverc()
	elseif (source == fc) then
			flyc()
	elseif (source == gl) then
		setElementData(localPlayer,"Launcher",(getElementData(localPlayer,"Launcher") or 0) + 7)
		outputChatBox("You Get +5 Launcher",0,255,0)
			guiAntiFlood(gl,10*10000) 
	elseif (source == skin) then
		triggerServerEvent("Sking",localPlayer)
	elseif (source == gm) then
		triggerServerEvent("waepong",localPlayer)
			guiAntiFlood(gm,15*10000)
	elseif (source == sb) then
		triggerServerEvent ( "ss", localPlayer)
			guiAntiFlood(sb,5*10000)
	elseif (source == rb) then
		triggerServerEvent("onClinetSpawnMonture",localPlayer)
		guiAntiFlood(rb,5*10000)
	elseif (source == sc) then
		local row, col = guiGridListGetSelectedItem (gc)
		if ( row and col and row ~= -1 and col ~= -1 ) then
		local CarsName = guiGridListGetItemText (gc, guiGridListGetSelectedItem (gc), 1 )
		triggerServerEvent("VIPsetPedCars",localPlayer,CarsName)
	elseif (source == fc2) then
		cc()
		end
	elseif (source == hunter) then
		triggerServerEvent("hunterg",localPlayer)
			guiAntiFlood(hunter,10*10000)
	elseif (source == maske) then
		executeCommandHandler("maske")
	end
end)


function VipFix()
guiGridListClear ( gc )
for i=1,#CarsList do
local row = guiGridListAddRow ( gc )
guiGridListSetItemText ( gc, row, 1, tostring ( CarsList[i][1] ), false, false )
end
end

addCommandHandler("bb",function()
	triggerServerEvent("ss",localPlayer)
end)


function hoverc()
	if isWorldSpecialPropertyEnabled("hovercars") then
		setWorldSpecialPropertyEnabled("hovercars",false)
		outputChatBox("Hover Cras Stop",255,0,0)
	else
		setWorldSpecialPropertyEnabled("hovercars",true)
		outputChatBox("Hover Cras Started",0,255,0)
	end
end

function flyc()
	if isWorldSpecialPropertyEnabled("aircars") then
		setWorldSpecialPropertyEnabled("aircars",false)
		outputChatBox("Fly Cras Stop",255,0,0)
	else
		setWorldSpecialPropertyEnabled("aircars",true)
		outputChatBox("Fly Cras Started",0,255,0)
	end
end

function cc()
		local veh = getPedOccupiedVehicle(localPlayer)
		if getElementHealth(veh) < 800 then
		triggerServerEvent("VIPfixVehicle",localPlayer)
		guiSetEnabled( fc2,false)
		setTimer(guiSetEnabled,60000,1, fc2,true)
		else
		exports["guimessages"]:outputClient("#3399FF[VIP System] : #FF0000The Cars Must Be Broken !",0,255,255)
		end
end

---BodyGard---
local pedTarget = {}
local pedTimer = {}
local pedShooting = {}
local AnimalFollowing = {}

addEvent( "onSyncPlayerAnimals", true )
addEventHandler( "onSyncPlayerAnimals", root,
	function ( theTable )
		animalTable = theTable
		--addEventHandler( "onClientPreRender", root, setAnimalFollowing)
		AnimalFollowing[localPlayer] = true
	end
)

local function doPedAttackOtherPlayer(ped)
	if(isTimer(pedTimer[ped])) or (isPedInVehicle(ped)) then
		killTimer(pedTimer[ped])
	end
	if(isElement(ped)) then
		pedTimer[ped] = setTimer(function()
		    if(isElement(ped)) then
			local target = pedTarget[ped]
			if (target) then
				local x, y, z = getElementPosition(ped)
				local x2, y2, z2 = getElementPosition(target)
				if(isLineOfSightClear(x, y, z, x2, y2, z2, true, false, false, false, false, false)) then
					if (getElementType(target) == "player") and getElementData(target, "LegalStatus") == "Jailed" then
						local theOwner = getElementData( ped, "animalOwner" )
						killTimer(pedTimer[ped])
						pedShooting[ped] = false
						setPedControlState(ped, "fire", false)
						if (isEventHandel == false) then
						--addEventHandler( "onClientPreRender", root, setAnimalFollowing)
						AnimalFollowing[localPlayer] = true
						end
					end
					if(getElementHealth(target) >= 1) and target ~= getElementData( ped, "animalOwner" ) then
						AnimalFollowing[localPlayer] = false
						--removeEventHandler( "onClientPreRender", root, setAnimalFollowing)
						isEventHandel = false
						if(pedShooting[ped] ~= true) then
							setPedAimTarget(ped, x2, y2, z2+0.3)
							setPedControlState(ped, "fire", true)
							setPedControlState ( ped, "jump", false )
							setPedControlState ( ped, "sprint", false )
							setPedControlState ( ped, "walk", false )
							setPedControlState ( ped, "forwards", false )
							pedShooting[ped] = true
						else
							local x1, y1, z1 = getElementPosition(ped)
							local x2, y2, z2 = getElementPosition(target)
							local rot = math.atan2(y2 - y1, x2 - x1) * 180 / math.pi
							rot = rot-90
							setPedRotation(ped, rot)
							setPedAimTarget(ped, x2, y2, z2+0.3)
							setPedControlState(ped, "fire", true)
						end
					else
						local theOwner = getElementData( ped, "animalOwner" )
						killTimer(pedTimer[ped])
						pedShooting[ped] = false
						setPedControlState(ped, "fire", false)
						if (isEventHandel == false) then
						AnimalFollowing[localPlayer] = true
						--addEventHandler( "onClientPreRender", root, setAnimalFollowing)
						end
					end
				else
					local theOwner = getElementData( ped, "animalOwner" )
					killTimer(pedTimer[ped])
					pedShooting[ped] = false
					setPedControlState(ped, "fire", false)
					if (isEventHandel == false) then
					--addEventHandler( "onClientPreRender", root, setAnimalFollowing)
					AnimalFollowing[localPlayer] = true
					end
				end
			end
		   else
			killTimer(pedTimer[ped])
		   end
		end, 100, -1)
	else
	killTimer(pedTimer[ped])
	end
end

function setAnimalFollowing()
if AnimalFollowing[localPlayer] then
	if (isEventHandel == false) then
	isEventHandel = true
	end
	if ( animalTable ) then
		for theOwner, k in pairs ( animalTable ) do
			local theAnimal = animalTable[theOwner][1]
			local thePlayer = animalTable[theOwner][3]
			if ( isElement( thePlayer ) ) and ( isElement( theAnimal ) ) and ( getElementHealth( theAnimal ) > 0 ) then
				local playerX, playerY, playerZ = getElementPosition ( thePlayer )
				local playerInt, playerDim = getElementInterior( thePlayer ), getElementDimension( thePlayer )
				local dogX, dogY, dogZ = getElementPosition ( theAnimal )
				local distance = getDistanceBetweenPoints2D ( playerX, playerY, dogX, dogY )
				setElementInterior( theAnimal, playerInt )
				setElementDimension( theAnimal, playerDim )
				local x1, y1, z1 = getElementPosition(theAnimal)
				local x2, y2, z2 = getElementPosition(thePlayer)
				local playerRotation = math.atan2(y2 - y1, x2 - x1) * 180 / math.pi
				playerRotation = playerRotation-90
				setPedRotation(theAnimal, playerRotation)
				setPedAimTarget(theAnimal, x2, y2, z2)

				if ( isElementInWater ( thePlayer ) ) then setElementDimension( theAnimal, 0 ) else setElementDimension( theAnimal, 0 ) end
				if ( isPedInVehicle( thePlayer ) ) then setElementDimension( theAnimal, 0 ) else setElementDimension( theAnimal, 0 ) end

				if ( playerZ > dogZ + 0.5 ) and not getPedControlState (theAnimal, "fire") then
						setPedControlState ( theAnimal, "jump", true )
						setTimer(function()
							if isElement(theAnimal) then
							setPedControlState ( theAnimal, "jump", false )
							end
						end ,500,1)
				end
				if ( playerZ < dogZ - 0.5 ) and not getPedControlState (theAnimal, "fire") then
						setPedControlState ( theAnimal, "jump", true )
						setTimer(function()
							if isElement(theAnimal) then
							setPedControlState ( theAnimal, "jump", false )
							end
						end ,500,1)
				end
				if ( distance >= 25 ) and not getPedControlState (theAnimal, "fire") then
						setPedWeaponSlot(theAnimal, 5)
						setElementPosition ( theAnimal, playerX + 0.5, playerY , playerZ )
						setElementDimension( theAnimal, playerDim )
						setElementInterior ( theAnimal, playerInt )
				end
				if ( distance >= 6 ) and ( distance < 25 ) and not getPedControlState (theAnimal, "fire") then
						setPedWeaponSlot(theAnimal, 0)
						setPedControlState ( theAnimal, "sprint", true )
						setPedControlState ( theAnimal, "walk", false )
						setPedControlState ( theAnimal, "forwards", true )
				end
				if ( distance >= 4 ) and ( distance < 6 ) and not getPedControlState (theAnimal, "fire") then
						setPedWeaponSlot(theAnimal, 5)
						setPedControlState ( theAnimal, "sprint", false )
						setPedControlState ( theAnimal, "walk", false )
						setPedControlState ( theAnimal, "forwards", true )
				end
				if ( distance >= 2 ) and ( distance < 4 ) and not getPedControlState (theAnimal, "fire") then
						setPedWeaponSlot(theAnimal, 5)
						setPedControlState ( theAnimal, "sprint", false )
						setPedControlState ( theAnimal, "walk", true )
						setPedControlState ( theAnimal, "forwards", true )
				end
				if ( distance < 2 ) and not getPedControlState (theAnimal, "fire") then
						setPedWeaponSlot(theAnimal, 5)
						setPedControlState ( theAnimal, "sprint", false )
						setPedControlState ( theAnimal, "walk", false )
						setPedControlState ( theAnimal, "forwards", false )
				end
						if ( isPedInVehicle ( thePlayer ) ) then
							if not ( isPedInVehicle( theAnimal ) ) then
				  			triggerServerEvent("warpAnimalIntoVehicle", theAnimal, thePlayer)
				   			end
			    			end
						if ( isPedInVehicle ( theAnimal ) ) and not ( isPedInVehicle( thePlayer ) ) then
							triggerServerEvent("removeAnimalOutVehicle", theAnimal, thePlayer)
						end
			end
		end
	end
end
end
addEventHandler( "onClientPreRender", root, setAnimalFollowing)


addEventHandler("onClientPedDamage", getRootElement(), function(attacker)
	if getElementData(source, "bodyguard") then
		if(attacker) and (isElement(attacker)) then
			if ( animalTable ) then
				for theOwner, k in pairs ( animalTable ) do
				local theAnimal = animalTable[theOwner][1]
				local thePlayer = animalTable[theOwner][3]

					if source == theAnimal and attacker ~= thePlayer then
						if (getElementType(attacker) == "player") then
						local AttackerTeam = getPlayerTeam(attacker)
						local thePlayerTeam = getPlayerTeam(thePlayer)
						local AttackerGroup = getElementData(attacker, "Group")
						local thePlayerGroup = getElementData(thePlayer, "Group")
							if getTeamName(AttackerTeam) ~= "No Team" and getTeamName(AttackerTeam) == getTeamName(thePlayerTeam) or AttackerGroup == thePlayerGroup then
							cancelEvent()
							else
							pedTarget[source] = attacker
							doPedAttackOtherPlayer(source)
							end
						end
					end
					if (getElementType(attacker) == "vehicle") or (getElementType(attacker) == "ped") then
						pedTarget[source] = attacker
						doPedAttackOtherPlayer(source)
					end
				end
			end
		end
	end
end)


addEventHandler("onClientPlayerDamage", getRootElement(), function(attacker)
	if(attacker) and (isElement(attacker)) then
		if (getElementType(attacker) == "ped") and getElementData( attacker, "bodyguard" ) and getElementData( attacker, "animalOwner" ) == source then
			cancelEvent()
		end
	    if ( animalTable ) then
		for theOwner, k in pairs ( animalTable ) do
			local theAnimal = animalTable[theOwner][1]
			local thePlayer = animalTable[theOwner][3]
			
			if (getElementType(attacker) == "player") then
				if theAnimal and getElementData( theAnimal, "animalOwner" ) == thePlayer and thePlayer == source then
				local AttackerTeam = getPlayerTeam(attacker)
				local sourceTeam = getPlayerTeam(source)
				local thePlayerTeam = getPlayerTeam(thePlayer)
				local AttackerGroup = getElementData(attacker, "Group")
				local sourceGroup = getElementData(source, "Group")
				local thePlayerGroup = getElementData(thePlayer, "Group")
					if getTeamName(AttackerTeam) ~= "No Team" and getTeamName(AttackerTeam) ~= getTeamName(thePlayerTeam) or AttackerGroup ~= thePlayerGroup then
						if theAnimal and attacker then
						pedTarget[theAnimal] = attacker
						doPedAttackOtherPlayer(theAnimal)
						end
					end
				end
				if (getElementType(attacker) == "vehicle") or (getElementType(attacker) == "ped") and attacker ~= theAnimal then
					if theAnimal and attacker then
					pedTarget[theAnimal] = attacker
					doPedAttackOtherPlayer(theAnimal)
					end
				end
			end
			if (attacker) == thePlayer and source ~= theAnimal and getElementData( theAnimal, "animalOwner" ) == attacker then
				if (getElementType(source) == "player") then

				local AttackerTeam = getPlayerTeam(attacker)
				local sourceTeam = getPlayerTeam(source)
				local thePlayerTeam = getPlayerTeam(thePlayer)

				local AttackerGroup = getElementData(attacker, "Group")
				local sourceGroup = getElementData(source, "Group")
				local thePlayerGroup = getElementData(thePlayer, "Group")

					if getTeamName(sourceTeam) ~= "No Team" and getTeamName(sourceTeam) ~= getTeamName(thePlayerTeam) or sourceGroup ~= thePlayerGroup then
				local AttackerStars = getElementData(attacker, "WantLvl")
				local sourceStars = getElementData(source, "WantLvl")
				local thePlayerStars = getElementData(thePlayer, "WantLvl")
				   	    if getTeamName(AttackerTeam) == "Police" and sourceStars "Jailed" then
 						cancelEvent()
					    else
						if theAnimal and source then
						pedTarget[theAnimal] = source
						doPedAttackOtherPlayer(theAnimal)
						end
					    end
					end
				end
			end
		end
	    end
	end
end)

------Bodyguards---------
local pedTarget = {}
local pedTimer = {}
local pedShooting = {}
local AnimalFollowing = {}

addEvent( "onSyncPlayerAnimals", true )
addEventHandler( "onSyncPlayerAnimals", root,
	function ( theTable )
		animalTable = theTable
		--addEventHandler( "onClientPreRender", root, setAnimalFollowing)
		AnimalFollowing[localPlayer] = true
	end
)

local function doPedAttackOtherPlayer(ped)
	if(isTimer(pedTimer[ped])) or (isPedInVehicle(ped)) then
		killTimer(pedTimer[ped])
	end
	if(isElement(ped)) then
		pedTimer[ped] = setTimer(function()
		    if(isElement(ped)) then
			local target = pedTarget[ped]
			if (target) then
				local x, y, z = getElementPosition(ped)
				local x2, y2, z2 = getElementPosition(target)
				if(isLineOfSightClear(x, y, z, x2, y2, z2, true, false, false, false, false, false)) then
					if (getElementType(target) == "player") and getElementData(target, "Stats") >= 2 then
						local theOwner = getElementData( ped, "animalOwner" )
						killTimer(pedTimer[ped])
						pedShooting[ped] = false
						setPedControlState(ped, "fire", false)
						if (isEventHandel == false) then
						--addEventHandler( "onClientPreRender", root, setAnimalFollowing)
						AnimalFollowing[localPlayer] = true
						end
					end
					if(getElementHealth(target) >= 1) and target ~= getElementData( ped, "animalOwner" ) then
						AnimalFollowing[localPlayer] = false
						--removeEventHandler( "onClientPreRender", root, setAnimalFollowing)
						isEventHandel = false
						if(pedShooting[ped] ~= true) then
							setPedAimTarget(ped, x2, y2, z2+0.3)
							setPedControlState(ped, "fire", true)
							setPedControlState ( ped, "jump", false )
							setPedControlState ( ped, "sprint", false )
							setPedControlState ( ped, "walk", false )
							setPedControlState ( ped, "forwards", false )
							pedShooting[ped] = true
						else
							local x1, y1, z1 = getElementPosition(ped)
							local x2, y2, z2 = getElementPosition(target)
							local rot = math.atan2(y2 - y1, x2 - x1) * 180 / math.pi
							rot = rot-90
							setPedRotation(ped, rot)
							setPedAimTarget(ped, x2, y2, z2+0.3)
							setPedControlState(ped, "fire", true)
						end
					else
						local theOwner = getElementData( ped, "animalOwner" )
						killTimer(pedTimer[ped])
						pedShooting[ped] = false
						setPedControlState(ped, "fire", false)
						if (isEventHandel == false) then
						AnimalFollowing[localPlayer] = true
						--addEventHandler( "onClientPreRender", root, setAnimalFollowing)
						end
					end
				else
					local theOwner = getElementData( ped, "animalOwner" )
					killTimer(pedTimer[ped])
					pedShooting[ped] = false
					setPedControlState(ped, "fire", false)
					if (isEventHandel == false) then
					--addEventHandler( "onClientPreRender", root, setAnimalFollowing)
					AnimalFollowing[localPlayer] = true
					end
				end
			end
		   else
			killTimer(pedTimer[ped])
		   end
		end, 100, -1)
	else
	killTimer(pedTimer[ped])
	end
end

function setAnimalFollowing()
if AnimalFollowing[localPlayer] then
	if (isEventHandel == false) then
	isEventHandel = true
	end
	if ( animalTable ) then
		for theOwner, k in pairs ( animalTable ) do
			local theAnimal = animalTable[theOwner][1]
			local thePlayer = animalTable[theOwner][3]
			if ( isElement( thePlayer ) ) and ( isElement( theAnimal ) ) and ( getElementHealth( theAnimal ) > 0 ) then
				local playerX, playerY, playerZ = getElementPosition ( thePlayer )
				local playerInt, playerDim = getElementInterior( thePlayer ), getElementDimension( thePlayer )
				local dogX, dogY, dogZ = getElementPosition ( theAnimal )
				local distance = getDistanceBetweenPoints2D ( playerX, playerY, dogX, dogY )
				setElementInterior( theAnimal, playerInt )
				setElementDimension( theAnimal, playerDim )
				local x1, y1, z1 = getElementPosition(theAnimal)
				local x2, y2, z2 = getElementPosition(thePlayer)
				local playerRotation = math.atan2(y2 - y1, x2 - x1) * 180 / math.pi
				playerRotation = playerRotation-90
				setPedRotation(theAnimal, playerRotation)
				setPedAimTarget(theAnimal, x2, y2, z2)

				if ( isElementInWater ( thePlayer ) ) then setElementDimension( theAnimal, 0 ) else setElementDimension( theAnimal, 0 ) end
				if ( isPedInVehicle( thePlayer ) ) then setElementDimension( theAnimal, 0 ) else setElementDimension( theAnimal, 0 ) end

				if ( playerZ > dogZ + 0.5 ) and not getPedControlState (theAnimal, "fire") then
						setPedControlState ( theAnimal, "jump", true )
						setTimer(function()
							if isElement(theAnimal) then
							setPedControlState ( theAnimal, "jump", false )
							end
						end ,500,1)
				end
				if ( playerZ < dogZ - 0.5 ) and not getPedControlState (theAnimal, "fire") then
						setPedControlState ( theAnimal, "jump", true )
						setTimer(function()
							if isElement(theAnimal) then
							setPedControlState ( theAnimal, "jump", false )
							end
						end ,500,1)
				end
				if ( distance >= 25 ) and not getPedControlState (theAnimal, "fire") then
						setPedWeaponSlot(theAnimal, 5)
						setElementPosition ( theAnimal, playerX + 0.5, playerY , playerZ )
						setElementDimension( theAnimal, playerDim )
						setElementInterior ( theAnimal, playerInt )
				end
				if ( distance >= 6 ) and ( distance < 25 ) and not getPedControlState (theAnimal, "fire") then
						setPedWeaponSlot(theAnimal, 0)
						setPedControlState ( theAnimal, "sprint", true )
						setPedControlState ( theAnimal, "walk", false )
						setPedControlState ( theAnimal, "forwards", true )
				end
				if ( distance >= 4 ) and ( distance < 6 ) and not getPedControlState (theAnimal, "fire") then
						setPedWeaponSlot(theAnimal, 5)
						setPedControlState ( theAnimal, "sprint", false )
						setPedControlState ( theAnimal, "walk", false )
						setPedControlState ( theAnimal, "forwards", true )
				end
				if ( distance >= 2 ) and ( distance < 4 ) and not getPedControlState (theAnimal, "fire") then
						setPedWeaponSlot(theAnimal, 5)
						setPedControlState ( theAnimal, "sprint", false )
						setPedControlState ( theAnimal, "walk", true )
						setPedControlState ( theAnimal, "forwards", true )
				end
				if ( distance < 2 ) and not getPedControlState (theAnimal, "fire") then
						setPedWeaponSlot(theAnimal, 5)
						setPedControlState ( theAnimal, "sprint", false )
						setPedControlState ( theAnimal, "walk", false )
						setPedControlState ( theAnimal, "forwards", false )
				end
						if ( isPedInVehicle ( thePlayer ) ) then
							if not ( isPedInVehicle( theAnimal ) ) then
				  			triggerServerEvent("warpAnimalIntoVehicle", theAnimal, thePlayer)
				   			end
			    			end
						if ( isPedInVehicle ( theAnimal ) ) and not ( isPedInVehicle( thePlayer ) ) then
							triggerServerEvent("removeAnimalOutVehicle", theAnimal, thePlayer)
						end
			end
		end
	end
end
end
addEventHandler( "onClientPreRender", root, setAnimalFollowing)

 

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...