Jump to content

codeluaeveryday

Members
  • Posts

    575
  • Joined

Everything posted by codeluaeveryday

  1. He obviously wants freeroam stuff: Set gravity to 0.0999, Set speed to 3, Get a jetpack and you will go really fast, gravity makes it speed faster than cars and planes. also you can create a macro to spawn the /cv create vehicle command, its awesome, you pretty much pwn everything with that.
  2. No need to wait for a dev, the other guy is correct, mta uses the HDD serial, every HDD has a unique serial, this is what makes it awesome to use in MTA, I wonder if MTA will use IPV6 to replace it.
  3. Untested (Sure it will work though) Replace the 'race/textlib.lua' with: dxText = {} dxText_mt = { __index = dxText } local idAssign,idPrefix = 0,"c" local g_screenX,g_screenY = guiGetScreenSize() local visibleText = {} ------ defaults = { fX = 0.5, fY = 0.5, bRelativePosition = true, strText = "", bVerticalAlign = "center", bHorizontalAlign = "center", tColor = {255,255,255,255}, fScale = 1, strFont = "default", strType = "normal", tAttributes = {}, bPostGUI = false, bClip = false, bWordWrap = true, bVisible = true, tBoundingBox = false, --If a bounding box is not set, it will not be used. bRelativeBoundingBox = true, } local validFonts = { default = true, ["default-bold"] = true, clear = true, arial = true, pricedown = true, bankgothic = true, diploma = true, beckett = true, } local validTypes = { normal = true, shadow = true, border = true, stroke = true, --Clone of border } local validAlignTypes = { center = true, left = true, right = true, } function dxText:create( text, x, y, relative, strFont, fScale, horzA ) assert(not self.fX, "attempt to call method 'create' (a nil value)") if ( type(text) ~= "string" ) or ( not tonumber(x) ) or ( not tonumber(y) ) then outputDebugString ( "dxText:create - Bad argument", 0, 112, 112, 112 ) return false end local new = {} setmetatable( new, dxText_mt ) --Add default settings for i,v in pairs(defaults) do new[i] = v end idAssign = idAssign + 1 new.id = idPrefix..idAssign new.strText = text or new.strText new.fX = x or new.fX new.fY = y or new.fY if type(relative) == "boolean" then new.bRelativePosition = relative end new:scale( fScale or new.fScale ) new:font( strFont or new.strFont ) new:align( horzA or new.bHorizontalAlign ) visibleText[new] = true return new end function dxText:text(text) if type(text) ~= "string" then return self.strText end self.strText = text return true end function dxText:position(x,y,relative) if not tonumber(x) then return self.fX, self.fY end self.fX = x self.fY = y if type(relative) == "boolean" then self.bRelativePosition = relative else self.bRelativePosition = true end return true end function dxText:color(r,g,b,a) if not tonumber(r) then return unpack(self.tColor) end g = g or self.tColor[2] b = b or self.tColor[3] a = a or self.tColor[4] self.tColor = { r,g,b,a } return true end function dxText:scale(scale) if not tonumber(scale) then return self.fScale end self.fScale = scale return true end function dxText:visible(bool) if type(bool) ~= "boolean" then return self.bVisible end if self.bVisible == bool then return end self.bVisible = bool if bool then visibleText[self] = true else visibleText[self] = nil end return true end function dxText:destroy() self.bDestroyed = true setmetatable( self, self ) return true end function dxText:font(font) if not validFonts[font] then return self.strFont end self.strFont = font return true end function dxText:postGUI(bool) if type(bool) ~= "boolean" then return self.bPostGUI end self.bPostGUI = bool return true end function dxText:clip(bool) if type(bool) ~= "boolean" then return self.bClip end self.bClip = bool return true end function dxText:wordWrap(bool) if type(bool) ~= "boolean" then return self.bWordWrap end self.bWordWrap = bool return true end function dxText:type(type,...) if not validTypes[type] then return self.strType, unpack(self.tAttributes) end self.strType = type self.tAttributes = {...} return true end function dxText:align(horzA, vertA) if not validAlignTypes[horzA] then return self.bHorizontalAlign, self.bVerticalAlign end vertA = vertA or self.bVerticalAlign self.bHorizontalAlign, self.bVerticalAlign = horzA, vertA return true end function dxText:boundingBox(left,top,right,bottom,relative) if left == nil then if self.tBoundingBox then return unpack(boundingBox) else return false end elseif tonumber(left) and tonumber(right) and tonumber(top) and tonumber(bottom) then self.tBoundingBox = {left,top,right,bottom} if type(relative) == "boolean" then self.bRelativeBoundingBox = relative else self.bRelativeBoundingBox = true end else self.tBoundingBox = false end return true end addEventHandler ( "onClientRender", getRootElement(), function() for self,_ in pairs(visibleText) do while true do if self.bDestroyed then visibleText[self] = nil break end if self.tColor[4] < 1 then break end local l,t,r,b --If we arent using a bounding box if not self.tBoundingBox then --Decide if we use relative or absolute local p_screenX,p_screenY = 1,1 if self.bRelativePosition then p_screenX,p_screenY = g_screenX,g_screenY end local fX,fY = (self.fX)*p_screenX,(self.fY)*p_screenY if self.bHorizontalAlign == "left" then l = fX r = fX + g_screenX elseif self.bHorizontalAlign == "right" then l = fX - g_screenX r = fX else l = fX - g_screenX r = fX + g_screenX end if self.bVerticalAlign == "top" then t = fY b = fY + g_screenY elseif self.bVerticalAlign == "bottom" then t = fY - g_screenY b = fY else t = fY - g_screenY b = fY + g_screenY end elseif type(self.tBoundingBox) == "table" then local b_screenX,b_screenY = 1,1 if self.bRelativeBoundingBox then b_screenX,b_screenY = g_screenX,g_screenY end l,t,r,b = self.tBoundingBox[1],self.tBoundingBox[2],self.tBoundingBox[3],self.tBoundingBox[4] l = l*b_screenX t = t*b_screenY r = r*b_screenX b = b*b_screenY end local type,att1,att2,att3,att4,att5 = self:type() if type == "border" or type == "stroke" then att2 = att2 or 0 att3 = att3 or 0 att4 = att4 or 0 att5 = att5 or self.tColor[4] outlinesize = att1 or 2 if outlinesize > 0 then for offsetX=-outlinesize,outlinesize,outlinesize do for offsetY=-outlinesize,outlinesize,outlinesize do if not (offsetX == 0 and offsetY == 0) then dxDrawText(self.strText, l + offsetX, t + offsetY, r + offsetX, b + offsetY, tocolor(att2, att3, att4, att5), self.fScale, self.strFont, self.bHorizontalAlign, self.bVerticalAlign, self.bClip, self.bWordWrap, self.bPostGUI, true ) end end
  4. Untested: replace race_client.lua with: g_Root = getRootElement() g_ResRoot = getResourceRootElement(getThisResource()) g_Me = getLocalPlayer() g_ArmedVehicleIDs = table.create({ 425, 447, 520, 430, 464, 432 }, true) g_WaterCraftIDs = table.create({ 539, 460, 417, 447, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454 }, true) g_ModelForPickupType = { nitro = 2221, repair = 2222, vehiclechange = 2223 } g_HunterID = 425 g_Checkpoints = {} g_Pickups = {} g_VisiblePickups = {} g_Objects = {} addEventHandler('onClientResourceStart', g_ResRoot, function() g_Players = getElementsByType('player') fadeCamera(false,0.0) -- create GUI local screenWidth, screenHeight = guiGetScreenSize() g_dxGUI = { } g_GUI = { speedbar = FancyProgress.create(0, 1.5, 'img/progress_speed_bg.png', -65, 90, 123, 30, 'img/progress_speed.png', 8, 8, 108, 15), } guiSetFont(g_GUI.timeleft, 'default-bold-small') guiLabelSetHorizontalAlign(g_GUI.timeleft, 'center') g_GUI.speedbar:setProgress(0) RankingBoard.precreateLabels(10) -- set update handlers g_PickupStartTick = getTickCount() g_WaterCheckTimer = setTimer(checkWater, 1000, 0) -- load pickup models and textures for name,id in pairs(g_ModelForPickupType) do engineImportTXD(engineLoadTXD('model/' .. name .. '.txd'), id) engineReplaceModel(engineLoadDFF('model/' .. name .. '.dff', id), id) -- Double draw distance for pickups engineSetModelLODDistance( id, 60 ) end if isVersion101Compatible() then -- Dont clip vehicles (1.0.1 function) setCameraClip ( true, false ) end -- Init presentation screens TravelScreen.init() TitleScreen.init() -- Show title screen now TitleScreen.show() setPedCanBeKnockedOffBike(g_Me, false) end ) ------------------------------------------------------- -- Title screen - Shown when player first joins the game ------------------------------------------------------- TitleScreen = {} TitleScreen.startTime = 0 function TitleScreen.init() local screenWidth, screenHeight = guiGetScreenSize() local adjustY = math.clamp( -30, -15 + (-30- -15) * (screenHeight - 480)/(900 - 480), -15 ); g_GUI['titleImage'] = guiCreateStaticImage(screenWidth/2-256, screenHeight/2-256+adjustY, 512, 512, 'img/title.png', false) g_dxGUI['titleText1'] = dxText:create('', 30, screenHeight-67, false, 'bankgothic', 0.70, 'left' ) g_dxGUI['titleText2'] = dxText:create('', 120, screenHeight-67, false, 'bankgothic', 0.70, 'left' ) g_dxGUI['titleText1']:text( 'KEYS: \n' .. 'F4 \n' .. 'F5 \n' .. 'ENTER' ) g_dxGUI['titleText2']:text( '\n' .. '- TRAFFIC ARROWS \n' .. '- TOP TIMES \n' .. '- RETRY' ) hideGUIComponents('titleImage','titleText1','titleText2') end function TitleScreen.show() showGUIComponents('titleImage','titleText1','titleText2') guiMoveToBack(g_GUI['titleImage']) TitleScreen.startTime = getTickCount() TitleScreen.bringForward = 0 addEventHandler('onClientRender', g_Root, TitleScreen.update) end function TitleScreen.update() local secondsLeft = TitleScreen.getTicksRemaining() / 1000 local alpha = math.min(1,math.max( secondsLeft ,0)) guiSetAlpha(g_GUI['titleImage'], alpha) g_dxGUI['titleText1']:color(220,220,220,255*alpha) g_dxGUI['titleText2']:color(220,220,220,255*alpha) if alpha == 0 then hideGUIComponents('titleImage','titleText1','titleText2') removeEventHandler('onClientRender', g_Root, TitleScreen.update) end end function TitleScreen.getTicksRemaining() return math.max( 0, TitleScreen.startTime - TitleScreen.bringForward + 10000 - getTickCount() ) end -- Start the fadeout as soon as possible function TitleScreen.bringForwardFadeout(maxSkip) local ticksLeft = TitleScreen.getTicksRemaining() local bringForward = ticksLeft - 1000 outputDebug( 'MISC', 'bringForward ' .. bringForward ) if bringForward > 0 then TitleScreen.bringForward = math.min(TitleScreen.bringForward + bringForward,maxSkip) outputDebug( 'MISC', 'TitleScreen.bringForward ' .. TitleScreen.bringForward ) end end ------------------------------------------------------- ------------------------------------------------------- -- Travel screen - Message for client feedback when loading maps ------------------------------------------------------- TravelScreen = {} TravelScreen.startTime = 0 function TravelScreen.init() local screenWidth, screenHeight = guiGetScreenSize() g_GUI['travelImage'] = guiCreateStaticImage(screenWidth/2-256, screenHeight/2-90, 512, 256, 'img/travelling.png', false, nil) g_dxGUI['travelText1'] = dxText:create('Travelling to', screenWidth/2, screenHeight/2-130, false, 'bankgothic', 0.60, 'center' ) g_dxGUI['travelText2'] = dxText:create('', screenWidth/2, screenHeight/2-100, false, 'bankgothic', 0.70, 'center' ) g_dxGUI['travelText3'] = dxText:create('', screenWidth/2, screenHeight/2-70, false, 'bankgothic', 0.70, 'center' ) g_dxGUI['travelText1']:color(240,240,240) hideGUIComponents('travelImage', 'travelText1', 'travelText2', 'travelText3') end function TravelScreen.show( mapName, authorName ) TravelScreen.startTime = getTickCount() g_dxGUI['travelText2']:text(mapName) g_dxGUI['travelText3']:text(authorName and "Author: " .. authorName or "") showGUIComponents('travelImage', 'travelText1', 'travelText2', 'travelText3') guiMoveToBack(g_GUI['travelImage']) end function TravelScreen.hide() hideGUIComponents('travelImage', 'travelText1', 'travelText2', 'travelText3') end function TravelScreen.getTicksRemaining() return math.max( 0, TravelScreen.startTime + 3000 - getTickCount() ) end ------------------------------------------------------- -- Called from server function notifyLoadingMap( mapName, authorName ) fadeCamera( false, 0.0, 0,0,0 ) -- fadeout, instant, black TravelScreen.show( mapName, authorName ) end -- Called from server function initRace(vehicle, checkpoints, objects, pickups, mapoptions, ranked, duration, gameoptions, mapinfo, playerInfo) outputDebug( 'MISC', 'initRace start' ) unloadAll() g_Players = getElementsByType('player') g_MapOptions = mapoptions g_GameOptions = gameoptions g_MapInfo = mapinfo g_PlayerInfo = playerInfo triggerEvent('onClientMapStarting', g_Me, mapinfo ) g_dxGUI.mapdisplay:text("Map: "..g_MapInfo.name) fadeCamera(true) showHUD(false) g_Vehicle = vehicle setVehicleDamageProof(g_Vehicle, true) OverrideClient.updateVars(g_Vehicle) --local x, y, z = getElementPosition(g_Vehicle) setCameraBehindVehicle(vehicle) --alignVehicleToGround(vehicle) updateVehicleWeapons() setCloudsEnabled(g_GameOptions.cloudsenable) setBlurLevel(g_GameOptions.blurlevel) g_dxGUI.mapdisplay:visible(g_GameOptions.showmapname) if engineSetAsynchronousLoading then engineSetAsynchronousLoading( g_GameOptions.asyncloading ) end -- checkpoints g_Checkpoints = checkpoints -- pickups local object local pos local colshape for i,pickup in pairs(pickups) do pos = pickup.position object = createObject(g_ModelForPickupType[pickup.type], pos[1], pos[2], pos[3]) setElementCollisionsEnabled(object, false) colshape = createColSphere(pos[1], pos[2], pos[3], 3.5) g_Pickups[colshape] = { object = object } for k,v in pairs(pickup) do g_Pickups[colshape][k] = v end g_Pickups[colshape].load = true if g_Pickups[colshape].type == 'vehiclechange' then g_Pickups[colshape].label = dxText:create(getVehicleNameFromModel(g_Pickups[colshape].vehicle), 0.5, 0.5) g_Pickups[colshape].label:color(255, 255, 255, 0) g_Pickups[colshape].label:type("shadow",2) end end -- objects g_Objects = {} local pos, rot for i,object in ipairs(objects) do pos = object.position rot = object.rotation g_Objects[i] = createObject(object.model, pos[1], pos[2], pos[3], rot[1], rot[2], rot[3]) end if #g_Checkpoints > 0 then g_CurrentCheckpoint = 0 showNextCheckpoint() end -- GUI g_dxGUI.timepassed:text('0:00:00') showGUIComponents('healthbar', 'speedbar', 'timepassed') hideGUIComponents('timeleftbg', 'timeleft') if ranked then showGUIComponents('ranknum', 'ranksuffix') else hideGUIComponents('ranknum', 'ranksuffix') end if #g_Checkpoints > 0 then showGUIComponents('checkpoint') else hideGUIComponents('checkpoint') end g_HurryDuration = g_GameOptions.hurrytime if duration then launchRace(duration) end
  5. Hello new MTA coder, My name is Chris, and I would be happy to help you learn Lua. I am assuming you are using the 'play' gamemode/resource, with this you will need to modify the broph.map file in the 'play' resource. Scroll through that file until you find something like this: <spawnpoint id="ranch" posX="-711" posY="957" posZ="12.4" rotation="90"></spawnpoint> <spawnpoint id="pirate" posX="2005" posY="1543" posZ="13.5" rotX="270"></spawnpoint> <spawnpoint id="grove" posX="2485" posY="-1667" posZ="13.3" rotX="0"></spawnpoint> <spawnpoint id="hill" posX="-2405" posY="-598" posZ="132.6" rotX="128"></spawnpoint> Now this part is very basic, you can remove some of those spawn points, yours already might only have 1 spawnpoint, too add more just copy and paste the line down to make another. You will need to specify as unique id with each spawn point, it doesn't matter what it is, also you can set the posX, posY, posZ positions, to find these just use the freeroam resource and press F1, and you will see the positions there. I hope this has helped you, happy coding
  6. No problem Never stop coding brother
  7. codeluaeveryday

    Roads

    WTF? Are you 100% sure? Cause I'm 500% sure you have no idea what your saying, roads are not MTA:SA entities or elements, it is a GTA:SA world object, that's like using getPlayerName(getPedOccupiedVehicle(source))... seriously.
  8. function destroyclan () local clan = getElementData ( source, "clan" ) local acc = getPlayerAccount ( source ) local clansroot = xmlLoadFile ("clans.xml") if ( clansroot ) then for i,v in ipairs (xmlNodeGetChildren(clansroot)) do local clanName = xmlNodeGetAttribute (v,"name") if clanName:lower() == clan:lower() then xmlDestroyNode ( v ) xmlSaveFile ( clansroot ) xmlUnloadFile ( clansroot ) exports ["guimessages"] : outputServer ( source, "You destroy your clan!", 255, 255, 0 ) setAccountData ( acc, "Clan", false ) removeElementData ( source, "clan" ) end end end end addEvent ( "destroyclan", true ) addEventHandler ( "destroyclan", root, destroyclan )
  9. No problem, I did make the update for it.
  10. Guys, do not freaking reply if you have no idea how to pooping help him. @Robbster: fr_server.lua: has a table ('g_OptionDefaults') for blocking access to options! fr_client.lua: Amazing shit here, you can create GUI's and edit them really easily, also removing stuff. They are setup as tables, the main table variable is 'wndMain'. I'd recommend you test it out before doing too much, also in that table contains other table variables, like wndBookmarks.
  11. PM me the file, there might be a way of changing the color without decompiling it, if the color is set as a variable we can set the variable in a different file.
  12. dbConnect dbQuery Remember dbConnect returns the required element for dbQuery, when using dbConnect, add a variable to it. so: local session = dbConnect(...) and use session for the dbQuery argument 'databaseConnection'. I hope this helps you with your enquire.
  13. The reason it is deleting them all is because you are 'for' looping all the children of the xml file then using xmlDestroyNode, if you cannot figure it out, can you please post the full function handler.
  14. function removeWorldModels() removeWorldModel(968, 200, -1526.4375, 481.38281, 6.90625, 0) removeWorldModel(966, 200, -1526.39062, 481.38281, 6.17969, 0) removeWorldModel(10829, 200, -1523.2578125, 486.796875, 6.15625, 0) end addEventHandler("onResourceStart", getRootElement(), removeWorldModels) addEventHandler("onPlayerJoin", getRootElement(), removeWorldModels)
  15. last time I checked CJ Clothing cannot be replaced using shaders.
  16. codeluaeveryday

    1s

    addCommandHandler setTimer string.find tonumber setElementFrozen toggleAllControls
  17. Yeah, but MSN still works ey? Yeah I rarely use MSN. Screw MSN, I'll do AIM and Yahoo.
  18. Are you saying this because MSN merged with Skype? Well in that case I'll make a AIM Messenger. or did you think this is a PM manager, please explain what you mean. PLUS: I'd like to see you freaking make this.
  19. Most likely yeah. It should work no matter the map name.
  20. Make sure the 'admin' resource is started, this handles the /register command.
  21. Mate, stop the resource known as 'scores', I hope that this solved the problem with the kills.
  22. The reason your admin panel is not returning your country is because its out of date, I made a tutorial on updating it, I recommend you use the automatic updater, not all flags are in the admin panel, not much I can do about that. Tutorial: viewtopic.php?f=148&t=56485 Recommended you use automatic.
  23. I believe this is from my super bugged MTA:SA code, here you go buddy: addEventHandler("onPlayerWasted", root, function(totalAmmo, killer, killerWeapon, bodypart, stealth) if killer then if killer ~= source then setElementData(killer, "kills", (getElementData(killer, "kills") or 0) + 1) end end setElementData(source, "deaths", (getElementData(source, "deaths") or 0) + 1) end ) addEventHandler("onPlayerLogout", root, function(previousAcc, currentAcc) setAccountData(currentAcc, "deaths", getElementData(source, "deaths") or 0) setAccountData(currentAcc, "kills", getElementData(source, "kills") or 0) end ) addEventHandler("onPlayerQuit", root, function() currentAcc = getPlayerAccount(source) setAccountData(currentAcc, "deaths", getElementData(source, "deaths") or 0) setAccountData(currentAcc, "kills", getElementData(source, "kills") or 0) end ) addEventHandler("onPlayerLogin", root, function(previousAcc, currentAcc, _autoLogin_) setElementData(source, "deaths", getAccountData(currentAcc, "deaths") or 0) setElementData(source, "kills", getAccountData(currentAcc, "kills") or 0) end )
×
×
  • Create New...