Jump to content

GRascm

Members
  • Posts

    23
  • Joined

  • Last visited

Posts posted by GRascm

  1. Yeah! Thank you for the tips, I made it! =) Not really great code, but it works.

    Here is the short demonstration of SetPedAnimationProgress function:

    And simple script, that i used to test animation progress:

      
    Progress = 0.5 
      
    function addAnim() 
        setPedAnimation( getLocalPlayer(), "SMOKING", "M_SMKSTND_LOOP") 
    end 
    addEventHandler( "onClientPlayerSpawn", getLocalPlayer(), addAnim) 
      
    function changeProgress(commandName, newProgress) 
        Progress = newProgress / 100; 
    end 
    addCommandHandler("animprogress", changeProgress) 
      
      
    function animRender() 
        setPedAnimationProgress(getLocalPlayer(), "M_SMKSTND_LOOP", Progress) 
    end 
    addEventHandler("onClientRender", getRootElement(), animRender) 
      
    

    And of cource a patch to MTA.

    http://pastebin.com/aC7tLWK3

    I have implemented just a client setPedAnimationFunction, I hope someone will implement animation syncing, and i have a stupid question:

      
                /* 
                Here must be something like  
                float fNewTime = pA->GetInterface()->pAnimHierarchy->fTotalTime * fProgress; 
                But only abstract classes avaliable here 
                */ 
                float fNewTime = *(float *)(*(DWORD *)( ((DWORD)(pA->GetInterface())) + 20) + 16) * fProgress; 
      
    

    What to do with this?

  2. A year ago i posted a request for setPedAnimationProgress scripting function

    And there was no progress, it still has "new" status.

    I tried to implement it myself, but nothing work :(

    And i am asking for help now.

    This is original GTA opcode handler for 0x0614(0614: set_actor $PLAYER_ACTOR animation "GYM_BP_DOWN" progress_to $1822 // 0.0 to 1.0) opcode.

    With my(and not only my comments).

      
    .text:00491802     ; __linkproc__ opcode_0614 
    .text:00491802     @@opcode_0614:                          ; CODE XREF: _opcode_handler_15+37j 
    .text:00491802                                             ; DATA XREF: .text:__linkproc__ opcode_tableo 
    .text:00491802 234                 push    1               ; set_actor %1d% animation %2h% progress_to %3d% // 0.0 to 1.0 
    .text:00491804 238                 mov     ecx, esi 
    .text:00491806 238                 call    CScriptThread__getNumberParams 
    .text:0049180B 234                 mov     ecx, _opcodeParameters 
    .text:00491811 234                 push    ecx             ; int 
    .text:00491812 238                 mov     ecx, _PedPool 
    .text:00491818 238                 call    ?atHandle@?$CPool@VCPed@@@@QAEPAVCVehicle@@I@Z ; CPed * CPool<CPed>::atHandle (u32 h); 
    .text:0049181D 234                 push    18h 
    .text:0049181F 238                 lea     edx, [esp+238h+var_1E4] 
    .text:00491823 238                 push    edx 
    .text:00491824 23C                 mov     ecx, esi 
    .text:00491826 23C                 mov     edi, eax   
    .text:00491828 23C                 call    _CScriptThread__getStringParam  
    .text:0049182D 234                 mov     ecx, [edi+18h] 
    .text:00491830 234                 lea     eax, [esp+234h+var_1E4] 
    .text:00491834 234                 push    eax 
    .text:00491835 238                 push    ecx 
      
    ; This function is actually FUNC_RpAnimBlendClumpGetAssociation_str, stores pointer to CAnimBlendAssociationSAInterface in EAX 
    .text:00491836 23C                 call    sub_4D6870    
      
      
    .text:0049183B 23C                 add     esp, 8 
    .text:0049183E 234                 push    1               ; count 
    .text:00491840 238                 mov     ecx, esi 
      
    ;moving our pointer to EDI 
    .text:00491842 238                 mov     edi, eax  
      
      
    .text:00491844 238                 call    CScriptThread__getNumberParams 
      
    ; if pointer is zero jump to return else continue running 
    .text:00491849 234                 test    edi, edi  
    .text:0049184B 234                 jz      loc_492203  
      
    ;Moving CAnimBlendHierarchySAInterface pointer from CAnimBlendAssociationSAInterface in EDX 
    .text:00491851 234                 mov     edx, [edi+14h]  
      
    ;It seems like loading fTotalTime field into FPU 
    .text:00491854 234                 fld     dword ptr [edx+10h] 
      
    ;I cant understand what this code do, but it is floating point  multiplication i think (using the stack? o_O) 
    .text:00491857 234                 push    ecx 
    .text:00491858 238                 fmul    _opcodeParameters 
      
    ;store in ecx pointer to CAnimBlendAssociationSAInterface 
    .text:0049185E 238                 mov     ecx, edi  
      
    .text:00491860 238                 fstp    [esp+238h+var_238] 
      
    ;calling function that actually sets animation frame position, takes one float argument, also uses data from ECX(there stored our pointer to that time) 
    .text:00491863 238                 call    sub_4CEA80      ; set animation progress 
      
    .text:00491868 234                 xor     al, al 
    .text:0049186A 234                 jmp     loc_492AAB 
      
    

    the function beginng

      
      
    .text:004CEA80     arg_0           = dword ptr  4 
      
      
    ;taking the argument of the function 
    .text:004CEA80 000                 mov     eax, [esp+arg_0] 
    .text:004CEA84 000                 fld     [esp+arg_0] 
      
    ;saving values, i think 
    .text:004CEA88 000                 push    ebx 
    .text:004CEA89 004                 push    esi 
      
    moving our pointer to esi and working with it 
    .text:004CEA8A 008                 mov     esi, ecx 
    .text:004CEA8C 008                 mov     ecx, [esi+14h] 
    .text:004CEA8F 008                 mov     [esi+20h], eax 
      
    ;... continue 
      
    

    I tried to add it to the MTA

      
    bool CStaticFunctionDefinitions::SetPedAnimationProgress ( CClientEntity& Entity, const char * szAnimName, float fProgress ) 
    {     
        RUN_CHILDREN SetPedAnimationProgress ( **iter, szAnimName, fProgress ); 
      
        if ( IS_PED ( &Entity ) ) 
        { 
            CClientPed& Ped = static_cast < CClientPed& > ( Entity ); 
            CAnimBlendAssociation* pA = g_pGame->GetAnimManager ()->RpAnimBlendClumpGetAssociation ( Ped.GetClump (), szAnimName ); 
      
            if ( pA ) 
            { 
                pA->SetCurrentTime ( fProgress ); 
            } 
        } 
      
        return false; 
    } 
      
    

    and

      
    void CAnimBlendAssociationSA::SetCurrentTime ( float fTime ) 
    { 
        DWORD DwFunc = 0x4CEA80; // function that actually sets the progress 
        float* fPointer = &fTime; //pointer to fTime, to pass it to function 
        _asm 
        { 
            push    ecx ; saving old ECX value 
            mov     ecx, m_pInterface ; moving "that" pointer to ECX, like the opcode handler 
            push    fPointer ; push the function argument 
            call    DwFunc ; call the function 
            pop     ecx ; and restore the ECX 
        }; 
    } 
      
    

    But of course nothing works, and game crashes. May be anyone have any idea? What am i doing wrong?

  3. I has connected to server, "Main" chatline was displayed ("Connected to MTA 1.1 Test Server [Windows]")

    Then may be 1-2 chat messages, and BOOM "Error! Can't send WM_COPYDATA". Or just full hanging. (Hanging(Полное зависание) are more often than crash)

    Dump is here: http://sendfile.su/397044

    WinXP 32bit, NVIDIA GeForce 480GTX if it will help.

    Oh, almost forget, if i clean "resource-cache folder"

    everything will be normal while resources being downloaded. After finishing download - immediately BUG.

  4. It is so great script editor, and all bugs not so annoing except one - the encoding bug is so annoing, I MUST use 2 editors at a time, MTASE to scripting, and then Notepad++ to re-encode script in necessary encoding. May be you will find a little time, to fix "encoding bug"? A little patch please :)

    ALso XML files with functions must update to current MTA version.

    PS

    place "function" between "\b" as other keywords, to prevent it from replacing in callClientFunction.

    <Block Name="Lua Code" Style="Lua Code" EscapeChar="" IsMultiline="true">
         <Scope Start="\bfunction\b" End="\bend\b" Style="Lua Keyword" Text="function ... end" CauseIndent="true" EndIsComplex="true" />
    

  5. Yes, I asked about the idea of scripting, even though I consider myself a good scripters, I sometimes need help, and there is nothing strange.

    You get by a negative attitude to the newcomers, if I ask you help, it does not mean that I ask to do everything for me (although some people do so), I just asked the ideas ... no matter on what basis would the seizure occurred, the main idea, and then I figured out ...

    Actually if anyone is interested I have done everything myself, without any help, realized it this way:

    When onPlayerWasted event is triggered I check whether the gang member in his area and was, he killed a player opposing gangs located in that area, and if so then start the timer-

    setTimer(checkCaptureTime, 1000, 1, 0, areaID, playerInfo[killer]["gang"], playerInfo[source]["gang"], currentArea)

    Here is code of the function:

    function checkCaptureTime(num, areaID, attackGang, defendGang, area)
    stillCapturing = false
    local allPlayers = getElementsByType("player")
    for k, player in ipairs(allPlayers) do
    	--here we check if player from attacking gang is on current zone, then attack still in progress and stillCapturing = true
    end
     
    if stillCapturing then
    	if num < 300 then --if num < 300 then the battle lasted less than 5 minutes, continue with check timer
    		setTimer(checkCaptureTime, 1000, 1, num+1, areaID, attackGang, defendGang, area)
    	else -- This means that the gang had no time to beat off for 5 minutes, and the territory was conquered by an enemy gang
    		outputChatBox("Gang ID "..defendGang.." loosed it's zone, now it zone of Gang ID "..attackGang )
    		setRadarAreaColor(area, 0, 255, 0, 100)--actually we ned to redraw to the new band color here...
    		setRadarAreaFlashing(area, false)
    		zoneInfo[areaID]["gangID"] = attackGang
    	end
    else
    	outputChatBox("Gang ID "..defendGang.." defended it's zone")--It mean that all enemies was killed, and zone was defended
    end
    end
    

  6. Please understand that you can't just ask for a script to be made for you, don't you think we have better things to do in our time? You'll have to do it yourself, we can help you with some parts of it, but we won't do it for you. Refer to the wiki for more information on scripts and scripting.

    Maybe I'm wrong words, or not correctly translated, but I tried to ask only idea how to do it, I'm pretty good scripters to do everything myself, I just could not think of the principle of implementation.

  7. Hi everyone, i need a little help with scripting.

    I am writing an Roleplay server, and i want to add some DM elements such as gang wars for territory under control, gangs will get some % from business on their territory, but it is not main.

    Main is: i have no idea how to do it, Can you help me? just a simple code, even not working code.

    There are many little gang zones(more than one hundred) and 4 bands.

  8. To fix bug of replacement callClientFunction to callClientfunction i have edited lua.syn

    where was such lines

    <Block Name="Lua Code" Style="Lua Code" EscapeChar="" IsMultiline="true">
    	<Scope Start="function " End="\bend\b" Style="Lua Keyword" Text="function ... end" CauseIndent="true" EndIsComplex="true" />
    

    I just add spase in Start="function "

    callClientFunction(...) - there a "(", and function funcName - there a " ".

  9. Hi all, I want to ask about two issues of MTA

    1. Problem with changing keyboard layout

    As far as I noticed that bug is on Windows XP, when you press keys to change keyboard layout, Layout dont changed in chat, you still write in previous layout. If you minimize the game, and then maximize(after pressing the key to change layout), layout will be changed.It happened not always, and not everyone has faced with this problem, but many players of my server.

    2. Proglem with a GUI

    I noticed the second problem, that is very important, sometimes, GUI events do not occur, Player pressed the GUI button, and Nothing Happened, And it is not Script BUG, it occur in differents scripts, my onw, and downloaded from

    community.multitheftauto.com

    May I ask, have this issues been registered on bugs.mtasa.com?(I habe not found them)

    What target version of it fix?

    May be it not MTA problem but something else?

    How to fix it myself, if it not MTA problem?

    If you cant understand what i wrote, sorry :) here is original russian alternative

    Всем привет я бы хоте спросить о двух серьёзных проблемах в MTA

    1.Проблема смены раскладки клавиатуры

    Как я заметил эта проблема проявляется на WindowsXP, после нажатия клавиш для смены раскладки, раскладка в чате остаётся прежней. Если после этого свернуть и развернуть игру, то раскладка смениться. Это проблема проявляется не всегда и не у всех, но многие игроки столкнулись с этим.

    2.Проблема с GUI

    Я заметил ещё одну проблему, очень важную, иногда события GUI не происходят. Игрок нажимает кнопку и ничего не случается,и это проблема не скриптов, это происходит в различных скриптах, моих собственных, и тех которые были скачаны с community.multitheftauto.com

    Можно спросить, эти проблемы были зарегестрированы на bugs.mtasa.com?(Я их там не нашел)

    В какой версии они будут исправлены?

    Может это проблема не МТА а чего либо ещё?

    Если это не проблема МТА, то как это исправить?

  10. Hello, can anyone help me?

    When people underwater, oxygen is infinite, also i can infinite run, how can i toggle it, to be normal mode, as single player?

    Also tell me please how to enable bike fall-off in my script

  11. There should be support for Unicode in GUI elements, it really needed for all NOTenglish speaking countries.

    I tried to rewrite the library cgui, for the new version of CEGUI(it has unicode support), but nothing work :(

    also i want add, that there a bug with changing keyboard layout on Window XP, I cant change it during the game, only if i minimize, and maximize game then layout will change

    PS sorry for my bad english

  12. I just copy'pasted that line into my map file and I didn't get the Fatal Error 6... I checked MTA source why it gives you Fatal Error 6 and found out that it's usually when MTA tries to get custom data. Custom data name can not be greater than 32 characters.

    Try to stop every resource and run only the one with your map file, then connect.

    big thanks for your help, but explain to me please what mean "Custom data name" and where MTA tries to get custom data? What I must to correct that don't have such errors?

    Thank you very much!

  13. It seems like a bug.

    - Are you sure it's this line that cause the error?

    - Is it your local server?

    - Do you get that error as well or just other players?

    1. Yes it's this line that cause error, before opening topic I was trying to resolve problem myself and I decide that this line cause error.

    2. Yes it is my server.

    3. Yes i get this error too.

  14. i have some troubles with a vehicles, i dont now how report about bug, and decide to write it here:

    I have 1970 vehicles over whole map, and server work whithout any troubles, all vehicles created by *.map file, but if i using vehicle id 611 user cant connect to my server they get error message: Fatal Error 6, i thought that i use too many veehicles, but i put more to try and server work -

    <vehicle model="611" posX="1302.968139" posY="1653.104248" posZ="10.470600" rotX="0" rotY="0" rotZ="268.427795" />
    

    if i add this line to the *.map file, then all gamers have fatal error 6, is any troubles in line or i found a bug?

    I dont need this vehicle very match but is it a bug?

    P.S. Sorry for my very bad English :oops:

×
×
  • Create New...