Jump to content

Turbe$Z

Members
  • Posts

    439
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Turbe$Z

  1. addEventHandler("onPlayerLogout", getRootElement(), function () local name = getPlayerName ( source ) if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then exports[getResourceName(resource)]:addNotification(root, name.." kilépett a tulajdonos szolgálatból!", "success") end end ) what wrong? onPlayerLogin working with this.. wtf?!
  2. client: local localPlayer = getLocalPlayer() local playerName = getPlayerName(localPlayer) function noBinds() guiSetInputMode("no_binds_when_editing") end addEventHandler("onClientResourceStart", root, noBinds) function createLoginWindow() windowLogin = guiCreateWindow(0.3945,0.3646,0.2109,0.2018,"Magyar Play Szerver - Loginpanel by turbesz",true) guiSetSize(windowLogin, 270, 175, false) guiSetAlpha(windowLogin,1) labelUsername = guiCreateLabel(10,52,59,24,"Felh.név:",false,windowLogin) guiSetAlpha(labelUsername,1) guiLabelSetColor(labelUsername,255,255,255) guiLabelSetVerticalAlign(labelUsername,"center") guiLabelSetHorizontalAlign(labelUsername,"left",false) labelPassword = guiCreateLabel(10,86,59,24,"Jelszó:",false,windowLogin) guiSetAlpha(labelPassword,1) guiLabelSetColor(labelPassword,255,255,255) guiLabelSetVerticalAlign(labelPassword,"center") guiLabelSetHorizontalAlign(labelPassword,"left",false) labelInfo = guiCreateLabel(10,26,250,17,"Regizz, és jelentkezz be a játékhoz.",false,windowLogin) guiSetAlpha(labelInfo,1) guiLabelSetColor(labelInfo,255,255,255) guiLabelSetVerticalAlign(labelInfo,"top") guiLabelSetHorizontalAlign(labelInfo,"center",false) guiSetFont(labelInfo,"default-bold-small") editUsername = guiCreateEdit(79,52,181,25,"",false,windowLogin) guiSetAlpha(editUsername,1) guiEditSetMaxLength(editUsername, 50) editPassword = guiCreateEdit(79,86,181,25,"",false,windowLogin) guiSetAlpha(editPassword,1) guiEditSetMasked(editPassword, true) guiEditSetMaxLength(editPassword, 50) buttonLogin = guiCreateButton(10,121,120,21,"Bejelentkezés",false,windowLogin) guiSetAlpha(buttonLogin,1) buttonRegister = guiCreateButton(143,121,117,21,"Regisztrálás",false,windowLogin) guiSetAlpha(buttonRegister,1) buttonGuest = guiCreateButton(10,145,121,21,"Vendég",false,windowLogin) guiSetAlpha(buttonGuest,1) checkbox_save = guiCreateCheckBox(157,145,117,21,"Adatok mentése",false,false,windowLogin) guiSetFont(checkbox_save,"default-small") guiWindowSetSizable ( windowLogin, false ) guiSetVisible(windowLogin, false) addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false) addEventHandler("onClientGUIClick", buttonRegister, clientSubmitRegister, false) local username, password = loadLoginFromXML() if not( username == "" or password == "") then guiCheckBoxSetSelected ( checkbox_save, true ) guiSetText ( editUsername, tostring(username)) guiSetText ( editPassword, tostring(password)) else guiCheckBoxSetSelected ( checkbox_save, false ) guiSetText ( editUsername, tostring(username)) guiSetText ( editPassword, tostring(password)) end end function loadLoginFromXML() local xml_save_log_File = xmlLoadFile ("files/xml/adatok.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/adatok.xml", "login") end local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if usernameNode and passwordNode then return xmlNodeGetValue(usernameNode), xmlNodeGetValue(passwordNode) else return "", "" end xmlUnloadFile ( xml_save_log_File ) end function saveLoginToXML(username, password) local xml_save_log_File = xmlLoadFile ("files/xml/adatok.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/adatok.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) if not usernameNode then usernameNode = xmlCreateChild(xml_save_log_File, "username") end xmlNodeSetValue (usernameNode, tostring(username)) end if (password ~= "") then local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue (passwordNode, tostring(password)) end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) end addEvent("saveLoginToXML", true) addEventHandler("saveLoginToXML", getRootElement(), saveLoginToXML) function resetSaveXML() local xml_save_log_File = xmlLoadFile ("files/xml/adatok.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/adatok.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) if not usernameNode then usernameNode = xmlCreateChild(xml_save_log_File, "username") end end if (password ~= "") then local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue (passwordNode, "") end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) end addEvent("resetSaveXML", true) addEventHandler("resetSaveXML", getRootElement(), resetSaveXML) addEventHandler("onClientGUIClick",root, function () if source == buttonGuest then guiSetVisible ( windowLogin , false ) showCursor(false) end end ) function resourceStart() createLoginWindow() if (windowLogin ~= nil) then guiSetVisible(windowLogin, true) else outputChatBox("Whoops, valami error történt.") end showCursor(true) guiSetInputEnabled(true) end function clientSubmitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(editUsername) local password = guiGetText(editPassword) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else guiSetText(labelInfo, "Írj be felh.nevet és jelszót.") end end end function clientSubmitRegister(button, state) if button == "left" and state == "up" then local username = guiGetText(editUsername) local password = guiGetText(editPassword) if username and password then triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password) else guiSetText(labelInfo, "Írj be felh.nevet és jelszót.") end end end function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(windowLogin, false) showCursor(false) end function unknownError() guiSetText(labelInfo, "Ismeretlen hiba.") end function loginWrong() guiSetText(labelInfo, "Hibás adatok.") end function registerTaken() guiSetText(labelInfo, "Felhasználó név regisztrálva van.") end addEvent("hideLoginWindow", true) addEvent("unknownError", true) addEvent("loginWrong", true) addEvent("registerTaken", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) addEventHandler("unknownError", getRootElement(), unknownError) addEventHandler("loginWrong", getRootElement(), loginWrong) addEventHandler("registerTaken", getRootElement(), registerTaken) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), resourceStart) fileDelete("client.lua") server: function loginHandler(player, username, password, checksave) local account = getAccount(username, password) if (account ~= false) then if (logIn(player, account, password) == true) then triggerClientEvent (player, "hideLoginWindow", getRootElement()) if checksave == true then triggerClientEvent(source,"saveLoginToXML",getRootElement(),username,password) else triggerClientEvent(source,"resetSaveXML",getRootElement(),username,password) end else triggerClientEvent (player, "unknownError", getRootElement()) end else triggerClientEvent (player, "loginWrong", getRootElement()) end end function registerHandler(player, username, password) local account = getAccount(username, password) if (account ~= false) then triggerClientEvent(player, "registerTaken", getRootElement()) else account = addAccount(username, password) if (logIn(player, account, password) == true) then triggerClientEvent(player, "hideLoginWindow", getRootElement()) else triggerClientEvent(player, "unknownError", getRootElement()) end end end addEvent("submitLogin", true) addEvent("submitRegister", true) addEventHandler("submitLogin", root, loginHandler) addEventHandler("submitRegister", root, registerHandler) why not save?
  3. working, but when i join, the online admins not show.. how to fix?
  4. why not show online admins, when i join? how to fix?*
  5. Client.lua : LblOnlineAdmins = {} admins = "" function setAdminList(list) if (admins ~= list) then admins = list if (admins == "") then guiSetText(LblOnlineAdmins, "Admins online: none") else guiSetText(LblOnlineAdmins, "Admins online: " .. admins) end end end addEvent( "setAdminList", true ) addEventHandler( "setAdminList", getRootElement(), setAdminList ) function getAdmins() LblOnlineAdmins = guiCreateLabel(0,0.9466,0.3799,0.0247,"",true) guiLabelSetColor(LblOnlineAdmins,255,0,0) guiLabelSetVerticalAlign(LblOnlineAdmins,"top") guiLabelSetHorizontalAlign(LblOnlineAdmins,"left",true) guiSetFont(LblOnlineAdmins,"default-bold-small") end addEventHandler( "onClientResourceStart", getRootElement( ), getAdmins) Server.lua : admins = "" function processAdminList() players = getElementsByType ( "player" ) admins = "" for k,v in ipairs(players) do local accountname = "" if (isGuestAccount(getPlayerAccount(v)) == false) then accountname = getAccountName (getPlayerAccount(v)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then if (admins == "") then admins = getPlayerName(v) else admins = admins .. ", " .. getPlayerName(v) end end end end triggerClientEvent("setAdminList", getResourceRootElement(), admins) end addEventHandler( "onPlayerLogin", getRootElement(), processAdminList ) addEventHandler( "onPlayerLogout", getRootElement(), processAdminList ) addEventHandler( "onPlayerChangeNick", getRootElement(), processAdminList ) addEventHandler( "onPlayerQuit", getRootElement(), processAdminList ) addEventHandler("onPlayerJoin", getRootElement(), processAdminList) how to fix?:(
  6. doesn't working
  7. first error by: function createKillMessageGUI() local gap = config.iconHeight - config.textHeight gap = gap/2 for i=1,config.lines do local y = config.startY*screenY + (config.iconHeight*(i-1)) y = y + gap contentMessages[i] = { dxText:create("",0,y) } end endTime = config.fadeTime + config.startFade end -- second error by: function destroyLine ( line ) for k,part in ipairs(contentMessages[line]) do destroyWidget(part) end contentMessages[line] = {} end first error: killmessages\gui.lua:159: attempt to index global 'dxText' (a nil value) second error: killmessages\gui.lua:468: bad argument #1 to 'ipairs' (table expected, got nil) how to fix this? i tried fix, but doesn't working
  8. local ScreenSizeX,ScreenSizeY = guiGetScreenSize(); local StartTick,Duration,EndTick = nil,2000,nil; local Debounce = false; local rootElement = getRootElement() local screenWidth, screenHeight = guiGetScreenSize() -- Get the screen resolution local function RenderHandler() local playerX, playerY, playerZ = getElementPosition( getLocalPlayer() ) -- Get player's coordinates. local playerZoneName = getZoneName( playerX, playerY, playerZ ) -- Get name of the player's zone. local CurrentTick = getTickCount(); -- get the current tick; local Progress = (CurrentTick-StartTick)/Duration; -- calculate the progress between 0 and 1 using simple math; local Alpha = interpolateBetween(0,0,0,255,0,0,Progress,"InOutQuad"); dxDrawText(playerZoneName,ScreenSizeX/2,ScreenSizeY/2,ScreenSizeX,ScreenSizeY,tocolor(255,255,255,Alpha),1,"default-bold"); if CurrentTick>=EndTick then -- if the animation is finished; StartTick,EndTick = nil,nil; -- clear variables; removeEventHandler("onClientRender",root,RenderHandler); -- remove the render handler; Debounce = false; -- we can now use /dx again; end; end; addEventHandler("onClientRender",rootElement, function() if not Debounce then -- if the text isn't already rendering; Debounce = true; StartTick = getTickCount(); -- get the current tick as the start tick of the animation; EndTick = StartTick+Duration+1000; -- calculate the end tick; addEventHandler("onClientRender",root,RenderHandler); -- add the render handler only when you type the command; end; end); fileDelete("client.lua") when i start script, the dx message show the zone name more than one, but i want, show the zone name only 1x how to fix this? sorry for my bad english
  9. client.lua:65: bad argument @ 'getElementData' [expected element at argument 1, got nil]
  10. -- Copyright (c) 2008, Alberto Alonso -- -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without modification, -- are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright notice, this -- list of conditions and the following disclaimer in the documentation and/or other -- materials provided with the distribution. -- * Neither the name of the superman script nor the names of its contributors may be used -- to endorse or promote products derived from this software without specific prior -- written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. local Superman = {} function canceldamage() cancelEvent() end addEventHandler("onClientPedDamage", getRootElement(), canceldamage) -- 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() function canFly() if getElementData(source,"SuperMan") == true then end end -- -- 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) attachElements(smokeGenerators[1], player, 0.75, -0.2, -0.4, -40, 0, 60) smokeGenerators[2] = self:createSmokeGenerator(player) attachElements(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 isElementInWater(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 -- function Superman.onJump(key, keyState) if not canFly() then return end local self = Superman local task = getPedSimplestTask(localPlayer) if not isPlayerFlying(localPlayer) then if task == "TASK_SIMPLE_IN_AIR" then setElementVelocity(localPlayer, 0, 0, TAKEOFF_VELOCITY) setTimer(Superman.startFlight, 100, 1) end end end -- -- Commands -- function Superman.cmdSuperman() if not canFly() then return end local self = Superman if isPedInVehicle(localPlayer) or isPlayerFlying(localPlayer) then return end setElementVelocity(localPlayer, 0, 0, TAKEOFF_VELOCITY) setTimer(Superman.startFlight, TAKEOFF_FLIGHT_DELAY, 1) end function Superman.startFlight() local self = Superman if isPlayerFlying(localPlayer) then return end triggerServerEvent("superman:start", rootElement) setPlayerFlying(localPlayer, true) setElementVelocity(localPlayer, 0, 0, 0) self.currentSpeed = 0 self.extraVelocity = { x = 0, y = 0, z = 0 } end -- -- Controls processing -- local jump, oldJump = false, false function Superman.processControls() local self = Superman if not isPlayerFlying(localPlayer) then jump, oldJump = getControlState("jump"), jump if canFly() and not oldJump and jump then Superman.onJump() end return end -- if not isPlayerFlying(localPlayer) then return end -- Calculate the requested movement direction local Direction = Vector3D:new(0, 0, 0) if getControlState("forwards") then Direction.y = 1 elseif getControlState("backwards") then Direction.y = -1 end if getControlState("left") then Direction.x = 1 elseif getControlState("right") then Direction.x = -1 end Direction:Normalize() -- Calculate the sight direction local cameraX, cameraY, cameraZ, lookX, lookY, lookZ = getCameraMatrix() local SightDirection = Vector3D:new((lookX - cameraX), (lookY - cameraY), (lookZ - cameraZ)) SightDirection:Normalize() if getControlState("look_behind") then SightDirection = SightDirection:Mul(-1) end -- Calculate the current max speed and acceleration values local maxSpeed = MAX_SPEED local acceleration = ACCELERATION if getControlState("sprint") then maxSpeed = MAX_SPEED * EXTRA_SPEED_FACTOR acceleration = acceleration * EXTRA_ACCELERATION_FACTOR elseif getControlState("walk") then maxSpeed = MAX_SPEED * LOW_SPEED_FACTOR acceleration = acceleration * LOW_ACCELERATION_FACTOR end local DirectionModule = Direction:Module() -- Check if we must change the gravity if DirectionModule == 0 and self.currentSpeed ~= 0 then setGravity(0) else setGravity(serverGravity) end -- Calculate the new current speed if self.currentSpeed ~= 0 and (DirectionModule == 0 or self.currentSpeed > maxSpeed) then -- deccelerate self.currentSpeed = self.currentSpeed - acceleration if self.currentSpeed < 0 then self.currentSpeed = 0 end elseif DirectionModule ~= 0 and self.currentSpeed < maxSpeed then -- accelerate self.currentSpeed = self.currentSpeed + acceleration if self.currentSpeed > maxSpeed then self.currentSpeed = maxSpeed end end -- Calculate the movement requested direction if DirectionModule ~= 0 then Direction = Vector3D:new(SightDirection.x * Direction.y - SightDirection.y * Direction.x, SightDirection.x * Direction.x + SightDirection.y * Direction.y, SightDirection.z * Direction.y) -- Save the last movement direction for when player releases all direction keys self.lastDirection = Direction else -- Player is not specifying any direction, use last known direction or the current velocity if self.lastDirection then Direction = self.lastDirection if self.currentSpeed == 0 then self.lastDirection = nil end else Direction = Vector3D:new(getElementVelocity(localPlayer)) end end Direction:Normalize() Direction = Direction:Mul(self.currentSpeed) -- Applicate a smooth direction change, if moving if self.currentSpeed > 0 then local VelocityDirection = Vector3D:new(getElementVelocity(localPlayer)) VelocityDirection:Normalize() if math.sqrt(VelocityDirection.x^2 + VelocityDirection.y^2) > 0 then local DirectionAngle = getVector2DAngle(Direction) local VelocityAngle = getVector2DAngle(VelocityDirection) local diff = angleDiff(DirectionAngle, VelocityAngle) local calculatedAngle if diff >= 0 then if diff > MAX_ANGLE_SPEED then calculatedAngle = VelocityAngle + MAX_ANGLE_SPEED else calculatedAngle = DirectionAngle end else if diff < MAX_ANGLE_SPEED then calculatedAngle = VelocityAngle - MAX_ANGLE_SPEED else calculatedAngle = DirectionAngle end end calculatedAngle = calculatedAngle % 360 local DirectionModule2D = math.sqrt(Direction.x^2 + Direction.y^2) Direction.x = -DirectionModule2D*math.cos(math.rad(calculatedAngle)) Direction.y = DirectionModule2D*math.sin(math.rad(calculatedAngle)) end end if Direction:Module() == 0 then self.extraVelocity = { x = 0, y = 0, z = 0 } end -- Set the new velocity setElementVelocity(localPlayer, Direction.x + self.extraVelocity.x, Direction.y + self.extraVelocity.y, Direction.z + self.extraVelocity.z) if self.extraVelocity.z > 0 then self.extraVelocity.z = self.extraVelocity.z - 1 if self.extraVelocity.z < 0 then self.extraVelocity.z = 0 end elseif self.extraVelocity.z < 0 then self.extraVelocity.z = self.extraVelocity.z + 1 if self.extraVelocity.z > 0 then self.extraVelocity.z = 0 end end end -- -- Players flight processing -- function Superman.processFlight() local self = Superman for player in iterateFlyingPlayers() do local Velocity = Vector3D:new(getElementVelocity(player)) local distanceToBase = getElementDistanceFromCentreOfMassToBaseOfModel(player) local playerPos = Vector3D:new(getElementPosition(player)) playerPos.z = playerPos.z - distanceToBase local distanceToGround if playerPos.z > 0 then local hit, hitX, hitY, hitZ, hitElement = processLineOfSight(playerPos.x, playerPos.y, playerPos.z, playerPos.x, playerPos.y, playerPos.z - LANDING_DISTANCE - 1, true, true, true, true, true, false, false, false) if hit then distanceToGround = playerPos.z - hitZ end end if distanceToGround and distanceToGround < GROUND_ZERO_TOLERANCE then self:restorePlayer(player) if player == localPlayer then setGravity(serverGravity) triggerServerEvent("superman:stop", getRootElement()) end elseif distanceToGround and distanceToGround < LANDING_DISTANCE then self:processLanding(player, Velocity, distanceToGround) elseif Velocity:Module() < ZERO_TOLERANCE then self:processIdleFlight(player) else self:processMovingFlight(player, Velocity) end end end function Superman:processIdleFlight(player) -- Set the proper animation on the player local animLib, animName = getPedAnimation(player) if animLib ~= IDLE_ANIMLIB or animName ~= IDLE_ANIMATION then setPedAnimation(player, IDLE_ANIMLIB, IDLE_ANIMATION, -1, IDLE_ANIM_LOOP, false, false) end setElementCollisionsEnabled(player, false) -- If this is myself, calculate the ped rotation depending on the camera rotation if player == localPlayer then local cameraX, cameraY, cameraZ, lookX, lookY, lookZ = getCameraMatrix() local Sight = Vector3D:new(lookX - cameraX, lookY - cameraY, lookZ - cameraZ) Sight:Normalize() if getControlState("look_behind") then Sight = Sight:Mul(-1) end Sight.z = math.atan(Sight.x / Sight.y) if Sight.y > 0 then Sight.z = Sight.z + math.pi end Sight.z = math.deg(Sight.z) + 180 setPedRotation(localPlayer, Sight.z) setElementRotation(localPlayer, 0, 0, Sight.z) else local Zangle = getPedCameraRotation(player) setPedRotation(player, Zangle) setElementRotation(player, 0, 0, Zangle) end end function Superman:processMovingFlight(player, Velocity) -- Set the proper animation on the player local animLib, animName = getPedAnimation(player) if animLib ~= FLIGHT_ANIMLIB or animName ~= FLIGHT_ANIMATION then setPedAnimation(player, FLIGHT_ANIMLIB, FLIGHT_ANIMATION, -1, FLIGHT_ANIM_LOOP, true, false) end if player == localPlayer then setElementCollisionsEnabled(player, true) else setElementCollisionsEnabled(player, false) end -- Calculate the player rotation depending on their velocity local Rotation = Vector3D:new(0, 0, 0) if Velocity.x == 0 and Velocity.y == 0 then Rotation.z = getPedRotation(player) else Rotation.z = math.deg(math.atan(Velocity.x / Velocity.y)) if Velocity.y > 0 then Rotation.z = Rotation.z - 180 end Rotation.z = (Rotation.z + 180) % 360 end Rotation.x = -math.deg(Velocity.z / Velocity:Module() * 1.2) -- Rotation compensation for the self animation rotation Rotation.x = Rotation.x - 40 -- Calculate the Y rotation for barrel rotations if not self.rotations[player] then self.rotations[player] = 0 end if not self.previousVelocity[player] then self.previousVelocity[player] = Vector3D:new(0, 0, 0) end local previousAngle = getVector2DAngle(self.previousVelocity[player]) local currentAngle = getVector2DAngle(Velocity) local diff = angleDiff(currentAngle, previousAngle) if isnan(diff) then diff = 0 end local calculatedYRotation = -diff * MAX_Y_ROTATION / MAX_ANGLE_SPEED if calculatedYRotation > self.rotations[player] then if calculatedYRotation - self.rotations[player] > ROTATION_Y_SPEED then self.rotations[player] = self.rotations[player] + ROTATION_Y_SPEED else self.rotations[player] = calculatedYRotation end else if self.rotations[player] - calculatedYRotation > ROTATION_Y_SPEED then self.rotations[player] = self.rotations[player] - ROTATION_Y_SPEED else self.rotations[player] = calculatedYRotation end end if self.rotations[player] > MAX_Y_ROTATION then self.rotations[player] = MAX_Y_ROTATION elseif self.rotations[player] < -MAX_Y_ROTATION then self.rotations[player] = -MAX_Y_ROTATION elseif math.abs(self.rotations[player]) < ZERO_TOLERANCE then self.rotations[player] = 0 end Rotation.y = self.rotations[player] -- Apply the calculated rotation setPedRotation(player, Rotation.z) setElementRotation(player, Rotation.x, Rotation.y, Rotation.z) -- Save the current velocity self.previousVelocity[player] = Velocity -- If the speed is over the given value, create the smoke generators if Velocity:Module() > (SMOKING_SPEED - ZERO_TOLERANCE) and not isElementInWater(player) then self:createSmokeGenerators(player) else self:destroySmokeGenerators(player) end end function Superman:processLanding(player, Velocity, distanceToGround) -- Set the proper animation on the player local animLib, animName = getPedAnimation(player) if animLib ~= FLIGHT_ANIMLIB or animName ~= FLIGHT_ANIMATION then setPedAnimation(player, FLIGHT_ANIMLIB, FLIGHT_ANIMATION, -1, FLIGHT_ANIM_LOOP, true, false) end if player == localPlayer then setElementCollisionsEnabled(player, true) else setElementCollisionsEnabled(player, false) end -- If the speed is over the given value, create the smoke generators if Velocity:Module() > (SMOKING_SPEED - ZERO_TOLERANCE) and not isElementInWater(player) then self:createSmokeGenerators(player) else self:destroySmokeGenerators(player) end -- Calculate the player rotation depending on their velocity and distance to ground local Rotation = Vector3D:new(0, 0, 0) if Velocity.x == 0 and Velocity.y == 0 then Rotation.z = getPedRotation(player) else Rotation.z = math.deg(math.atan(Velocity.x / Velocity.y)) if Velocity.y > 0 then Rotation.z = Rotation.z - 180 end Rotation.z = (Rotation.z + 180) % 360 end Rotation.x = -(85 - (distanceToGround * 85 / LANDING_DISTANCE)) -- Rotation compensation for the self animation rotation Rotation.x = Rotation.x - 40 -- Apply the calculated rotation setPedRotation(player, Rotation.z) setElementRotation(player, Rotation.x, Rotation.y, Rotation.z) end -- -- Vectors -- Vector3D = { new = function(self, _x, _y, _z) local newVector = { x = _x or 0.0, y = _y or 0.0, z = _z or 0.0 } return setmetatable(newVector, { __index = Vector3D }) end, Copy = function(self) return Vector3D:new(self.x, self.y, self.z) end, Normalize = function(self) local mod = self:Module() if mod ~= 0 then self.x = self.x / mod self.y = self.y / mod self.z = self.z / mod end end, Dot = function(self, V) return self.x * V.x + self.y * V.y + self.z * V.z end, Module = function(self) return math.sqrt(self.x * self.x + self.y * self.y + self.z * self.z) end, AddV = function(self, V) return Vector3D:new(self.x + V.x, self.y + V.y, self.z + V.z) end, SubV = function(self, V) return Vector3D:new(self.x - V.x, self.y - V.y, self.z - V.z) end, CrossV = function(self, V) return Vector3D:new(self.y * V.z - self.z * V.y, self.z * V.x - self.x * V.z, self.x * V.y - self.y * V.z) end, Mul = function(self, n) return Vector3D:new(self.x * n, self.y * n, self.z * n) end, Div = function(self, n) return Vector3D:new(self.x / n, self.y / n, self.z / n) end, MulV = function(self, V) return Vector3D:new(self.x * V.x, self.y * V.y, self.z * V.z) end, DivV = function(self, V) return Vector3D:new(self.x / V.x, self.y / V.y, self.z / V.z) end, } this full code
  11. like this ? function canFly() if getElementData(source,"SuperMan") == true then end end
  12. unnecessary, because i got this error: ERROR: superman-admin\client.lua:65: attempt to call global 'getPlayerAccount' (a nil value) how to fix this error?
  13. i downloaded this from community: script and this from script decription: "If you want to restrict it to the Admin ACL, then replace it: local function canFly()return getTeamName(getPlayerTeam(getLocalPlayer())) == "Admins"endfor: local function canFly() return (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Admin"))) end" and i tried this, but doesn't working this is from client.lua: -- -- Check for admin privileges -- local function canFly() return (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Admin"))) end How to fix this? Why not working?
  14. local localPlayer = getLocalPlayer() local playerName = getPlayerName(localPlayer) function createLoginWindow() windowLogin = guiCreateWindow(0.3945,0.3646,0.2109,0.2018,"Magyar Play Szerver - Loginpanel by turbesz",true) guiSetSize(windowLogin, 270, 155, false) guiSetAlpha(windowLogin,1) labelUsername = guiCreateLabel(10,52,59,24,"Felh.név:",false,windowLogin) guiSetAlpha(labelUsername,1) guiLabelSetColor(labelUsername,255,255,255) guiLabelSetVerticalAlign(labelUsername,"center") guiLabelSetHorizontalAlign(labelUsername,"left",false) labelPassword = guiCreateLabel(10,86,59,24,"Jelszó:",false,windowLogin) guiSetAlpha(labelPassword,1) guiLabelSetColor(labelPassword,255,255,255) guiLabelSetVerticalAlign(labelPassword,"center") guiLabelSetHorizontalAlign(labelPassword,"left",false) labelInfo = guiCreateLabel(10,26,250,17,"Regizz, és jelentkezz be a játékhoz.",false,windowLogin) guiSetAlpha(labelInfo,1) guiLabelSetColor(labelInfo,255,255,255) guiLabelSetVerticalAlign(labelInfo,"top") guiLabelSetHorizontalAlign(labelInfo,"center",false) guiSetFont(labelInfo,"default-bold-small") editUsername = guiCreateEdit(79,52,181,25,"",false,windowLogin) guiSetAlpha(editUsername,1) guiEditSetMaxLength(editUsername, 50) editPassword = guiCreateEdit(79,86,181,25,"",false,windowLogin) guiSetAlpha(editPassword,1) guiEditSetMasked(editPassword, true) guiEditSetMaxLength(editPassword, 50) buttonLogin = guiCreateButton(10,121,120,21,"Bejelentkezés",false,windowLogin) guiSetAlpha(buttonLogin,1) buttonRegister = guiCreateButton(143,121,117,21,"Regisztrálás",false,windowLogin) guiSetAlpha(buttonRegister,1) guiWindowSetSizable ( windowLogin, false ) guiSetInputMode("no_binds_when_editing") guiSetVisible(windowLogin, false) addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false) addEventHandler("onClientGUIClick", buttonRegister, clientSubmitRegister, false) end function resourceStart() createLoginWindow() if (windowLogin ~= nil) then guiSetVisible(windowLogin, true) else outputChatBox("Whoops, valami error történt.") end showCursor(true) guiSetInputEnabled(true) guiSetInputMode("no_binds_when_editing") end function clientSubmitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(editUsername) local password = guiGetText(editPassword) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else guiSetText(labelInfo, "Írj be felh.nevet és jelszót.") end end end function clientSubmitRegister(button, state) if button == "left" and state == "up" then local username = guiGetText(editUsername) local password = guiGetText(editPassword) if username and password then triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password) else guiSetText(labelInfo, "Írj be felh.nevet és jelszót.") end end end function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(windowLogin, false) showCursor(false) end function unknownError() guiSetText(labelInfo, "Ismeretlen hiba.") end function loginWrong() guiSetText(labelInfo, "Hibás adatok.") end function registerTaken() guiSetText(labelInfo, "Felhasználó név regisztrálva van.") end guiSetInputMode("no_binds_when_editing") addEvent("hideLoginWindow", true) addEvent("unknownError", true) addEvent("loginWrong", true) addEvent("registerTaken", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) addEventHandler("unknownError", getRootElement(), unknownError) addEventHandler("loginWrong", getRootElement(), loginWrong) addEventHandler("registerTaken", getRootElement(), registerTaken) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), resourceStart) i added one more line this: guiSetInputMode("no_binds_when_editing") but.. binds working when i type my name, and pass, why? how to fix?
  15. function createPasswordWindow() windowChangepw = guiCreateWindow(0.3859,0.349,0.2130,0.1628,"Jelszó váltás",true) guiSetSize(windowChangepw, 165, 21) guiSetAlpha(windowChangepw,0.80000001192093) editOldpw = guiCreateEdit(110,29,180,21,"",false,windowChangepw) guiSetAlpha(editOldpw,1) guiEditSetMasked(editOldpw,true) labelOldpw = guiCreateLabel(10,29,90,21,"Régi:",false,windowChangepw) guiSetAlpha(labelOldpw,1) guiLabelSetColor(labelOldpw,255,255,255) guiLabelSetVerticalAlign(labelOldpw,"center") guiLabelSetHorizontalAlign(labelOldpw,"left",false) editNewpw = guiCreateEdit(110,60,180,21,"",false,windowChangepw) guiSetAlpha(editNewpw,1) guiEditSetMasked(editNewpw,true) guiEditSetMaxLength(editNewpw,50) labelNewpw = guiCreateLabel(10,60,90,21,"Új:",false,windowChangepw) guiSetAlpha(labelNewpw,1) guiLabelSetColor(labelNewpw,255,255,255) guiLabelSetVerticalAlign(labelNewpw,"center") guiLabelSetHorizontalAlign(labelNewpw,"left",false) buttonChangepw = guiCreateButton(10,91,280,23,"Változtatás",false,windowChangepw) guiSetAlpha(buttonChangepw,1) buttonClosepw = guiCreateButton(10,115,90,23,"Bezár",false,windowChangepw) guiSetVisible(windowChangepw, false) addEventHandler("onClientGUIClick", buttonChangepw, clientSubmitChangepw, false) addEventHandler("onClientGUIClick", buttonClosepw, false) end --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- function turbeszbezar() guiSetVisible(windowChangepw, false) showCursor(false) end addEventHandler("onClientGUIClick", buttonClosepw, false) --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- What wrong? Why not working?
  16. when i playing a dm map, and everybody die, the votemap start automatic. how to disable? i want when everyone die, after start votemap
  17. when i have 1000 money for example, and vote the new map, when start the new map this money will be zero. how to fix this bug?
×
×
  • Create New...