Jump to content

ارقاء اعتائي الحل


z24d

Recommended Posts

أبيه للكونسل بس ماضبط !

  
local Superman = {} 
  
-- Static global values 
local rootElement = getRootElement() 
local thisResource = getThisResource() 
  
-- Resource events 
addEvent("superman:start", true) 
addEvent("superman:stop", true) 
  
-- 
-- Start/stop functions 
-- 
function Superman.Start() 
if ( isObjectInACLGroup('user.'..getAccountName(getPlayerAccount(source)),aclGetGroup('Console')) ) then 
  local self = Superman 
  end 
  
  addEventHandler("superman:start", rootElement, self.clientStart) 
  addEventHandler("superman:stop", rootElement, self.clientStop) 
end 
addEventHandler("onResourceStart", getResourceRootElement(thisResource), Superman.Start, false) 
  
function Superman.clientStart() 
if ( isObjectInACLGroup('user.'..getAccountName(getPlayerAccount(source)),aclGetGroup('Console')) ) then 
  setElementData(client, "superman:flying", true) 
  end 
end 
  
function Superman.clientStop() 
if ( isObjectInACLGroup('user.'..getAccountName(getPlayerAccount(source)),aclGetGroup('Console')) ) then 
  setElementData(client, "superman:flying", false) 
  end 
end 
  

Edited by Guest
Link to comment
  
local Superman = {}
 
-- Settings
local ZERO_TOLERANCE = 0.00001
local MAX_ANGLE_SPEED = 6 -- In degrees per frame
local MAX_SPEED = 1.0
local EXTRA_SPEED_FACTOR = 1.85
local LOW_SPEED_FACTOR = 0.40
local ACCELERATION = 0.025
local EXTRA_ACCELERATION_FACTOR = 1.8
local LOW_ACCELERATION_FACTOR = 0.85
local TAKEOFF_VELOCITY = 1.75
local TAKEOFF_FLIGHT_DELAY = 750
local SMOKING_SPEED = 1.25
local GROUND_ZERO_TOLERANCE = 0.18
local LANDING_DISTANCE = 3.2
local FLIGHT_ANIMLIB = "swim"
local FLIGHT_ANIMATION = "Swim_Dive_Under"
local FLIGHT_ANIM_LOOP = false
local IDLE_ANIMLIB = "cop_ambient"
local IDLE_ANIMATION = "Coplook_loop"
local IDLE_ANIM_LOOP = true
local MAX_Y_ROTATION = 55
local ROTATION_Y_SPEED = 3.8
 
-- Static global variables
local thisResource = getThisResource()
local rootElement = getRootElement()
local localPlayer = getLocalPlayer()
local serverGravity = getGravity()
 
 
--
-- Utility functions
--
local function isPlayerFlying(player)
  local data = getElementData(player, "superman:flying")
  if not data or data == false then return false
  else return true end
end
 
local function setPlayerFlying(player, state)
  if state == true then state = true
  else state = false end
 
  setElementData(player, "superman:flying", state)
end
 
local function iterateFlyingPlayers()
  local current = 1
  local allPlayers = getElementsByType("player")
 
  return function()
    local player
   
    repeat
      player = allPlayers[current]
      current = current + 1
    until not player or (isPlayerFlying(player) and isElementStreamedIn(player))
 
    return player
  end
end
 
function Superman:restorePlayer(player)
  setPlayerFlying(player, false)
  setPedAnimation(player, false)
  setElementVelocity(player, 0, 0, 0)
  setElementRotation(player, 0, 0, 0)
  setPedRotation(player, getPedRotation(player))
  setElementCollisionsEnabled(player, true)
  self:destroySmokeGenerators(player)
  self.rotations[player] = nil
  self.previousVelocity[player] = nil
end
 
function Superman:createSmokeGenerator(player)
  local generator = createObject(2780, getElementPosition(player))
  setElementCollisionsEnabled(generator, false)
  setObjectScale(generator, 0)
  return generator
end
 
