Jump to content

تصحيح خطأ بالحارس الشخصي


Recommended Posts

السلام عليكم

الحين معي مود فيب

لما اضغط علي الزر الي ينزل الحارس

ماينزل

:(

الكلنت

local animalTable = false
isEventHandel = true
---------------------------------|
local rX,rY = guiGetScreenSize()
local sw,sh = 527,514
---------------------------------|
local tag = dxCreateTexture("3.png")
 
addEventHandler("onClientPreRender", root,
function()
 for i, player in ipairs ( getElementsByType ( "player" ) ) do
   if ( getElementData ( player, "isPlayerVIP" ) == true ) then
   local x, y, z = getPedBonePosition(player, 5)
	if player ~= localPlayer then
   	dxDrawMaterialLine3D(x, y, z+1.2, x, y, z+0.6, tag, 0.7, tocolor(0,255,255,255))
	end
  end
 end
 end
 )

------------------

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
	function ()
	
        window = guiCreateWindow(242, 194, 511, 347, "|= V.I.P |=", false)
        guiSetProperty(window, "CaptionColour", "FF00FF00")
        guiSetAlpha(window, 1.00)

        close = guiCreateButton(10, 306, 493, 27, "=| Close Window |=", false, window)
        guiSetProperty(close, "NormalTextColour", "FFFF0000")
        vipset = guiCreateLabel(120, 172, 1000, 18, "=| VIP Option |=", false, window)
        guiSetFont(vipset, "default-bold-small")
        guiLabelSetColor(vipset, 255, 0, 0)
        vipcars = guiCreateButton(10, 200, 156, 27, "=| Spawn Vehicle |=", false, window)
        guiSetProperty(vipcars, "NormalTextColour", "FF00FF00")
        vipjet = guiCreateButton(345, 274, 157, 27, "=| JetPack |=", false, window)
        guiSetProperty(vipjet, "NormalTextColour", "FF00FF00")
        viphel = guiCreateButton(179, 200, 156, 27, "=| Health |=", false, window)
        guiSetProperty(viphel, "NormalTextColour", "FF00FF00")
        vipcbody = guiCreateButton(345, 200, 156, 27, "=| Create Body |=", false, window)
        guiSetProperty(vipcbody, "NormalTextColour", "FF00FF00")
        vipfv = guiCreateButton(9, 274, 156, 27, "=| Fix Vehicle |=", false, window)
        guiSetProperty(vipfv, "NormalTextColour", "FF00FF00")
        vipdskin = guiCreateButton(9, 237, 157, 27, "=| Skin VIP |=", false, window)
        guiSetProperty(vipdskin, "NormalTextColour", "FF00FF00")
        vipdbody = guiCreateButton(345, 237, 157, 27, "=[ Destroy Body ]=", false, window)
        guiSetProperty(vipdbody, "NormalTextColour", "FF00FF00")
        viplr = guiCreateButton(179, 274, 157, 27, "=| Launcher |=", false, window)
        guiSetProperty(viplr, "NormalTextColour", "FF00FF00")
        viparmor = guiCreateButton(180, 237, 156, 27, "=| Armour |=", false, window)
        guiSetProperty(viparmor, "NormalTextColour", "FF00FF00")
        vipimg = guiCreateStaticImage(9, 19, 499, 153, "wnd.png", false, window)
        guiSetProperty(vipimg, "NormalTextColour", "FF00FF00")    

    guiWindowSetMovable (window, true)
    guiWindowSetSizable (window, false)
    guiSetVisible (window, false)
	
	

	
addEventHandler ("onClientGUIClick", GridListVipSkins, function() setElementModel ( localPlayer, guiGridListGetItemText ( GridListVipSkins, guiGridListGetSelectedItem ( GridListVipSkins ), 1, 2 )    ) end, false)
addEventHandler("onClientGUIClick", close, 
function() guiSetVisible(window, false) 
 setElementModel ( localPlayer, tonumber( getElementData( localPlayer, "clothesvipSkin" )) )
 showCursor(false) 
 guiSetVisible(VipHats, false)
 guiSetVisible(WindowWalkStyles, false)
 end, false)
addEventHandler("onClientGUIClick", closeFrom, 
function() guiSetVisible(window, false) 
 setElementModel ( localPlayer, tonumber( getElementData( localPlayer, "clothesvipSkin" )) )
 showCursor(false) 
 end, false)
end)


