Jump to content

xeon17

Members
  • Posts

    1,903
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by xeon17

  1. xeon17

    Question

    Is enough i'll have cool admin panel hahah '-' thank you Castilo , going to change it
  2. xeon17

    Question

    How can i change the GUI there '-'
  3. xeon17

    Question

    I downloaded the last admin panel and look how it look I mean the Admin Panel by ll_Toady but in better design.
  4. xeon17

    Question

    Is there any admin panel who look like this but on english langauge ? i have seen pictures of this admin panel on forum too. https://community.multitheftauto.com/ind ... ls&id=8552 Thanks.
  5. xeon17

    Bug

    [2014-02-02 16:05:12] SCRIPT ERROR: save_sistem\a_save.lua:98: unexpected symbol near '<' [2014-02-02 16:05:12] ERROR: Loading script failed: save_sistem\a_save.lua:98: unexpected symbol near '<'
  6. xeon17

    Bug

    function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin) if not (isGuestAccount (getPlayerAccount (source))) then local accountData = getAccountData (theCurrentAccount, "funmodev2-money") if (accountData) then local playerMoney = getAccountData (theCurrentAccount, "funmodev2-money") local playerSkin = getAccountData (theCurrentAccount, "funmodev2-skin") local playerHealth = getAccountData (theCurrentAccount, "funmodev2-health") local playerArmor = getAccountData (theCurrentAccount, "funmodev2-armor") local playerX = getAccountData (theCurrentAccount, "funmodev2-x") local playerY = getAccountData (theCurrentAccount, "funmodev2-y") local playerZ = getAccountData (theCurrentAccount, "funmodev2-z") local playerInt = getAccountData (theCurrentAccount, "funmodev2-int") local playerDim = getAccountData (theCurrentAccount, "funmodev2-dim") local playerWanted = getAccountData (theCurrentAccount, "funmodev2-wantedlevel") local playerTeam = getAccountData (theCurrentAccount, "funmodev2-Team") local playerWeaponID0 = getAccountData (theCurrentAccount, "funmodev2-weaponID0") local playerWeaponID1 = getAccountData (theCurrentAccount, "funmodev2-weaponID1") local playerWeaponID2 = getAccountData (theCurrentAccount, "funmodev2-weaponID2") local playerWeaponID3 = getAccountData (theCurrentAccount, "funmodev2-weaponID3") local playerWeaponID4 = getAccountData (theCurrentAccount, "funmodev2-weaponID4") local playerWeaponID5 = getAccountData (theCurrentAccount, "funmodev2-weaponID5") local playerWeaponID6 = getAccountData (theCurrentAccount, "funmodev2-weaponID6") local playerWeaponID7 = getAccountData (theCurrentAccount, "funmodev2-weaponID7") local playerWeaponID8 = getAccountData (theCurrentAccount, "funmodev2-weaponID8") local playerWeaponID9 = getAccountData (theCurrentAccount, "funmodev2-weaponID9") local playerWeaponID10 = getAccountData (theCurrentAccount, "funmodev2-weaponID10") local playerWeaponID11 = getAccountData (theCurrentAccount, "funmodev2-weaponID11") local playerWeaponID12 = getAccountData (theCurrentAccount, "funmodev2-weaponID12") local playerWeaponAmmo0 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo0") local playerWeaponAmmo1 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo1") local playerWeaponAmmo2 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo2") local playerWeaponAmmo3 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo3") local playerWeaponAmmo4 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo4") local playerWeaponAmmo5 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo5") local playerWeaponAmmo6 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo6") local playerWeaponAmmo7 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo7") local playerWeaponAmmo8 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo8") local playerWeaponAmmo9 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo9") local playerWeaponAmmo10 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo10") local playerWeaponAmmo11 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo11") local playerWeaponAmmo12 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo12") spawnPlayer (source, playerX, playerY, playerZ +1, 0, playerSkin, playerInt, playerDim) setPlayerMoney (source, playerMoney) setTimer (setElementHealth, 50, 1, source, playerHealth) setTimer (setPedArmor, 50, 1, source, playerArmor) setTimer (setPlayerWantedLevel, 50, 1, source, playerWanted) giveWeapon(source, playerWeaponID0, playerWeaponAmmo0, true) giveWeapon(source, playerWeaponID1, playerWeaponAmmo1, false) giveWeapon(source, playerWeaponID2, playerWeaponAmmo2, false) giveWeapon(source, playerWeaponID3, playerWeaponAmmo3, false) giveWeapon(source, playerWeaponID4, playerWeaponAmmo4, false) giveWeapon(source, playerWeaponID5, playerWeaponAmmo5, false) giveWeapon(source, playerWeaponID6, playerWeaponAmmo6, false) giveWeapon(source, playerWeaponID7, playerWeaponAmmo7, false) giveWeapon(source, playerWeaponID8, playerWeaponAmmo8, false) giveWeapon(source, playerWeaponID9, playerWeaponAmmo9, false) giveWeapon(source, playerWeaponID10, playerWeaponAmmo10, false) giveWeapon(source, playerWeaponID11, playerWeaponAmmo11, false) giveWeapon(source, playerWeaponID12, playerWeaponAmmo12, false) setCameraTarget (source, source) fadeCamera(source, true, 2.0) end end end addEventHandler ("onPlayerLogin", getRootElement(), playerLogin) function onLogout () kickPlayer (source, nil, "Logging out is disallowed.") end addEventHandler ("onPlayerLogout", getRootElement(), onLogout) function onQuit (quitType, reason, responsibleElement) if not (isGuestAccount (getPlayerAccount (source))) then account = getPlayerAccount (source) if (account) then local x,y,z = getElementPosition (source) setAccountData (account, "funmodev2-money", tostring (getPlayerMoney (source))) setAccountData (account, "funmodev2-skin", tostring (getPedSkin (source))) setAccountData (account, "funmodev2-health", tostring (getElementHealth (source))) setAccountData (account, "funmodev2-armor", tostring (getPedArmor (source))) setAccountData (account, "funmodev2-R", r) setAccountData (account, "funmodev2-G", g) setAccountData (account, "funmodev2-B", b) setAccountData (account, "funmodev2-x", x) setAccountData (account, "funmodev2-y", y) setAccountData (account, "funmodev2-z", z) setAccountData (account, "funmodev2-int", getElementInterior (source)) setAccountData (account, "funmodev2-dim", getElementDimension (source)) setAccountData (account, "funmodev2-wantedlevel", getPlayerWantedLevel (source)) setAccountData (account, "funmodev2-weaponID0", getPedWeapon (source, 0)) setAccountData (account, "funmodev2-weaponID1", getPedWeapon (source, 1)) setAccountData (account, "funmodev2-weaponID2", getPedWeapon (source, 2)) setAccountData (account, "funmodev2-weaponID3", getPedWeapon (source, 3)) setAccountData (account, "funmodev2-weaponID4", getPedWeapon (source, 4)) setAccountData (account, "funmodev2-weaponID5", getPedWeapon (source, 5)) setAccountData (account, "funmodev2-weaponID6", getPedWeapon (source, 6)) setAccountData (account, "funmodev2-weaponID7", getPedWeapon (source, 7)) setAccountData (account, "funmodev2-weaponID8", getPedWeapon (source, -- s8) -->) setAccountData (account, "funmodev2-weaponID9", getPedWeapon (source, 9)) setAccountData (account, "funmodev2-weaponID10", getPedWeapon (source, 10)) setAccountData (account, "funmodev2-weaponID11", getPedWeapon (source, 11)) setAccountData (account, "funmodev2-weaponID12", getPedWeapon (source, 12)) setAccountData (account, "funmodev2-weaponAmmo0", getPedTotalAmmo (source, 0)) setAccountData (account, "funmodev2-weaponAmmo1", getPedTotalAmmo (source, 1)) setAccountData (account, "funmodev2-weaponAmmo2", getPedTotalAmmo (source, 2)) setAccountData (account, "funmodev2-weaponAmmo3", getPedTotalAmmo (source, 3)) setAccountData (account, "funmodev2-weaponAmmo4", getPedTotalAmmo (source, 4)) setAccountData (account, "funmodev2-weaponAmmo5", getPedTotalAmmo (source, 5)) setAccountData (account, "funmodev2-weaponAmmo6", getPedTotalAmmo (source, 6)) setAccountData (account, "funmodev2-weaponAmmo7", getPedTotalAmmo (source, 7)) setAccountData (account, "funmodev2-weaponAmmo8", getPedTotalAmmo (source, -- s8) -->) setAccountData (account, "funmodev2-weaponAmmo9", getPedTotalAmmo (source, 9)) setAccountData (account, "funmodev2-weaponAmmo10", getPedTotalAmmo (source, 10)) setAccountData (account, "funmodev2-weaponAmmo11", getPedTotalAmmo (source, 11)) setAccountData (account, "funmodev2-weaponAmmo12", getPedTotalAmmo (source, 12)) end end end addEventHandler ("onPlayerQuit", getRootElement(), onQuit) --- function setTeam() local account = getPlayerAccount(source) local team = getAccountData (account, "team") if team and getTeamFromName(team) then setPlayerTeam(source, getTeamFromName(team)) end end addEventHandler("onPlayerLogin",getRootElement(),setTeam) function saveTeam() local team = getPlayerTeam(source) local account = getPlayerAccount(source) if (team) and not isGuestAccount(account) then setAccountData(account, "team", getTeamName(team)) end end addEventHandler("onPlayerQuit",getRootElement(),saveTeam) function convertWeaponsToJSON(player) local weaponSlots = 12 local weaponsTable = {} for slot=1, weaponSlots do local weapon = getPedWeapon( source, slot ) local ammo = getPedTotalAmmo( source, slot ) if (weapon > 0 and ammo > 0) then weaponsTable[weapon] = ammo end end return toJSON(weaponsTable) end addEventHandler("onPlayerWasted", root, function() local weapons = convertWeaponsToJSON(source) setElementData(source,"tempWeapons",weapons) takeAllWeapons ( source ) end ) function giveWeaponsFromJSON(player, weapons) if (weapons and weapons ~= "") then for weapon, ammo in pairs(fromJSON(weapons)) do if (weapon and ammo) then giveWeapon(player, tonumber(weapon), tonumber(ammo)) end end end end addEventHandler("onPlayerSpawn", root, function () local weapons = getElementData(source,"tempWeapons") if (weapons) then giveWeaponsFromJSON(source, weapons) removeElementData ( source, "tempWeapons" ) end end ) function saveWeaponStats(player) if (not player or not isElement(player)) then return end local account = getPlayerAccount(player) if (account and not isGuestAccount(account)) then local stats = "" for stat=69, 81 do local value = getPedStat(player, stat) stats = stats ..",".. stat ..";".. value end setAccountData(account, "weaponStats", stats) end end addEventHandler("onPlayerQuit",root,function () saveWeaponStats(source) end) function loadWeaponStats(player) if (not player or not isElement(player)) then return end local account = getPlayerAccount(player) if (account and not isGuestAccount(account)) then local statsData = getAccountData(account,"weaponStats") local stats = split(statsData, ",") for k, v in ipairs(stats) do local stat = split(v, ";") setPedStat(player, tonumber(stat[1]), tonumber(stat[2])) end end end addEventHandler("onPlayerLogin",root,function () loadWeaponStats(source) end) function something() if (not getPlayerTeam(source)) then return end local r, g, b = getTeamColor(getPlayerTeam(source)) setPlayerNametagColor(source, r, g, b) end addEventHandler("onPlayerLogin", root, something) addEventHandler("onPlayerJoin", root, something) [2014-02-02 15:47:54] SCRIPT ERROR: save_sistem\a_save.lua:98: unexpected symbol near '<' [2014-02-02 15:47:54] ERROR: Loading script failed: save_sistem\a_save.lua:98: unexpected symbol near '<'
  7. xeon17

    Save system

    https://community.multitheftauto.com/in ... ls&id=3940 https://community.multitheftauto.com/in ... ils&id=732 https://community.multitheftauto.com/in ... ls&id=6998 choose one you like.
  8. Why don't you stop posting the same thing that another user already said? He wanna get some big rank on forum
  9. xeon17

    Help

    The scripts work without problems , but when the scripts are on at 1 time then they don't work. please help addCommandHandler("gang", function(player, command, subcommand, ...) local args = {...} local team = getPlayerTeam(player) if(subcommand == "tag") then if(not isElement(team)) then return outputChatBox("#F4A460[GANG]#F08080 Você não possui uma gang...", player, 0, 0, 0, true) end local tag = args[1] if(tag) then setElementData(team, "tag", tag) return outputChatBox("#F4A460[GANG]#F08080 Tag setada com sucesso = " .. tag , player, 0, 0, 0, true) else setElementData(team, "tag", nil) return outputChatBox("#F4A460[GANG]#F08080 Tag removida.", player, 0, 0, 0, true) end end end) addEventHandler("onPlayerChat", root, function(message, messageType) local team = getPlayerTeam(source) if team then local tag = getElementData(team, "tag") if tag then if messageType == 0 then cancelEvent() local r, g, b = getPlayerNametagColor(source) outputChatBox(string.format("[%s]%s: #FFFFFF %s", tag, getPlayerName(source), message), root, r, g, b, true) elseif messageType == 2 then cancelEvent() local r, g, b = getPlayerNametagColor(source) for _, member in ipairs( getPlayersInTeam(team) ) do outputChatBox(string.format("[%s]%s: #FFFFFF %s", tag, getPlayerName(source), message), member, r, g, b, true) end end end end end) Script 2 : local aTable = { -- ['Word'] = { 'Out put of it' }, ['bitch'] = { 'I Love You' }, } addEventHandler('onPlayerChat',root, function ( Massege ) local r,g,b = getPlayerNametagColor ( source ) or 255,255,255 for v in pairs ( aTable ) do if string.find ( Massege,v ) then cancelEvent ( ) outputChatBox ( ' '..getPlayerName ( source )..' : '..aTable [ v ] [ 1 ]..' ',root,r,g,b ) end end end ) Script 3 function blockChatMessage() cancelEvent() end addEventHandler( "onPlayerChat", getRootElement(), blockChatMessage) function sayMessageNear(message, messageType) local x,y,z = getElementPosition(source) if x ~= 0 and y ~= 0 and z ~= 0 then if messageType == 0 then r,g,b = getTeamColor(getPlayerTeam(source)) thePlayerName = getPlayerName(source) thePlayerID = getElementData(source,"id") outputChatBox(thePlayerName.."["..tostring(thePlayerID).."]: #ffffff"..message, getRootElement(), r,g,b, true) end end end addEventHandler("onPlayerChat", getRootElement(), sayMessageNear) function sayMessageTeam(message, messageType) if messageType == 2 then r,g,b = getTeamColor(getPlayerTeam(source)) thePlayerName = getPlayerName(source) for i,v in ipairs(getElementsByType("player")) do if getPlayerTeam(source) == getPlayerTeam(v) then thePlayerID = getElementData(source,"id") outputChatBox("(TEAM) "..thePlayerName.."["..tostring(thePlayerID).."]: "..message, v, r,g,b, true) end end end end addEventHandler("onPlayerChat", getRootElement(), sayMessageTeam)
  10. I copyed it bad from my computer , but fixed after 10 seconds..
  11. "Author" version="1.0" type="script" />
  12. "Author" version="1.0" type="script" />
  13. xeon17

    Race times

    Well, are you asking about the kill messages, its easy. Its already added to the server, just type /start killmessages
  14. xeon17

    '-'

    Thanks for your help guys , i understand it now going to crate a perfect vehcile script
  15. xeon17

    '-'

    createVehicle ( 411, x, y, z + 10 ) whats +10 ?
  16. xeon17

    '-'

    Can someone give me a extample for CrateVehcile please.. and a extample to crate a spawn table
  17. xeon17

    Functions

    Thanks Castilo & CiBeR for your help script working perfect now without bugs
  18. xeon17

    Functions

    I got a bug now [2014-01-28 20:37:32] WARNING: X-Scores\server.lua:15: Bad argument @ 'getElementData' [Expected element at argument 1, got boolean] [2014-01-28 20:37:32] ERROR: X-Scores\server.lua:15: attempt to perform arithmetic on a boolean value
  19. xeon17

    Functions

    All is working nice but in the scoreboard frist is Deaths after Ratio and Kills. should be Kills,Deaths,Ratio here the full script : addEventHandler ( "onPlayerWasted", root, function( totalAmmo, killer, killerWeapon, bodypart, stealth ) if killer then local account = getPlayerAccount ( killer ) if killer ~= source then setAccountData( account,"killsdeathsratio.Kills",tonumber( getAccountData( account,"killdeathsratio.Kills" ) or 0 ) +1 ) setElementData( killer, "Kills", tonumber( getAccountData( account,"killsdeathsratio.Kills" ) ) ) setElementData( killer, "Ratio", tonumber(getElementData( killer, "Kills" )/getElementData( source, "Deaths") ) ) end else local accountSource = getPlayerAccount ( source ) setAccountData( accountSource,"killsdeathsratio.Deaths",tonumber( getAccountData(accountSource,"killsdeathsratio.Deaths") or 0 ) +1 ) setElementData( source, "Deaths", tonumber( getAccountData( accountSource,"killsdeathsratio.Deaths" ) ) ) setElementData( source, "Ratio", getElementData( killer, "Kills" )/getElementData( source, "Deaths") ) end end ) addEventHandler( "onPlayerLogin",root, function( thePreviousAccount, theCurrentAccount, autoLogin ) local account = getPlayerAccount ( source ) if not getAccountData( account,"killsdeathsratio.Kills" ) and not getAccountData( account,"killsdeathsratio.Deaths" ) then setAccountData( account,"killsdeathsratio.Kills",0 ) setAccountData( account,"killsdeathsratio.Deaths",0 ) end setElementData( source,"Deaths",tonumber( getAccountData( account,"killsdeathsratio.Deaths" ) or 0 ) ) setElementData( source,"Kills",tonumber( getAccountData( account,"killsdeathsratio.Kills" ) or 0 ) ) setElementData( source, "Ratio", getElementData( source, "Kills" )/getElementData( source, "Deaths") ) end ) addEventHandler( "onResourceStart",resourceRoot, function( ) outputDebugString( "add Total Kills to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "Kills",root,5, 0.070 ) ) ) outputDebugString( "add Total Kills to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "Deaths",root,5, 0.070 ) ) ) outputDebugString( "add Ratio to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "Ratio",root,5, 0.070 ) ) ) end ) an picture : Picture with my Favorite scoreboard whitch i use
  20. xeon17

    Functions

    Will this work ? addEventHandler ( "onPlayerWasted", root, function( totalAmmo, killer, killerWeapon, bodypart, stealth ) if killer then local account = getPlayerAccount ( killer ) if killer ~= source then setAccountData( account,"killsdeathsratio.Kills",tonumber( getAccountData( account,"killdeathsratio.Kills" ) or 0 ) +1 ) setElementData( killer, "Kills", tonumber( getAccountData( account,"killsdeathsratio.Kills" ) ) ) setElementData( killer, "Ratio, tonumber(getElementData( killer, "Kills" )/getElementData( source, "Deaths") ) ) end else local accountSource = getPlayerAccount ( source ) setAccountData( accountSource,"killsdeathsratio.Deaths",tonumber( getAccountData(accountSource,"killsdeathsratio.Deaths") or 0 ) +1 ) setElementData( source, "Deaths, tonumber( getAccountData( accountSource,"killsdeathsratio.Deaths" ) ) ) setElementData( source, "Ratio", getElementData( killer, "Kills )/getElementData( source, "Deaths") ) end end ) addEventHandler( "onPlayerLogin",root, function( thePreviousAccount, theCurrentAccount, autoLogin ) local account = getPlayerAccount ( source ) if not getAccountData( account,"killsdeathsratio.Kills" ) and not getAccountData( account,"killsdeathsratio.Deaths" ) then setAccountData( account,"killsdeathsratio.Kills",0 ) setAccountData( account,"killsdeathsratio.Deaths",0 ) end setElementData( source,"Deaths",tonumber( getAccountData( account,"killsdeathsratio.Deaths" ) or 0 ) ) setElementData( source,"Kills,tonumber( getAccountData( account,"killsdeathsratio.Kills" ) or 0 ) ) setElementData( source, "Ratio", getElementData( source, "Kills" )/getElementData( source, "Deaths) ) end )
  21. xeon17

    Functions

    What functions i need to use to save players kills,deaths,ratio when player quit in his account , and when he enter he have his kills,dealth,ratio .
  22. Replace your client.lua with -- 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() -- -- Check for admin privileges -- local function canFly() return (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Admin"))) 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
×
×
  • Create New...