function Superman:createSmokeGenerators(player)
  if not self.smokeGenerators[player] then
    local smokeGenerators = {}
 
    smokeGenerators[1] = self:createSmokeGenerator(player)
    attachElementToElement(smokeGenerators[1], player, 0.75, -0.2, -0.4, -40, 0, 60)
    smokeGenerators[2] = self:createSmokeGenerator(player)
    attachElementToElement(smokeGenerators[2], player, -0.75, -0.2, -0.4, -40, 0, -60)
 
    self.smokeGenerators[player] = smokeGenerators
  end
end
 
function Superman:destroySmokeGenerators(player)
  if self.smokeGenerators[player] then
    for k, v in ipairs(self.smokeGenerators[player]) do
      destroyElement(v)
    end
    self.smokeGenerators[player] = nil
  end
end
 
function angleDiff(angle1, angle2)
  angle1, angle2 = angle1 % 360, angle2 % 360
  local diff = (angle1 - angle2) % 360
  if diff <= 180 then
    return diff
  else
    return -(360 - diff)
  end
end
 
local function isPedInWater(ped)
  local pedPosition = Vector3D:new(getElementPosition(ped))
  if pedPosition.z <= 0 then return true end
 
  local waterLevel = getWaterLevel(pedPosition.x, pedPosition.y, pedPosition.z)
  if not isElementStreamedIn(ped) or not waterLevel or waterLevel < pedPosition.z then
    return false
  else
    return true
  end
end
 
local function isnan(x)
    math.inf = 1/0
    if x == math.inf or x == -math.inf or x ~= x then
        return true
    end
    return false
end
 
local function getVector2DAngle(vec)
  if vec.x == 0 and vec.y == 0 then return 0 end
  local angle = math.deg(math.atan(vec.x / vec.y)) + 90
  if vec.y < 0 then
    angle = angle + 180
  end
  return angle
end
 
--
-- Initialization and shutdown functions
--
function Superman.Start()
  local self = Superman
 
  -- Register events
  addEventHandler("onClientResourceStop", getResourceRootElement(thisResource), Superman.Stop, false)
  addEventHandler("onPlayerJoin", rootElement, Superman.onJoin)
  addEventHandler("onPlayerQuit", rootElement, Superman.onQuit)
  addEventHandler("onClientRender", rootElement, Superman.processControls)
  addEventHandler("onClientRender", rootElement, Superman.processFlight)
  addEventHandler("onClientPlayerDamage", localPlayer, Superman.onDamage, false)
  addEventHandler("onClientElementDataChange", rootElement, Superman.onDataChange)
  addEventHandler("onClientElementStreamIn", rootElement, Superman.onStreamIn)
  addEventHandler("onClientElementStreamOut", rootElement, Superman.onStreamOut)
 
  -- Bind keys
  bindKey("jump", "down", Superman.onJump)
 
  -- Register commands
  addCommandHandler("superman", Superman.cmdSuperman)
 
  -- Initializate attributes
  self.smokeGenerators = {}
  self.rotations = {}
  self.previousVelocity = {}
end
addEventHandler("onClientResourceStart", getResourceRootElement(thisResource), Superman.Start, false)
 
function Superman.Stop()
  local self = Superman
 
  setGravity(serverGravity)
 
  -- Restore all players animations, collisions, etc
  for player in iterateFlyingPlayers() do
    self:restorePlayer(player)
  end
end
 
 
 
--
-- Join/Quit
--
function Superman.onJoin(player)
  local self = Superman
  local player = player or source
 
  setPlayerFlying(player, false)
end
 
function Superman.onQuit(reason, player)
  local self = Superman
  local player = player or source
 
  if isPlayerFlying(player) then
    self:restorePlayer(player)
  end
end
 
 
--
-- onDamage: superman is invulnerable
--
function Superman.onDamage()
  local self = Superman
 
  if isPlayerFlying(localPlayer) then
    cancelEvent()
  end
end
 
 
--
-- onStreamIn: Reset rotation attribute for player
--
function Superman.onStreamIn()
  local self = Superman
end
 
function Superman.onStreamOut()
  local self = Superman
 
  if source and isElement(source) and getElementType(source) == "player" and isPlayerFlying(source) then
    self.rotations[source] = nil
    self.previousVelocity[source] = nil
  end
end
 