function ShowPremiumPanel ()
	if ( getElementData(localPlayer, "isPlayerVIP") ) then
	if getElementDimension(localPlayer) == 0 and getElementInterior(localPlayer) == 0  then
		if guiGetVisible(window) then
			guiSetVisible(window, false)
			guiSetVisible(VipHats, false)
			showCursor(false,false)
		else
			setElementData ( localPlayer, "clothesvipSkin", getElementModel ( localPlayer ), true )
			triggerServerEvent ( "OnClientGetPreminumTime", localPlayer ) 
		end
	else
	exports["guimessages"]:outputClient( "#00FF00=(VIP-System)=#CC0000 : Sorry: You Cant use VIP panel here", 255, 0, 0)
	end
	end
end
addCommandHandler ( "vip", ShowPremiumPanel )
bindKey ( "F10", "down", ShowPremiumPanel )

addEvent( "OpenVIPanel", true )
addEventHandler( "OpenVIPanel", root,
function ( getTime )
			guiSetVisible(window,true)
			showCursor(true,true)
			guiSetText( LabelAccountName, "account name : "..getElementData(localPlayer,"Account").."" )
	     		guiSetText( LabelPlayerName, "player name : "..getPlayerName( localPlayer ).."" )
			guiSetText( LabelIsAccountPremium, "Vip : YES" )
			guiSetText( LabelTimeRemainig, "Time for END VIP : Open" )
end)

------- Button For VIP panel
addEventHandler("onClientGUIClick", root,
function ()
  if (source == vipcars) then
     triggerServerEvent ( "onClientSpawnVIPvehicles", localPlayer)
  elseif (source == vipjet) then
     triggerServerEvent ( "onClientGivJetPackPlayer", localPlayer)
  elseif (source == viphel) then
    guiSetEnabled( viphel,false)
    setTimer(guiSetEnabled,60000*20,1, viphel,true)
     triggerServerEvent ( "onClinetGiveVIPHealth", localPlayer)
	 
  elseif (source == viparmor) then
    guiSetEnabled( viparmor,false)
    setTimer(guiSetEnabled,60000*20,1, viparmor,true)
     triggerServerEvent ( "onClinetGiveVIPArmor", localPlayer)
  elseif (source == vipdskin) then
     triggerServerEvent ( "onClinetTakeVIPSkin", localPlayer)
  	elseif (source == vipcbody) then
	     triggerServerEvent ( "onClinetSpawnMonture", localPlayer)
	 elseif (source == vipdbody) then
	    triggerServerEvent ( "onClinetHideLion", localPlayer)
	elseif (source == vipfv) then
	    triggerServerEvent ( "VIPFixVehicle", localPlayer)
	elseif (source == viplr) then
	guiSetEnabled( viplr,false)
    setTimer(guiSetEnabled,60000*20,1, viplr,true)
	    triggerServerEvent ( "LauncherVIP", localPlayer)
	end
end)


--[[setTimer (
function ()
  if ( getElementData(localPlayer, "isPlayerVIP") ) then
   triggerServerEvent ( "onClientCheckZone", localPlayer)
  end
end, 10000, 0 )]]



addEvent("CloseVIPanel", true)
addEventHandler("CloseVIPanel",getRootElement(),
function ()
    guiSetVisible(window, false)
    guiSetInputEnabled(false)
    showCursor(false)
end)

