Jump to content

50p

Retired Staff
  • Posts

    2,973
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by 50p

  1. AWESOME, thank you :D

    Just two things left, how do I hide the image?

    And how do I put the image completely at the background? So if someone is new, and he wants to choose his team, he can't click on it now, because that image is in front of that gui. So I want that image behind it, always. How?

    And a little question if someone knows, which X-Y point is the middle of the screen, to show my image in the middle?

    Why don't you read the tutorial about GUI? You know where to learn from now.

    The center of the screen is just a simple math calculation which you should already know about...

    screenSize = { guiGetScreenSize() } -- make a table which is the size of player's screen, width -> [1], height -> [2]
     
    local centerOfScreenX = screenSize[ 1 ] / 2;
    local centerOfScreenY = screenSize[ 2 ] / 2;
     
    -- take a note of size of your image you want to display, eg. 100x200
    -- and get the center of it or rather get half of its dimensions
    local centerOfImageX = 100 / 2;
    local centerOfImageY = 200 / 2;
    MYIMAGE = guiCreateStaticImage( centerOfScreenX - centerOfImageX, centerOfScreenY - centerOfImageY, 100, 200, "IMAGE.png", false )
     
    -- hide:
    guiSetVisible( MYIMAGE, false );
     
    -- make it underneath everything:
    guiMoveToBack( MYIMAGE )
    

    READ THE WIKI AND TUTORIALS IF YOU HAVE QUESTIONS REGARDING SUCH THINGS.

    Most of the functions names are self-explanatory.

  2. Extended from mapmanager example:
    function loadMap(startedMap)
       mapRoot = getResourceRootElement(startedMap)
    local mapVehicles =  getElementsByType ( "vehicle", mapRoot )  --start at Map Root Element, we're not interested in other vehicles possibly existing
    for _, veh in pairs ( mapVehicles ) do
    toggleVehicleRespawn ( veh, true )
    setVehicleRespawnDelay ( veh, 30000 )  --delay in milliseconds, this is 30 seconds
    end
    end
     
    addEventHandler("onGamemodeMapStart", getRootElement(), loadMap)
    

    Either toggleVehicleRespawn or setVehicleRespawnDelay doesn't work properly.

    The best way to respawn vehicle after it explodes is to set a timer which will respawn the vehicle in onVehicleExplode event.

    https://wiki.multitheftauto.com/wiki/RespawnVehicle (the example shows exactly what I described)

  3. I've been trying to reproduce what causes the glitch inability-to-save glitch.

    So far; I've noticed:

    • Saving does not work if the file isn't part of a resource. Nor does it show in the SW info bar.
    • It occured after trying to change my profile settings.
    • A reinstall does not fix it. Nor could I find anything in Applications Data. Registry perhaps (though I searched for MTASE in regedit and got nothing)?
    • If saving doesn't work; neither does right-clicking or IntelliSense.

    - Oh, I know it doesn't save files that weren't added to any resource that's because of the way I open files.

    - What did you mean by "after trying to change my profile settings"? Your PC profile? And what settings?

    - MTASE is not stored in registry yet.

    A suggestion/feature request: allow opening other file formats (defaultly interpreting it as Lua).

    MTASE supports XML files as well. That was mainly to let users change their map files manually.

  4. The forum sa-mp, redirect me to you :) Do something to help in this language LUA? I'm using the current plugin, which allows the use of LUA scripts in SA-MP.

    They can't send you here simply because the plugin doesn't support MTA functions. You better start using MTA and learn Lua from our wiki. You will make scripts that are not possible in SA-MP.

    BTW, what does SA-MP camera bug has to do to MTA? It's just wrong.

  5. The point of this function is not to add it to command handler but call it from anywhere. You can call this function from onClientMarkerHit for example to start the countdown.. Or you can call this function when player dies to tell him how long until he respawns.

  6. .....

    uhm you forgot a thing:

    https://wiki.multitheftauto.com/wiki/AddCommandHandler

    The handler function takes one more argument (client-side)

    string commandName, [string arg1, string arg2, ...]
    

    So the countdown handler function will be:

    function Countdown( commandName, seconds )
    guiStaticImageLoadImage( IMAGE, "images/" .. tostring( seconds ) .. ".png" );
    guiSetVisible( IMAGE, true );
    if ( seconds > 0 ) then -- do we need to continue countdown?
    setTimer( Countdown, 1000, 1, seconds - 1 ); -- call this function again in 1sec. with decreased value of "seconds"
    else
           CountdownFinished( )
    end
    end
    

    and use the command like /countdown 3

    This should work.

    LEAVE THE COUNTDOWN FUNCTION ALONE! DO NOT MODIFY IT UNLESS YOU KNOW WHAT YOU'RE DOING! From what I see you don't know what you're doing.

    Your code will not work... What's the purpose of Countdown function? It starts countdown and takes only 1 parameter.

    I was hoping you can add command handler function yourself easily but it seems to be headache for both of you.

    addCommandHandler( "countdown",
    function( _, secs )
           secs = tonumber( secs )
    if secs then
               Countdown( secs )
    end
    end
    )
    

  7. First of all, I haven't added any commands there. You have to add it yourself.

    Second of all, guiCreateStaticImage doesn't hide the image after it's created... You must hide it yourself with guiSetVisible. Besides, image shouldn't be created outside a function (move it inside a function that is called when resource starts or somewhere else).

    Last but not least, debug your script.

  8. A useful tool would be an inbuilt CEGUI interface so that we can design GUI out of game.

    I've started making one long time ago but couldn't figure out why it stops rendering after loading cgui.dll up... There is no MTA Developer that knows why at least that's what they said when I asked them on IRC.

    If there is anyone that wants to help me, feel free to do so with my source code (it's C++):

    http://scripteditor.beta.mtasa.com/file ... or_src.zip

    I'm including here binaries if you can't compile it yourself:

    http://scripteditor.beta.mtasa.com/file ... Editor.zip

    As I said, I started making it pretty long time ago when MTA went open source, so the "CGUI..." classes and cgui.dll are old but that doesn't mean it's the cause of stopping DirectX from rendering since it worked with MTA.

    There are following features:

    - change resolution of rendering window (from 640x480 to 1680x1050)

    - loads cgui.dll from "File" menu

    - context menu (right-click menu) on "black screen" which is meant to let user create GUI elements quickly (it's useless since cgui.dll doesn't initialize at all)

    I'll say it again, MTA Developers weren't able or willing to help me and I got pissed off after a few weeks of trying to fix it.

  9. Keep in mind the bandwidth issues when using events - don't pass a large list of arguments unless you really need to. It is marginally more efficient to pass one large event than two smaller ones.

    If your array is small (say, 1 - 4), you can loop through it but it's not good idea to do so. Just send the array with 1 call.

  10. If you're planning to make your own countdown script with GUI then I'll give you some advice before you start:

    - Use 1 "static image element" and use guiStaticImageLoadImage instead of creating 4 images and showing/hiding them whenever needed.. this doesn't just save bandwidth but also memory where images are stored in

    - make 1 function that starts the countdown and counts down by itself.

    The less code your client-side script has the more bandwidth you save and shorter download time is.

    Take this as a sample:

    -- create your image (any image, can be "images/0.png")
    IMAGE = guiCreateStaticImage( ........ ); -- put your own arguments here
     
    -- call this function to start countdown, eg.  Countdown( 3 );
    function Countdown( seconds )
    guiStaticImageLoadImage( IMAGE, "images/" .. tostring( seconds ) .. ".png" );
    guiSetVisible( IMAGE, true );
    if ( seconds > 0 ) then -- do we need to continue countdown?
    setTimer( Countdown, 1000, 1, seconds - 1 ); -- call this function again in 1sec. with decreased value of "seconds"
    else
           CountdownFinished( )
    end
    end
     
    function CountdownFinished( )
    --[[ DO WHATEVER YOU WANT HERE
            WHEN COUNTDOWN ENDS...
            YOU CAN HIDE THE IMAGE ]]
    guiSetVisible( IMAGE, false );
    -- OR SHOW "GO!" for a second or 2
    guiStaticImageLoadImage( IMAGE, "images/go.png" );
    setTimer( guiSetVisible, 2000, 1, IMAGE, false );
    end
    

×
×
  • Create New...