--
-- onDataChange: Check if somebody who is out of stream stops being superman
--
function Superman.onDataChange(dataName, oldValue)
  local self = Superman
 
  if dataName == "superman:flying" and isElement(source) and getElementType(source) == "player" and
     oldValue ~= getElementData(source, dataName) and oldValue == true and getElementData(source, dataName) == false then
    self:restorePlayer(source)
  end
end
 
--
-- onJump: Combo to start flight without any command
--
Link to comment

بالطريقه هذي لازم لها تريقر للسيرفر ومن السيرفر للكلاينت

لاكن فيه طريقه اسهل والي هي كذا

اول ما الادمن يسجل دخوله يتحقق انه معه ادمن او لا ويعطيه الديتا

addEventHandler ("onPlayerLogin", root, 
  function (_, acc) 
    if isObjectInACLGroup ("user." .. getAccountName (acc), aclGetGroup ("Console")) then 
      setElementData (source, "isAdmin", true) 
    end 
  end 
) 

وبعدين تحط الكود حق الكلاينت زي كذا:

  
local Superman = {}
 
-- Settings
local ZERO_TOLERANCE = 0.00001
local MAX_ANGLE_SPEED = 6 -- In degrees per frame
local MAX_SPEED = 1.0
local EXTRA_SPEED_FACTOR = 1.85
local LOW_SPEED_FACTOR = 0.40
local ACCELERATION = 0.025
local EXTRA_ACCELERATION_FACTOR = 1.8
local LOW_ACCELERATION_FACTOR = 0.85
local TAKEOFF_VELOCITY = 1.75
local TAKEOFF_FLIGHT_DELAY = 750
local SMOKING_SPEED = 1.25
local GROUND_ZERO_TOLERANCE = 0.18
local LANDING_DISTANCE = 3.2
local FLIGHT_ANIMLIB = "swim"
local FLIGHT_ANIMATION = "Swim_Dive_Under"
local FLIGHT_ANIM_LOOP = false
local IDLE_ANIMLIB = "cop_ambient"
local IDLE_ANIMATION = "Coplook_loop"
local IDLE_ANIM_LOOP = true
local MAX_Y_ROTATION = 55
local ROTATION_Y_SPEED = 3.8
 
-- Static global variables
local thisResource = getThisResource()
local rootElement = getRootElement()
local localPlayer = getLocalPlayer()
local serverGravity = getGravity()
 
 
--
-- Utility functions
--
local function isPlayerFlying(player)
  local data = getElementData(player, "superman:flying")
  if not data or data == false then return false
  else return true end
end
 
local function setPlayerFlying(player, state)
  if state == true then state = true
  else state = false end
 
  setElementData(player, "superman:flying", state)
end
 
local function iterateFlyingPlayers()
  local current = 1
  local allPlayers = getElementsByType("player")
 
  return function()
    local player
   
    repeat
      player = allPlayers[current]
      current = current + 1
    until not player or (isPlayerFlying(player) and isElementStreamedIn(player))
 
    return player
  end
end
 
function Superman:restorePlayer(player)
  setPlayerFlying(player, false)
  setPedAnimation(player, false)
  setElementVelocity(player, 0, 0, 0)
  setElementRotation(player, 0, 0, 0)
  setPedRotation(player, getPedRotation(player))
  setElementCollisionsEnabled(player, true)
  self:destroySmokeGenerators(player)
  self.rotations[player] = nil
  self.previousVelocity[player] = nil
end
 
function Superman:createSmokeGenerator(player)
  local generator = createObject(2780, getElementPosition(player))
  setElementCollisionsEnabled(generator, false)
  setObjectScale(generator, 0)
  return generator
end
 
function Superman:createSmokeGenerators(player)
  if not self.smokeGenerators[player] then
    local smokeGenerators = {}
 
    smokeGenerators[1] = self:createSmokeGenerator(player)
    attachElementToElement(smokeGenerators[1], player, 0.75, -0.2, -0.4, -40, 0, 60)
    smokeGenerators[2] = self:createSmokeGenerator(player)
    attachElementToElement(smokeGenerators[2], player, -0.75, -0.2, -0.4, -40, 0, -60)
 
    self.smokeGenerators[player] = smokeGenerators
  end
end
 
function Superman:destroySmokeGenerators(player)
  if self.smokeGenerators[player] then
    for k, v in ipairs(self.smokeGenerators[player]) do
      destroyElement(v)
    end
    self.smokeGenerators[player] = nil
  end