addEvent("CloseVIPanel2", true)
addEventHandler("CloseVIPanel2",getRootElement(),
function ()
    setElementModel ( localPlayer, tonumber( getElementData( localPlayer, "clothesvipSkin" )))
    guiSetVisible(window, false)
    guiSetInputEnabled(false)
    showCursor(false)
end)



    txd = engineLoadTXD ( "Mods/wmybar.txd" )
    engineImportTXD ( txd, 9 )
    dff = engineLoadDFF ( "Mods/wmybar.dff", 9 )
    engineReplaceModel ( dff, 9 )

    txd1 = engineLoadTXD ( "Mods/rabbit.txd" )
    engineImportTXD ( txd1, 10 )
    dff1 = engineLoadDFF ( "Mods/rabbit.dff", 10 )
    engineReplaceModel ( dff1, 10 )

    txd2 = engineLoadTXD ( "Mods/premiumSkin1.txd" )
    engineImportTXD ( txd2, 11 )
    dff2 = engineLoadDFF ( "Mods/premiumSkin1.dff", 11 )
    engineReplaceModel ( dff2, 11 )

    txd3 = engineLoadTXD ( "Mods/premiumSkin2.txd" )
    engineImportTXD ( txd3, 12 )
    dff3 = engineLoadDFF ( "Mods/premiumSkin2.dff", 12 )
    engineReplaceModel ( dff3, 12 )

    txd4 = engineLoadTXD ( "Mods/premiumSkin3.txd" )
    engineImportTXD ( txd4, 13 )
    dff4 = engineLoadDFF ( "Mods/premiumSkin3.dff", 13 )
    engineReplaceModel ( dff4, 13 )
	

addEventHandler( "onClientResourceStart", resourceRoot,
  function ()
    --fileDelete("VIP_Client.lua")
	engineImportTXD( engineLoadTXD( "Mods/car.txd" ), getVehicleModelFromName ( "Majestic" ) )
	engineReplaceModel ( engineLoadDFF( "Mods/car.dff", 0 ) , getVehicleModelFromName ( "Majestic" ) )
end
)
-------------------------------------------
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)

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 < 3 then
 						cancelEvent()
					    else
						if theAnimal and source then
						pedTarget[theAnimal] = source
						doPedAttackOtherPlayer(theAnimal)
						end
					    end
					end
				end
			end
		end
	    end
	end
end)

سيرفر

 

 

 



local theVehicle = {}
local latestSpawn = {}
local latestGetArmor = {}
local latestGetSkin = {}
local latestGetMonture = {}
local latestHideAnimal = {}
local latestHideVehilces = {}
local latestUseHats = {}
local theTimer = {}
local hatObjects = {}
local timers = {}

-----------------
function outButDxChat (Text,player,r,p,g)
exports["guimessages"]:outputServer(player,Text,r,p,g)
end
--------------------

local Serials = {
--Consoles
	["1514639F9F1D2DFDDE9659DF6FD4BB12"] = true, --


--VIP

	["1514639F9F1D2DFDDE9659DF6FD4BB12"] = true,

}

