Jump to content

Lordy

Members
  • Posts

    290
  • Joined

  • Last visited

Posts posted by Lordy

  1. You can change it locally.

    C:\Program Files\MTA San Andreas\MTA\cgui\CGUI.png

    But if you want to change it for other users too, you need to write custom GUI (using images etc.)

    There *could* be an option, kinda like server setting to enforce other CGUI.png on clients, but it's not possible at the moment. Search in bugs.mtasa.com if there is such issue, if not, create it ;) The main way to suggest features.

  2. I just speed-read the script, it seems to be EXACTLY what I'm after, though I honestly want to learn how to script that kind of stuff.

    EDIT: Out of curiosity, I pasted the code into the Script Editor, and there are tons of "unexpected symbol" errors and a few " expected near end" errors.

    You did switch line numbers off before copying, right? Or didn't you?

    @Solidsnake, it's hard to read the code with such indenting..

  3. Well how much data is lots of data? And if it's really optimised code, you should maybe break the loops up

    I'm not sure if this would work, but worth a try imo

    local n = 1
    local steps = 20
    for n,n+steps do 
    --whatever you do
    n = n + steps
    end
    for n,n+steps do
    n = n+steps
    end
    

    etc.

    so it would effectively do the whole loop but would be several loops so it wouldn't time out

  4. Don't pass. It's the most basic thing with commands/even gui windows

    local active = false
    function yourFunction()
    if not active then -- if it isn't active yet, only then
    -- your code, which starts stuff
    	active = true -- set it to active, so it couldn't get duplicated
    end
    end
    function yourSecondFunction()
    if active then -- only run, if it's active
    -- your code, which ends stuff here
    	active = false -- as things have been shut down, you can now set it to inactive again
    end
    end
    

    And when you start something, you call yourFunction, when ending it, yourSecondFunction

  5. That's kinda logical. It's not like SAMP, where server shows client gui :P It has to be a client side script, not server side. Wiki states aswell that gui functions are clientside not serverside.

  6. tables work exactly like any other variable. Let's say you have a server side variable serverVar = "niceHair". It can be called from server side scripts of that resource. Same case if you had a server side table serverTable = {}. You can operate with it only server side.

  7. Or you could cache the player list in a table on resource start and every time someone joins/leaves, you modify the table, so you wouldn't have to getElementsByType("player") every frame.

    local players = {} -- make it local to the file, not necessary, but I like
    function cachePlayers() 
    for k, v in ipairs(getElementsByType("player")) do
    	players[k] = v
    end
    end
     
    function addPlayer()
    table.insert(players,source)
    end
    function removePlayer()
    for k,v in ipairs(players) do
    if v == source then
    table.remove(players,k)
    return
    end
    end
    end	
    function drawList()
    for num,this_player in ipairs(players) do
    local plname = getPlayerName(this_player)
    dxDrawText(plname,100,100+num*16) --num increases with each cycle, so every name is drawn under previous name
    end
    end
    addEventHandler("onClientRender",root,drawList)
    addEventHandler("onClientResourceStart",resourceRoot,cachePlayers)
    addEventHandler("onClientPlayerJoin",root,addPlayer) -- add a player into the table when someone joins
    addEventHandler("onClientPlayerQuit",root,removePlayer) -- remove a player from table if he quits
    

    It's slightly more complicated but should be faster. Not much, but if you have lot's of stuff going on onClientRender, things should be optimized.

  8. Try this.

    Before doing the xmlLoadFile, output to chat fileExists("connect.xml") just to make sure MTA recognises the file.

    If it returns true, try having the xml file as

    <connect></connect>
    

    instead of just

    <connect/>
    

    Maybe it wants the root node to be like that. Also maybe it doesn't like attributes for the root node. Just see if it loads the file. These are just "maybes" which you should try. I'm not really sure what could be the problem there.

    EDIT: And just a tip, instead of checking, if the file is nil and if the file is false, use just

    if not File then end
    

    , because not nil and not false both return true

  9. Alright. There's the definitions.xml file in the resource

    Inside that, there are two languages defined, ENG and EST

    You can define something else (preferable keep ENG as the first, it's essential for the resource to work). Just duplicate the ENG part and change it for example to FIN. Now translate the strings. You can always add new strings aswell, but you need to make sure that the first (ENG) has all the strings listed. The others don't have to have. The resource="rodeggo" part means that the string is meant to be called from rodeggo resource. You have to change it to any other resource you are using (or use a bit different importing)

    Now in a random resource, you need to define

    myStringArray = exports.rodeggo:importStrings()
    

    Then you can use them like

    outputChatBox(myStringArray.SOMESTRINGID)
    

    SOMESTRINGID is the string name in definitions.xml

    And when you switch languages with "/setlang ENG", "/setlang FIN" then outputChatBox should output different strings.

    If you want to access strings which don't belong to that resource, you need to do

    myStringArray = exports.rodeggo:importStrings(resourcename)
    

    resourcename is the same as in string tag resource="" in definitions.xml

    You can check the source of the resource as well, there should be one commented out example.

×
×
  • Create New...