end
 
function angleDiff(angle1, angle2)
  angle1, angle2 = angle1 % 360, angle2 % 360
  local diff = (angle1 - angle2) % 360
  if diff <= 180 then
    return diff
  else
    return -(360 - diff)
  end
end
 
local function isPedInWater(ped)
  local pedPosition = Vector3D:new(getElementPosition(ped))
  if pedPosition.z <= 0 then return true end
 
  local waterLevel = getWaterLevel(pedPosition.x, pedPosition.y, pedPosition.z)
  if not isElementStreamedIn(ped) or not waterLevel or waterLevel < pedPosition.z then
    return false
  else
    return true
  end
end
 
local function isnan(x)
    math.inf = 1/0
    if x == math.inf or x == -math.inf or x ~= x then
        return true
    end
    return false
end
 
local function getVector2DAngle(vec)
  if vec.x == 0 and vec.y == 0 then return 0 end
  local angle = math.deg(math.atan(vec.x / vec.y)) + 90
  if vec.y < 0 then
    angle = angle + 180
  end
  return angle
end
 
--
-- Initialization and shutdown functions
--
function Superman.Start()
  local self = Superman
 
  -- Register events
  addEventHandler("onClientResourceStop", getResourceRootElement(thisResource), Superman.Stop, false)
  addEventHandler("onPlayerJoin", rootElement, Superman.onJoin)
  addEventHandler("onPlayerQuit", rootElement, Superman.onQuit)
  addEventHandler("onClientRender", rootElement, Superman.processControls)
  addEventHandler("onClientRender", rootElement, Superman.processFlight)
  addEventHandler("onClientPlayerDamage", localPlayer, Superman.onDamage, false)
  addEventHandler("onClientElementDataChange", rootElement, Superman.onDataChange)
  addEventHandler("onClientElementStreamIn", rootElement, Superman.onStreamIn)
  addEventHandler("onClientElementStreamOut", rootElement, Superman.onStreamOut)
 
  -- Bind keys
  bindKey("jump", "down", Superman.onJump)
 
  -- Register commands
  addCommandHandler("superman", Superman.cmdSuperman)
 
  -- Initializate attributes
  self.smokeGenerators = {}
  self.rotations = {}
  self.previousVelocity = {}
end
addEventHandler("onClientResourceStart", getResourceRootElement(thisResource), Superman.Start, false)
 
function Superman.Stop()
  local self = Superman
 
  setGravity(serverGravity)
 
  -- Restore all players animations, collisions, etc
  for player in iterateFlyingPlayers() do
    self:restorePlayer(player)
  end
end
 
 
 
--
-- Join/Quit
--
function Superman.onJoin(player)
  local self = Superman
  local player = player or source
 
  setPlayerFlying(player, false)
end
 
function Superman.onQuit(reason, player)
  local self = Superman
  local player = player or source
 
  if isPlayerFlying(player) then
    self:restorePlayer(player)
  end
end
 
 
--
-- onDamage: superman is invulnerable
--
function Superman.onDamage()
  local self = Superman
 
  if isPlayerFlying(localPlayer) then
    cancelEvent()
  end
end
 
 
--
-- onStreamIn: Reset rotation attribute for player
--
function Superman.onStreamIn()
  local self = Superman
end
 
function Superman.onStreamOut()
  local self = Superman
 
  if source and isElement(source) and getElementType(source) == "player" and isPlayerFlying(source) then
    self.rotations[source] = nil
    self.previousVelocity[source] = nil
  end
end
 
--
-- onDataChange: Check if somebody who is out of stream stops being superman
--
function Superman.onDataChange(dataName, oldValue)
  local self = Superman
 
  if dataName == "superman:flying" and isElement(source) and getElementType(source) == "player" and
     oldValue ~= getElementData(source, dataName) and oldValue == true and getElementData(source, dataName) == false then
    self:restorePlayer(source)
  end
end
 
--
-- onJump: Combo to start flight without any command
--
Link to comment

هيك بيزببط ؟

  
  