addEventHandler ( "onResourceStart", resourceRoot, function (  )
	for _,players in ipairs ( getElementsByType ( "player" ) ) do
		if  ( getPlayerAccount( players ) and not isGuestAccount( getPlayerAccount( players ) ) ) then
			--if ( isObjectInACLGroup ( "user."..getAccountName ( getPlayerAccount ( players ) ), aclGetGroup ( "VIP" ) ) ) then
			if ( Serials[getPlayerSerial(players)] ) then
				if aclGetGroup("VIP") then
					if not ( isObjectInACLGroup ( "user."..getAccountName ( getPlayerAccount ( players )), aclGetGroup ( "VIP" ) ) ) then
					aclGroupAddObject(aclGetGroup("VIP"), "user."..getAccountName ( getPlayerAccount ( players ) ))
					outButDxChat("#00FF00=(VIP-System)=#CC0000 : successfully added to VIP Group.",players,255,255,0,false)
					end
				end
				setElementData(players, "isPlayerVIP", true)
			end
		end
	end
end )  
 
 
addEventHandler ( "onPlayerLogin", root, function ( _,acc )
	if ( Serials[getPlayerSerial(source)] ) then
		if aclGetGroup("VIP") then
			if not ( isObjectInACLGroup ( "user."..getAccountName( acc ), aclGetGroup ( "VIP" ) ) ) then
				aclGroupAddObject(aclGetGroup("VIP"), "user."..getAccountName ( getPlayerAccount ( source ) ))
				outButDxChat("#00FF00=(VIP-System)=#CC0000 : successfully added to VIP Group.",source,255,255,0,false)
				
			end
		end
		setElementData(source, "isPlayerVIP", true)
	end
end)

------------------

function getPremiumHoursToString ( thePlayer )
	if ( isElement( thePlayer ) ) then
		local userID = getElementData( thePlayer, "accountUserID" )
		if getElementData(thePlayer, "isPlayerVIP" ) then
			local premiumData = "N/A"
			if ( premiumData ) and ( premiumData.premium ) then
			 if ( premiumData.premium < 60 ) then
				return ""..premiumData.premium.." minutes"
			else
				local premiumtime = math.floor(premiumData.premium/60)
				if( premiumtime == 1 ) then
				return ""..premiumtime.." hour"
				 else
				return ""..premiumtime.." hours"
			  end
			end
		else
			return false
		end
	else
		return false
	end
	else
	  return false
    end
end

addEvent( "OnClientGetPreminumTime", true )
addEventHandler( "OnClientGetPreminumTime", root,
	function ()
	    local GetTime = getPremiumHoursToString ( source ) or "N/A"
			triggerClientEvent( source, "OpenVIPanel", source, GetTime )
	end
)

--[[function updatetheVipTimeForAllPlayers ()
	for index , player in ipairs ( getElementsByType ( "player" ) ) do
		if not isGuestAccount ( getPlayerAccount ( player ) ) then
			if getElementData(player, "isPlayerVIP") then
				if (getPlayerIdleTime( player ) < 600000) then
					local playerID = exports.TNS:playerID( player )
					local premiumData = exports.TNSmysql:querySingle( "SELECT * FROM premium WHERE id = ?",playerID )
					if premiumData.premium > 4 then
						convertedTime = premiumData.premium - 5
					elseif premiumData.premium == 4 then
						convertedTime = premiumData.premium - 4
					elseif premiumData.premium == 3 then
						convertedTime = premiumData.premium - 3
					elseif premiumData.premium == 2 then
						convertedTime = premiumData.premium - 2
					elseif premiumData.premium == 1 then
						convertedTime = premiumData.premium - 1
					end
				
					if convertedTime == 0 then
						setElementData(player, "isPlayerVIP", false)
						setElementData(player, "vip", "No")
					end
				
					local updateViptime = exports.TNSmysql:exec("UPDATE premium SET premium=? WHERE id = '" .. playerID .. "'"
                         ,tonumber(convertedTime)
                        )
				end
			end
		end
	end
end
setTimer ( updatetheVipTimeForAllPlayers , 600000, 0 )]]

local vehs = {}
 
addEvent("onClientSpawnVIPvehicles", true)
addEventHandler("onClientSpawnVIPvehicles", root,
function()
   local accName = getAccountName ( getPlayerAccount ( source ) )
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
        if (isElement(vehs[source])) then
            destroyElement(vehs[source])
            vehs[source] = nil
        end
        local x, y, z = getElementPosition(source)
        vehs[source] = createVehicle(411, x+3, y, z+1)
		addVehicleUpgrade ( vehs[source], 1010 )
        outButDxChat("#00FF00=(VIP-System)=#CC0000 : Vehicle Created Successfully .",source,255,255,0,false)
    end
end)

