Jump to content

GTX

Members
  • Posts

    1,273
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by GTX

  1. That will not work with hex codes, e.g: Player's name will be GT#ff0000X and you will write /push GTX. This will not work. You can use that: function findPlayer(namepart) local player = getPlayerFromName(namepart) if player then return player end for _,player in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(player):lower(),"#%x%x%x%x%x%x", ""), namepart:lower(), 1, true) then return player end end return false end
  2. Look around the MTA forums! I have seen many people asking the same question.
  3. Try to use addEventHandler ( "onClientRender", root, createShadowedLabelFromSpare ) on the end of your file.
  4. GTX

    /renamett problem

    It doesn't work...
  5. GTX

    Need help here...

    I got 'state' from race resource, so if player's state is 'dead' then...
  6. GTX

    Need help here...

    var:position 2 var:acc userdata: 0x90d5e90 var:count 2
  7. GTX

    Need help here...

    Yes, it is defined
  8. GTX

    Need help here...

    Both codes don't work. And no, my in-game nick is GTX#
  9. It doesn't work, I do not know why. There are no errors. Code: addCommandHandler( "renamett", function( player, cmd, place, name ) if not _TESTING and not isPlayerInACLGroup(player, g_Settings.admingroup) then return end if g_SToptimesManager and g_SToptimesManager.mapTimes then local row = g_SToptimesManager.mapTimes:renamett(place, name) if row then g_SToptimesManager:updateTopText() local mapName = tostring(g_SToptimesManager.mapTimes.mapName) local placeText = place and " #" .. tostring(place) or "" outputChatBox( "Top time"..placeText.." from '" .. tostring(row.playerName) .. "' renamed by " .. getPlayerName(player), getRootElement(), 255, 255, 0 ) outputChatBox( "Top time"..placeText.." has been renamed to " .. name, getRootElement(), 255, 255, 0 ) outputServerLog( "INFO: Top time"..placeText.." from '" ..tostring(row.playerName).. "' (" ..tostring(row.timeText).. " in " ..mapName.. ") renamed by " .. getAdminNameForLog(player) ) end end end ) g_SToptimesManager.mapTimes:renamett function: function SMaptimes:renamett(place, name) time = SMaptimes:getPositionForTime( time, dateRecorded ) place = tonumber(place) or 1 -- Although the list should be sorted already, make sure self:sort() -- Remove the first row if #self.dbTable.rows >= place then -- Copy it out and then remove it from the table local row = self.dbTable.rows[place] table.remove( self.dbTable.rows, place ) table.insert( self.dbTable.rows, place, getPlayerName(name), getPlayerSerial(name), timeMS, timeText, dateRecorded, extra ) return row end return false end
  10. Here seems to be wrong this: if getElementData(source, "state") == "dead" then... I can't get it... It's working fine if I delete that code Code: function earnMoney() local position = getAliveRacePlayers() local acc = getPlayerAccount(source) if getElementData(source, "state") == "dead" then else if not (position <= 0) then if getPlayerCount() >= count then local pAlive = getAliveRacePlayers() local pDead = getDeadRacePlayers() local maxCash = 21*(pAlive+pDead) -- Total cash available to earn. local portion = 0 local finalCash = 0 if not (position == 1) then portion = math.ceil(maxCash/(pAlive+pDead-1)) -- The amount to multiply by the number of dead players to later return the money value. finalCash = math.ceil(portion*(pDead)) -- Calculate the final money value. else finalCash = maxCash end local playerCash = getAccountData(acc,"Cash") or 0 outputChatBox("#FFFFFF>> #ff8600You have recieved $" .. finalCash .. "!",source,255,255,255,true) setAccountData(acc,"Cash", tostring(playerCash) + finalCash) outputDebugString("Final cash for player "..getPlayerName(source)..": "..finalCash) else outputChatBox("#FFFFFF>> #ff0000Need atleast " .. count .. " players to affect the stats!", source, 255, 255, 255, true) return end scoreboardRefresh(source) end end end addEventHandler("onPlayerWasted", getRootElement(), earnMoney)
  11. https://community.multitheftauto.com/index.php?p= ... ls&id=3656 - Not his map
  12. There were a lot of questions about that. Search around the forum!
  13. Yeah, definitely my vol 2 will be better. And of course, thanks for your replies!
  14. Hello, here I'll show you my first map
  15. Good job! I hope 1.4 will be released soon
  16. Try this: dxText = {} dxText_mt = { __index = dxText } local idAssign,idPrefix = 0,"c" local g_screenX,g_screenY = guiGetScreenSize() local visibleText = {} ------ local 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 ) 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 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 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:extent() local extent = dxGetTextWidth ( self.strText:gsub("#%x%x%x%x%x%x",""), self.fScale, self.strFont ) if self.strType == "stroke" or self.strType == "border" then extent = extent + self.tAttributes[1] end return extent end function dxText:height() local height = dxGetFontHeight ( self.fScale, self.strFont ) if self.strType == "stroke" or self.strType == "border" then height = height + self.tAttributes[1] end return height 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 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
  17. Awesome! Can't wait before its release!
  18. function DestructionWin( ) local alivePlayers = getAlivePlayers( ) if #alivePlayers == 1 then local account = getPlayerAccount( alivePlayers[1] ) if account then if isGuestAccount( account ) then return end setAccountData( account,"Race Wins",tostring( getAccountData( account,"Race Wins" ) or 0 ) +1 ) end local playername = getPlayerName( alivePlayers[1] ) outputChatBox ( "#FFA824The player " .. playername .. " won!", root, 255, 255, 255, true ) end end addEventHandler( "onPlayerWasted", root, function( ) local account = getPlayerAccount( source ) if account then if isGuestAccount( account ) then return end setAccountData( account,"Race Loses",tostring( getAccountData( account,"Race Loses" ) or 0 )+1 ) end end ) function ratioCalculator( player ) local KDR_DECIMAL_PLACES = 2 local account = getPlayerAccount( player ) if account then if isGuestAccount( account ) then return end local raceLoses = getAccountData( account,"Race Loses" ) if raceLoses == 0 then setAccountData( account, "Ratio", "-") else local kdr = round( getAccountData( account, "Race Wins" ) / raceLoses, KDR_DECIMAL_PLACES ) setAccountData( account, "Ratio", tostring(kdr)) end end end addEventHandler( "onPlayerLogin",root, function ( ) local account = getPlayerAccount( source ) if account then if isGuestAccount( account ) then return end local raceWins = getAccountData( account,"Race Wins" ) or 0 local raceLoses = getAccountData( account,"Race Loses" ) or 0 local ratio = getAccountData( account, "Ratio" ) or 0 setElementData( source,"Race Wins",tostring( raceWins ) ) setElementData( source,"Race Loses",tostring( raceLoses ) ) setElementData( source,"Ratio",tostring( ratio ) ) end end ) function publicstatsinfo( ) if isElement( source ) then local account = getPlayerAccount( source ) if account then if isGuestAccount( account ) then return end local askdname = getPlayerName( source ) local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 local ratio = getAccountData( account, "Ratio" ) or 0 if loses and wins then outputChatBox("#FFA824*" .. tostring( askdname ) .. " won " .. tostring( wins ) .. " times and he lost " ..tostring( loses ).. " times, his ratio is " .. tostring( ratio ) .. "%", root, 255, 12, 15, true) else outputChatBox("#FFA824*" .. tostring( askdname ).. " doesen't losed or won " , root, 255, 12, 15, true) end end else outputChatBox( "Error source is not player" ) end end addEvent( "stats", true ) addEventHandler( "stats", root, publicstatsinfo ) function checkCommand( message, messageType ) if messageType == 0 then if message == "!stats" then triggerEvent( "stats", source ) cancelEvent( ) end end end addEventHandler( "onPlayerChat", root, checkCommand )
  19. Thank you a lot, my friend
  20. Hello, I got confused with setting positions, so I'll explain. I've got resolution 1680x1050 and the text is on the right position but when I change it to for example 800x600 then the text isn't showing. Here's the code: function dx() sx, sy = guiGetScreenSize() dxDrawText("dx 24/7 text DD/DM", (754/1024)*sx-50, (228/768)*sy-290, (732/1024)*sx, (258/768)*sy, tocolor(255,255,255,255), (sx/1024)*0.8, "bankgothic") end addEventHandler("onClientRender", getRootElement(), dx) Thanks in advance
  21. GTX

    I'm confused...

    Ah yes, got it, thanks!
  22. GTX

    I'm confused...

    Hello, I got confused so I post this here, thanks in advance: addCommandHandler('stats', function(source, command, name) if not name then local acc = getPlayerAccount(source) if isGuestAccount(acc) then outputChatBox("#FFFFFF>> #ff0000You must be logged in to view someones stats.", source, 0, 0, 255, true) else outputChatBox("#FFFFFF>> "..getPlayerName(source).." #0fc0fcstats:", source, 0, 0, 255, true) outputChatBox("#0fc0fcVisits: #FFFFFF" ..tostring(getAccountData(acc,"visits")).. " #0fc0fcWins: #FFFFFF" .. tonumber(getAccountData(acc, "played") or 0 - getAccountData(acc, "deaths") or 0) .. " #0fc0fcDeaths: #FFFFFF" ..tostring(getAccountData(acc, "deaths")).. " #0fc0fcMaps played: #FFFFFF" ..tostring(getAccountData(acc, "played")), source, 0, 0, 255, true) outputChatBox("#0fc0fcCash: #ffffff$"..getPlayerMoney(source) .. " #0fc0fcPoints: #ffffff" .. tostring(getAccountData(acc,"points")), source, 0, 0, 255, true) end else local player, playerName = findPlayer(name) local accn = getPlayerAccount(player) if player then outputChatBox("#FFFFFF>> "..playerName.." #0fc0fcstats:", source, 0, 0, 255, true) outputChatBox("#0fc0fcVisits: #FFFFFF" ..tostring(getAccountData(accn,"visits")).. " #0fc0fcWins: #FFFFFF" ..tonumber(p_MPlayed[player] - p_Deaths[player]).. " #0fc0fcDeaths: #FFFFFF" ..tostring(p_Deaths[player]).. " #0fc0fcMaps played: #FFFFFF" ..tostring(p_MPlayed[player]), source, 0, 0, 255, true) outputChatBox("#0fc0fcCash: #ffffff$"..getPlayerMoney(player).."#0fc0fc Points: #ffffff" .. tostring(getAccountData(accn, "points")), source, 0, 0, 255, true) else outputChatBox("#FFFFFF>> #ff0000Invalid player.", source, 0, 0, 255, true) end end end ) Check out line 10! Error: Attempt to perform arithmetic on a boolean value.
×
×
  • Create New...