local groupsTable = { 
    "oneradmin", 
    "Head.Admin",  
    "Console", 
    "big.Admin", 
    "Master", 
    "Moafek", 
    "Sozr", 
    "FDR", 
} 
  
addEventHandler ("onPlayerLogin", root, 
function(player, commandName, ...) 
    local account = getPlayerAccount(player) 
    if account and not isGuestAccount(account) then 
        local accName = getAccountName(account) 
        local hasPermission 
        for _, groupName in ipairs(groupsTable) do 
            local group = aclGetGroup(groupName) 
            if group then 
                if isObjectInACLGroup("user."..accName, group) then 
                    hasPermission = true 
                    break 
                end 
            end 
        end 
        if hasPermission then 
            setElementData (source, "isAdmin", true) 
        end 
    end 
end) 
  
  
  

Edited by Guest
Link to comment
  
  
local groupsTable = { 
    "oneradmin", 
    "Head.Admin",  
    "Console", 
    "big.Admin", 
    "Master", 
    "Moafek", 
    "Sozr", 
    "FDR", 
} 
  
addEventHandler ("onPlayerLogin", root, 
function(commandName, ...) 
    local account = getPlayerAccount(source) 
    if account and not isGuestAccount(account) then 
        local accName = getAccountName(account) 
        local hasPermission 
        for _, groupName in ipairs(groupsTable) do 
            local group = aclGetGroup(groupName) 
            if group then 
                if isObjectInACLGroup("user."..accName, group) then 
                    hasPermission = true 
                    break 
                end 
            end 
        end 
        if hasPermission then 
            setElementData (source, "isAdmin", true) 
        end 
    end 
end) 
  
  

تشذي.؟

Link to comment
local groupsTable = { 
    "oneradmin", 
    "Head.Admin", 
    "Console", 
    "big.Admin", 
    "Master", 
    "Moafek", 
    "Sozr", 
    "FDR", 
} 
  
addEventHandler("onPlayerLogin", root, 
function(_, acc) 
    local accName = getAccountName(acc) 
    for _, groupName in ipairs(groupsTable) do 
        local group = aclGetGroup(groupName) 
        if group then 
            if isObjectInACLGroup("user."..accName, group) then 
                setElementData(source, "isAdmin", true) 
                break 
            end 
        end 
    end 
end) 

Link to comment
addEventHandler("onResourceStart",resourceRoot,  
function()  
    local XML = xmlCreateFile ( "Save.xml", "Ranks" )  
    local CreateChild = xmlCreateChild(XML, "Ranks")  
     xmlNodeSetValue ( CreateChild, groupsTable)  
    xmlSaveFile ( XML )  
    end  
)  
  
  
  
  
local Superman = {} 
  
-- Static global values 
local rootElement = getRootElement() 
local thisResource = getThisResource() 
  
-- Resource events 
addEvent("superman:start", true) 
addEvent("superman:stop", true) 
  
-- 
-- Start/stop functions 
-- 
function Superman.Start() 
  local self = Superman 
  
  addEventHandler("superman:start", rootElement, self.clientStart) 
  addEventHandler("superman:stop", rootElement, self.clientStop) 
end 
addEventHandler("onResourceStart", getResourceRootElement(thisResource), Superman.Start, false) 
  
function Superman.clientStart() 
  setElementData(client, "superman:flying", true) 
end 
  
function Superman.clientStop() 
  setElementData(client, "superman:flying", false) 
end 
  
local groupsTable = { 
    "oneradmin", 
    "Head.Admin", 
    "Console", 
    "big.Admin", 
    "Master", 
    "Moafek", 
    "Sozr", 
    "FDR", 
} 
  
  
addEventHandler("onPlayerLogin", root, 
function(_, acc) 
 local XML = xmlLoadFile ( "Save.xml" ) 
 if XML then  
 local Child = xmlFindChild ( XML, "Ranks", 0 ) 
  if Child  then  
local Get = xmlNodeGetValue ( Child ) 
    local accName = getAccountName(acc) 
    for _, groupName in ipairs(Get) do 
        local group = aclGetGroup(groupName) 
        if group then 
            if isObjectInACLGroup("user."..accName, group) then 
                setElementData(source, "isAdmin", true) 
                break 
               end 
            end 
        end 
    end 
end) 
  

Edited by Guest
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...