addEventHandler ( "onPlayerQuit", root, 
function()
	if ( isElement( theVehicle[source] ) ) then 
		destroyElement( theVehicle[source] )
		theVehicle[source] = nil
	end
end
)



addEventHandler("onVehicleExplode", root, 
function ()
	if ( getElementData(source, "vehicleType") == "vipCar" ) then
		local theOwner = getElementData(source, "vehicleOwner")
		theTimer[theOwner] = setTimer(destroyVehicle, 2000, 1, source, theOwner)
	end
end
)

addEventHandler("onVehicleStartEnter", root, 
function ( player, seat, jacked )
	if ( getElementData(source, "vehicleType") == "vipCar" ) and ( seat == 0 ) then
	 local wanted = getElementData(player,"WantLvl")
		if ( wanted < 3 ) then
			if source and getElementType(source) == "player" then
				local Team = getPlayerTeam(source)
				if Team then
					if ( player ~= getElementData(source, "vehicleOwner") ) and not getTeamFromName(Team) == "Police" then
					cancelEvent()
					end
				end
			end
		end
	end
end
)

function currentZone(player)
	local x, y, z = getElementPosition(player)
	if x < -920 then
		return "SF"
	elseif y < 420 then
		return "LS"
	else
		return "LV"
	end
end

function HealthVIP  ( )
   local accName = getAccountName ( getPlayerAccount ( source ) )
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
setPedStat(source, 24, 900)
setElementHealth ( source, 160 )
outButDxChat("#00FF00=(VIP-System)=#CC0000 : You take health successfully . Wait 5 minutes to again.",source,255,255,0,false)
end 
end
addEvent( "onClinetGiveVIPHealth", true )
addEventHandler( "onClinetGiveVIPHealth", getRootElement(),HealthVIP )

function LauncherVIP () 
   local accName = getAccountName ( getPlayerAccount ( source ) )
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
setElementData(source,"GLA",(getElementData(source,"GLA")or 0)+7)
outButDxChat("#00FF00=(VIP-System)=#CC0000 : You take launcher successfully . Wait 20 minutes to again.",source,255,255,0,false)
   end
end
addEvent( "LauncherVIP", true )
addEventHandler( "LauncherVIP", getRootElement(),LauncherVIP )

function JetpackGive  ( )
   local accName = getAccountName ( getPlayerAccount ( source ) )
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
   local hasJetPack = doesPedHaveJetPack ( source )
if ( hasJetPack ) then  
removePedJetPack ( source )  
outButDxChat ("#00FF00=(VIP-System)=#CC0000 : You have delete jetpack",source,255,255,0,false)
else
givePedJetPack ( source )
outButDxChat ("#00FF00=(VIP-System)=#CC0000 : You have get jetpack",source,255,255,0,false)
end
end
  end
addEvent( "onClientGivJetPackPlayer", true )
addEventHandler( "onClientGivJetPackPlayer", getRootElement(), JetpackGive )

function ArmourVIP ( )
   local accName = getAccountName ( getPlayerAccount ( source ) )
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
setPedArmor (source,100)
outButDxChat("#00FF00=(VIP-System)=#CC0000 : You take armour successfully . Wait 5 minutes to again.",source,255,255,0,false)
   end
end
addEvent( "onClinetGiveVIPArmor", true )
addEventHandler( "onClinetGiveVIPArmor", getRootElement(),ArmourVIP )

