Jump to content

Deep thinker

Members
  • Posts

    218
  • Joined

  • Last visited

Everything posted by Deep thinker

  1. check the script for a second.--Client local languages = { ["English"] = "en", ["Spanish"] = "es", ["Afrikaans"] = "af", ["Albanian"] = "sq", ["Arabic"] = "ar", ["Belarusian"] = "be", ["Bulgarian"] = "bg", ["Catalan"] = "ca", ["Chinese"] = "zh", ["Chinese Simplified"] = "zh-CN", ["Chinese Traditional"] = "zh-TW", ["Croatian"] = "hr", ["Czech"] = "cs", ["Danish"] = "da", ["Dutch"] = "nl", ["Estonian"] = "et", ["Filipino"] = "tl", ["Finnish"] = "fi", ["French"] = "fr", ["Galician"] = "gl", ["German"] = "de", ["Greek"] = "el", ["Haitian Creole"] = "ht", ["Hebrew"] = "iw", ["Hindi"] = "hi", ["Hungarian"] = "hu", ["Icelandic"] = "is", ["Indonesian"] = "id", ["Irish"] = "ga", ["Italian"] = "it", ["Japanese"] = "ja", ["Korean"] = "ko", ["Latvian"] = "lv", ["Lithuanian"] = "lt", ["Macedonian"] = "mk", ["Malay"] = "ms", ["Maltese"] = "mt", ["Norwegian"] = "no", ["Persian"] = "fa", ["Polish"] = "pl", ["Portuguese"] = "pt", ["Portuguese Portugal"] = "pt-PT", ["Romanian"] = "ro", ["Russian"] = "ru", ["Serbian"] = "sr", ["Slovak"] = "sk", ["Slovenian"] = "sl", ["Swahili"] = "sw", ["Swedish"] = "sv", ["Tagalog"] = "tl", ["Thai"] = "th", ["Turkish"] = "tr", ["Ukrainian"] = "uk", ["Vietnamese"] = "vi", ["Welsh"] = "cy", ["Yiddish"] = "yi", } window = guiCreateWindow(0.4229,0.2839,0.1416,0.3411,"Select languages for the translated channel",true) guiWindowSetSizable(window,false) guiSetVisible(window,false) comboBox_to = guiCreateComboBox(0.0621,0.1031,0.8207,0.7069,"Spanish",true,window) doneButton = guiCreateButton(0.1655,0.8702,0.6621,0.0916,"Done",true,window) for languageName, language in pairs(languages) do guiComboBoxAddItem(comboBox_to, languageName) end addEvent("showLangSelector",true) addEventHandler("showLangSelector",root, function () guiSetVisible(window,true) showCursor(true) end) addEventHandler("onClientGUIClick",doneButton, function () local selectedTo = guiComboBoxGetSelected(comboBox_to) if selectedTo then local langNameTo = guiComboBoxGetItemText(comboBox_to, selectedTo) setElementData(localPlayer,"lang_to",languages[langNameTo]) guiSetVisible(window,false) showCursor(false) end end, false) --Server Side local languages = { ["en"] = "English", ["es"] = "Spanish", ["af"] = "Afrikaans", ["sq"] = "Albanian", ["ar"] = "Arabic", ["be"] = "Belarusian", ["bg"] = "Bulgarian", ["ca"] = "Catalan", ["zh"] = "Chinese", ["zh-CN"] = "Chinese Simplified", ["zh-TW"] = "Chinese Traditional", ["hr"] = "Croatian", ["cs"] = "Czech", ["da"] = "Danish", ["nl"] = "Dutch", ["et"] = "Estonian", ["tl"] = "Filipino", ["fi"] = "Finnish", ["fr"] = "French", ["gl"] = "Galician", ["de"] = "German", ["el"] = "Greek", ["ht"] = "Haitian Creole", ["iw"] = "Hebrew", ["hi"] = "Hindi", ["hu"] = "Hungarian", ["is"] = "Icelandic", ["id"] = "Indonesian", ["ga"] = "Irish", ["it"] = "Italian", ["ja"] = "Japanese", ["ko"] = "Korean", ["lv"] = "Latvian", ["lt"] = "Lithuanian", ["mk"] = "Macedonian", ["ms"] = "Malay", ["mt"] = "Maltese", ["no"] = "Norwegian", ["fa"] = "Persian", ["pl"] = "Polish", ["pt"] = "Portuguese", ["pt-PT"] = "Portuguese Portugal", ["ro"] = "Romanian", ["ru"] = "Russian", ["sr"] = "Serbian", ["sk"] = "Slovak", ["sl"] = "Slovenian", ["sw"] = "Swahili", ["sv"] = "Swedish", ["tl"] = "Tagalog", ["th"] = "Thai", ["tr"] = "Turkish", ["uk"] = "Ukrainian", ["vi"] = "Vietnamese", ["cy"] = "Welsh", ["yi"] = "Yiddish", } addEventHandler("onPlayerJoin",root, function () bindKey(source,"F4","down",switchChannel) setElementData(source,"lang_to","en") end) addEventHandler("onResourceStart",resourceRoot, function () for index, player in pairs(getElementsByType("player")) do setElementData(player,"translator",false) bindKey(player,"F4","down",switchChannel) if not getElementData(player,"lang_to") then setElementData(player,"lang_to","en") end end end) function switchChannel(player) if getElementData(player,"translator") then setElementData(player,"translator",false) exports["(T-RPG)Info"]:sendMessage(player,"*CHAT* Translator disabled.",0,255,0) else setElementData(player,"translator",true) triggerClientEvent(player,"showLangSelector",player) exports["(T-RPG)Info"]:sendMessage(player,"*CHAT* Translator enabled.",0,255,0) end end function onChat(message, messageType) if (messageType == 0) then local r, g, b = getPlayerNametagColor(source) outputChatBox(getPlayerName(source)..": #ffffff"..message,getRootElement(),r,g,b,true) cancelEvent() end end addEventHandler("onPlayerChat",root,onChat) addEvent("onRecieveTranslatedText",true) addEventHandler("onRecieveTranslatedText",root, function (player, translatedText, bool, languageCode, message) if not bool and not message.player then local r, g, b = getPlayerNametagColor(player) for index, players in pairs(getElementsByType("player")) do if getElementData(players,"translator") then end end end end) addEventHandler("onRecieveTranslatedText",root, function (player, translatedText, bool, languageCode, message) if message and type(message) == "table" and message.player and type(message.player) == "string" and message.r and message.g and message.b then outputChatBox("Translator ("..tostring(languages[languageCode]).."): ".. message.player ..": #ffffff".. translatedText,player,message.r,message.g,message.b,true) end end) I have checked the /debugscript 3 ,it didn't notice anything at all Please answer as soon as possible.
  2. i stopped all the resources and started that chat resource.still bugged and out putting 2 messages instead of 1.
  3. Max: Test Max: test Max: test Max: test when i said Test in Main chat it got repeated 4 times ,i wanna stop this repeating thing it's kinda annoying
  4. no i didn't replace anything ,i meant that there is 2 chat resources,i can't stop the old one to make the anther one work correctly. got my point?
  5. thank you it worked perfectly but i need to fix anther thing in my server ,i have started a new chat resource but when i type something it repeat it self 3 or 2 times. can you tell me a solution ?
  6. i did but i couldn't fix it in any kind of ways .
  7. addEvent('showAssistanceMsg', true) addEventHandler('showAssistanceMsg', root, function(name, location) theAlpha = 255 rand = math.random(-50, 50) function showMSG() if theAlpha > 0 then theAlpha = theAlpha - 0.3 dxDrawText("(..name..)" Requesting Medical Assistance in '(..location..)',x(914.0),y(453.0+rand),x(1322.0),y(504.0),tocolor(0,205,0,theAlpha),x(1.3),"default-bold","center","center",false,false,false) else removeEventHandler('onClientRender', root, showMSG) end end addEventHandler('onClientRender', root, showMSG) end end end end ) function x(f) local sx, sy = guiGetScreenSize() return (sx/1440) * f end function y(f) local sx, sy = guiGetScreenSize() return (sy/900) * f end It's a simple notification script for a job with a command but there is a bug i can't fix which is ')' expected near 'Requesting' ,,please answer asap
  8. i will stay in touch with you in pm,if you don't mind.
  9. thank you ,it worked successfully
  10. i have checked the line 3, i have also edited it but there is a bug function renderStaffTag() local streamedPlayers = getElementsByType ("player", root, true) if not getPlayerTeam(p) or getPlayerTeam(p) ~= getTeamFromName("Staff") then return end if streamedPlayers and #streamedPlayers ~= 0 then local lpos = {getElementPosition(localPlayer)} for _,p in ipairs (streamedPlayers) do if p and isElement (p) then local ppos = {getElementPosition(p)} if getDistanceBetweenPoints3D (lpos[1], lpos[2], lpos[3], ppos[1], ppos[2], ppos[3]) <= 20 then local x, y = getScreenFromWorldPosition (ppos[1], ppos[2], ppos[3]+1.2) if x and y then dxDrawText ("Staff Member", x+1, y+1, x, y, tocolor (0, 0, 0), 1, "pricedown", "center") dxDrawText ("Staff Member", x, y, x, y, tocolor (52, 0, 66), 1, "pricedown", "center") end end end end end end addEventHandler ("onClientRender", root, renderStaffTag) now it doesn't draw anything .
  11. hello i have created a simple staff tag but i am using dxdrawtext to make it but it's bugged .it includes every time to have this tag when i am in the criminal team it draws the text. function renderStaffTag() local streamedPlayers = getElementsByType ("player", root, true) if getPlayerTeam(p) or getPlayerTeam(p) ~= getTeamFromName("Staff") then if streamedPlayers and #streamedPlayers ~= 0 then local lpos = {getElementPosition(localPlayer)} for _,p in ipairs (streamedPlayers) do if p and isElement (p) then local ppos = {getElementPosition(p)} if getDistanceBetweenPoints3D (lpos[1], lpos[2], lpos[3], ppos[1], ppos[2], ppos[3]) <= 20 then local x, y = getScreenFromWorldPosition (ppos[1], ppos[2], ppos[3]+1.2) if x and y then dxDrawText ("Staff Member", x+1, y+1, x, y, tocolor (0, 0, 0), 1, "pricedown", "center") dxDrawText ("Staff Member", x, y, x, y, tocolor (52, 0, 66), 1, "pricedown", "center") end end end end end end end addEventHandler ("onClientRender", root, renderStaffTag)
  12. i am going to script it so give me time
  13. actually you didn't get the point i just want to export the player's play time from a script called for ex :"playtime" and if it's increased 1 more hour give him 10000$ to notice the part of the players AFK i got an ANTI AFK system that if the player didn't move for 5 minutes he will be auto kicked from the server.
  14. hello i want to know what kind of functions in a script which depends on the play time . should i use "export" from the play time script ? the point of my code is to give the player when gains 1 more hour in his play time . thank you sorry about that part i meant to give the player money when he gains 1 more hour in his play time. thank you
  15. hello every one ,i want to replace some files in mta sa with a loader script for example i wanna replace (effects.fxp and effectsPC.txd particle.txd and vehicle.txd) those are GTA SA folders and i want to replace them in mta sa what should i do? if you got a solution please send the full code.
  16. no ,i want when i press the key the button get pressed alone :3
  17. worked i got 1 last question ,how can i bind a key to a button :3 sorry i ask a lot any ways ,it;'s just to gain my own knowledge about scripting
  18. nope ,i think you didn't send me the client side ,or it's the same also it sends me in the debugscript output these |1| Client (Max) tiggered server event superman:start but event not added to server side |2 |Client (Max) tiggered server event superman:stop but event not added to server side
  19. i don't know i swear to god i am in the criminal team but i could fly
  20. i still can fly with out being in the staff team
  21. where to add this please add it to the full script
  22. 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 = 3.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 + 3 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 -- function Superman.onJump(key, keyState) local self = Superman local task = getPlayerSimplestTask(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() 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 -- function Superman.processControls() local self = Superman 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 isPedInWater(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 isPedInWater(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, } here is the rest :3
  23. this is the script since i have downloaded it ,also it's too hard to understand for me
×
×
  • Create New...