addEvent('onClinetHideLion', true)
addEventHandler('onClinetHideLion', root,
function ()
if getElementData(source,"Stats") > 2 then
   if getElementData(source, "isPlayerVIP") then
	if ( latestHideAnimal[getPlayerSerial(source)] ) and ( getTickCount()-latestHideAnimal[getPlayerSerial(source)] < 10000 ) then
	outButDxChat("#00FF00=(VIP-System)=#CC0000 : You can use this button only every 10 Seconds.",source,255,255,0,false)
	else
	 onHideAnimalForVips( source )
	 triggerClientEvent ( source, "CloseVIPanel", getRootElement())
	 outButDxChat("#00FF00=(VIP-System)=#CC0000 : You have successfully hide your Bodyguard.",source,255,255,0,false)
	 latestHideAnimal[getPlayerSerial(source)] = getTickCount()
        end
      end
   end
end)

function SetSkinSERVER ( )
   local accName = getAccountName ( getPlayerAccount ( source ) )
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
setPedSkin (source,83)
outButDxChat("#00FF00=(VIP-System)=#CC0000 : Select Skin first .",source,255,255,0,false)
   end
end
addEvent( "onClinetTakeVIPSkin", true )
addEventHandler( "onClinetTakeVIPSkin", getRootElement(),SetSkinSERVER  )

addEvent("VIPFixVehicle", true)
addEventHandler("VIPFixVehicle", root,
function()
   local accName = getAccountName ( getPlayerAccount ( source ) )
   if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
        if isPedInVehicle ( source ) then
		local theVehicle = getPedOccupiedVehicle ( source ) 
		fixVehicle ( theVehicle )
            outButDxChat("#00FF00=(VIP-System)=#CC0000 : Vehicle fixed Successfully .",source,255,255,0,false)
        end
    end
end)


addEvent('onClinetSpawnMonture', true)
addEventHandler('onClinetSpawnMonture', root,
function ()
	if getElementData(source,"Stats") < 0 then
		if getElementData(source, "isPlayerVIP") then
			if ( latestGetMonture[getPlayerSerial(source)] ) and ( getTickCount()-latestGetMonture[getPlayerSerial(source)] < 300000 ) then
				outButDxChat("#00FF00=(VIP-System)=#CC0000 : You can take Bodyguard, only every 5 minutes.",source,255,255,0,false)
				triggerClientEvent ( source, "CloseVIPanel2", getRootElement())
			elseif ( getElementInterior(source) ~= 0 ) or ( getElementDimension(source) ~= 0 ) then
				outButDxChat("#00FF00=(VIP-System)=#CC0000 : You can't spawn a Bodyguard in interiors.",source,255,255,0,false)
			elseif ( getPlayerAnimal ( source ) ) then
				outButDxChat("#00FF00=(VIP-System)=#CC0000 : You already spawned a Bodyguard.",source,255,255,0,false)
			elseif ( doesPedHaveJetPack ( source ) ) then
				outButDxChat("#00FF00=(VIP-System)=#CC0000 : Remove the jetpack to spawn a Bodyguard.",source,255,255,0,false)
			elseif ( getPedOccupiedVehicle ( source ) ) then 
				outButDxChat("#00FF00=(VIP-System)=#CC0000 : You are in a vehicle, you can't spawn a Bodyguard.",source,255,255,0,false)
			else
				setPlayerAnimal ( source, "Lion", 164 )
				triggerClientEvent ( source, "CloseVIPanel2", getRootElement())
				outButDxChat("#00FF00=(VIP-System)=#CC0000 : You have successfully spawned a Bodyguard.",source,255,255,0,false)
				latestGetMonture[getPlayerSerial(source)] = getTickCount()
			end
		end
	end
end
)

function warpAnimalIntoVehicle (theAnimal)
	if theAnimal then
	local Animal = getPedOccupiedVehicle ( theAnimal )
		if Animal then
		local AnimalsVehicleSeats = getVehicleMaxPassengers( Animal )
		local PlayerVehicleOccupants = getVehicleOccupants( Animal )
			for seat = 0, AnimalsVehicleSeats do
				local occupant = PlayerVehicleOccupants[seat]
				if Animal and not occupant then
					warpPedIntoVehicle( source, Animal, seat)		
				end
			end
		end
	end
end
addEvent("warpAnimalIntoVehicle", true)
addEventHandler("warpAnimalIntoVehicle", root, warpAnimalIntoVehicle)

function removeAnimalOutVehicle (theAnimal)
	removePedFromVehicle ( source )
	local x, y, z = getElementPosition ( theAnimal )
	setElementPosition ( source, x + 1.5, y + 1.5, z )
end
addEvent("removeAnimalOutVehicle", true)
addEventHandler("removeAnimalOutVehicle", root, removeAnimalOutVehicle)

function changeHats(model,scale)
	if model then
	if ( latestUseHats[getPlayerSerial(source)] ) and ( getTickCount()-latestUseHats[getPlayerSerial(source)] < 10000 ) then
	outButDxChat("#00FF00=(VIP-System)=#CC0000 : You can take a hat, only every 10 seconds.",source,255,255,0,false)
	elseif ( getPedOccupiedVehicle ( source ) ) then
	outButDxChat("#00FF00=(VIP-System)=#CC0000 : You can't take a hat in vehilce.",source,255,255,0,false)
	else
		if isElement(hatObjects[source]) then
			destroyElement(hatObjects[source])
			hatObjects[source] = nil
			if isTimer(timers) then killTimer(timers[source]) end
		end
			hatObjects[source] = createObject(model, 0,0,-10 )
			setObjectScale(hatObjects[source],scale)
			exports.bone_attach:attachElementToBone(hatObjects[source],source,1,-0.0050,0.025,0.125,0,4,180)
		    latestUseHats[getPlayerSerial(source)] = getTickCount()
			local p = source
			timers[p] = setTimer(function()
				local int,dim=getElementInterior(p),getElementDimension(p)
		--		setElementInterior(hatObjects[p],int)
		--		setElementDimension(hatObjects[p],dim)
			end,5000,1)
		end
	else
		if isElement(hatObjects[source]) then destroyElement(hatObjects[source]) end
		if isTimer(timers) then killTimer(timers[source]) end
			hatObjects[source] = nil
			outButDxChat("#00FF00=(VIP-System)=#CC0000 : No longer wearing any hat.",source,255,255,0,false)
		end
end
addEvent("vipHats_changeHat",true)
addEventHandler("vipHats_changeHat",root,changeHats)

addEventHandler("onPlayerQuit",root,function()
	if isElement(hatObjects[source]) then
		if isTimer(timers[source]) then
			killTimer(timers[source])
		end
			destroyElement(hatObjects[source])
			hatObjects[source] = nil
	end
end)

function destroyVehicle ( vehicle, thePlayer  )
	theVehicle[thePlayer] = nil
	theTimer[thePlayer] = nil
	if isElement(vehicle) then
	destroyElement(vehicle)
	end
end

------------------------------------------------
addEventHandler("onPlayerLogin", root,
function()
	if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("VIP")) then
	setElementData(source, "isPlayerVIP", true)
	outButDxChat("#00FF00=(VIP-System)=#CC0000 : Welcome to open your vip press 'F10' or type '/vip'.",source,255,255,0,false)
	else
	setElementData(source, "isPlayerVIP", false)
	end
end
)

addEventHandler("onResourceStart", getResourceRootElement( getThisResource( ) ),
function()
	for i , v in ipairs ( getElementsByType ( "player" ) ) do
		if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(v)),aclGetGroup("VIP")) then
		setElementData(v, "isPlayerVIP", true)
		outButDxChat("#00FF00=(VIP-System)=#CC0000 : Welcome to open your vip press 'F10' or type '/vip'.",v,255,255,0,false)
		else
		setElementData(v, "isPlayerVIP", false)
		end
	end
end
)

-----------------------------------------------------

 

الخطأ بالدي بق

p_576c0lib1.png

 

مشكورين مقدمآآ

Link to comment

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.
×
×
  • Create New...