Другое SAMPFUNCS | API C++

OosKar

Известный
11
0
Can I apply some animations through sf? I've tried everything, but I can not solve it. What could be the problem?
Код:
        int ID = SF-> getSAMP () -> getPlayers () -> sLocalPlayerID;
        string category = "DILDO";
        string animationName = "DILDO_G";
        char * categoryC = "DILDO";
        char * animationNameC = "DILDO_G";
        char categoryCH [256] = "DILDO";
        char animationNameCH [256] = "DILDO_G";
        float animationSpeed = 4.1;

        BitStream bitStream;
        bitStream.ResetWritePointer ();
        bitStream.Write (int32 (ID)); // (int16 (ID)) // (BYTE (ID))
        bitStream.Write (DWORD (category.length ())); // (BYTE (category.length ())) // (strlen (categoryC))
        bitStream.Write ((PCHAR) category.c_str, category.length ()); // (categoryCH) // (category) // (categoryC) ((PCHAR) category, length)
        bitStream.Write (DWORD (animationName.length ())); // The same as above.
        bitStream.Write ((PCHAR) animationName.c_str, animationName.length ());
        bitStream.Write (animationSpeed);
        bitStream.Write (false);
        bitStream.Write (false);
        bitStream.Write (false);
        bitStream.Write (false);
        bitStream.Write (int (0));
        SF-> getRakNet () -> emulateRecvRPC (ScriptRPCEnumeration :: RPC_ScrApplyAnimation, & bitStream);

I developed the code for reading animation, and everything is working fine.
Код:
bool CALLBACK incomingRPC (stRakNetHookParams * params) {
    if (params-> packetId == ScriptRPCEnumeration :: RPC_ScrApplyAnimation) {

        byte fileAnimationLength = 0, animationNameLength = 0;
        char fileAnimationName [256], animationName [256];
        byte timeFlag = 0; // animationLoop = 0,
        float animationSpeed = 0;
        short unsigned int id = 0;
        bool animationLoop = false, lockX = false, lockY = false, freeze = false;
        size_t lengthFile = 0;
        params-> bitStream-> ResetReadPointer ();
        params-> bitStream-> Read (id);
        params-> bitStream-> Read (fileAnimationLength);
        params-> bitStream-> Read (fileAnimationName, fileAnimationLength);
        params-> bitStream-> Read (animationNameLength);
        params-> bitStream-> Read (animationName, animationNameLength);
        params-> bitStream-> Read (animationSpeed);
        params-> bitStream-> Read (animationLoop);
        params-> bitStream-> Read (lockY);
        params-> bitStream-> Read (lockX);
        params-> bitStream-> Read (freeze);
        params-> bitStream-> Read (timeFlag);
        params-> bitStream-> ResetReadPointer ();
        fileAnimationName [fileAnimationLength] = '\ 0';
        animationName [animationNameLength] = '\ 0';

        SF-> getSAMP () -> getChat () -> AddChatMessage (-1,
            "Player:% i | FileZ:% i | File:% s | NameZ:% i | Name:% s | Speed:%. 1f | Loop:% s | Y:% s | Z:% s | Freeze:% s | Time:% i ",
            id,
            fileAnimationLength,
            fileAnimationName,
            animationNameLength,
            animationName,
            animationSpeed,
            animationLoop? ("true"): ("false"),
            lockY? ("true"): ("false"),
            lockX? ("true"): ("false"),
            freeze? ("true"): ("false"),
            timeFlag);
    }
    return true;
}


EmulationRPC, Similar structure: (SR_team)
Код:
Number of bytes / name
_____________________________________________________
2 / id of the player to which the animation is applied
1 / length of animation file name
n / animation file name
1 / animation name length
n / animation name
4 / animation speed float
1 / animation looping 1/0
1 / lock y 1/0
1 / lock x 1/0
1 / freeze player 1/0
4 / some dwTime flag, usually 0 * /

Raklogger.json
Код:
            {
                "id": "86",
                "name": "RPC_ScrApplyAnimation",
                "lenBytes": "24",
                "lenBits": "188",
                "unreadBits": "188",
                "data": "000007414952504F5254046E756C6C333383400000000000",
                "datetime": "30.10.2017-21: 40: 17",
                "params": ""
            },

Raklogger.txt
Код:
[RPC Recv] RPC_ScrApplyAnimation [86] (length: 31 bytes, 244 bits)
> dump:
0000 00 00 07 42 44 5F 46 49 52 45 0B 42 44 5F 50 41 ... BD_FIRE.BD_PA
0010 4E 49 43 5F 30 31 64 3B 83 40 00 00 00 00 NIC_01d; ƒ @ .....

events.lua ([URL = 'https: //github.com/THE-FYP/SAMP.Lua/blob/master/samp/events.lua#L122'] SAMP.Lua / events.lua at master · THE-FYP / SAMP.Lua · GitHub ( SAMP.Lua / samp / events at master · THE-FYP / SAMP.Lua · GitHub (https://github.com/THE-FYP/SAMP.Lua/blob / master / samp / events) [/ sup] .lua # L122) [/ sup] [/ URL])
Код:
INCOMING_RPCS [RPC.APPLYANIMATION] = {'onApplyPlayerAnimation', {playerId = 'int16'}, {animLib = 'string8'}, {animName = 'string8'}, {loop = 'bool'}, {lockX = 'bool' }, {lockY = 'bool'}, {freeze = 'bool'}, {time = 'int32'}} [/ code] [/ code] [/ code] [/ sup]
 

itsLegend

Фонд борьбы за жуков 🐞
Администратор
2,696
1,468
Can I apply some animations through sf? I've tried everything, but I can not solve it. What could be the problem?
I can't say about RPC emulating, but you can take the PlayAnimation function from sobeit's source - mod_s0beit_sa/GTAfuncs.cpp at master · BlastHackNet/mod_s0beit_sa · GitHub(https://github.com/BlastHackNet/mod_s0beit_sa/blob/master/src/GTAfuncs.cpp#L660)
How it in SFPlugin:
C++:
    CAnimBlock* pBlock = GAME->GetAnimManager()->GetAnimationBlock("DILDO");
    if (pBlock != nullptr)
    {
        //bool bLoaded = false;

        if (!pBlock->IsLoaded())
        {
            pBlock->Request(EModelRequestType::BLOCKING);
        }

        if (pBlock->IsLoaded()) // TODO: to check: is timer need?
        {
            CTask* playAnimation = GAME->GetTasks()->CreateTaskSimpleRunNamedAnim(
                "DILDO_G",
                pBlock->GetName(),
                0x10 | 0x2 | 0x08 | 0x40 | 0x80, // flags: unknown, bLoop, bUpdatePosition, !bFreezeLastFrame
                4.0f
            );

            if (playAnimation != nullptr)
            {
                playAnimation->SetAsPedTask(PEDSELF, TASK_PRIORITY_PRIMARY);
            }
        }
    }
 
Последнее редактирование:

OosKar

Известный
11
0
GitHub [/ url] [GotHub] (https://github.com/BlastHackNet/mod_s0beit_sa/blob/master/src/GTAfuncs.cpp#L660) [/ sup]
How it in SFPlugin:
C++:
    CAnimBlock * pBlock = GAME-> GetAnimManager () -> GetAnimationBlock ("DILDO");
    if (pBlock! = nullptr)
    {
        // bool bLoaded = false;

        if (! pBlock-> IsLoaded ())
        {
            pBlock-> Request (EModelRequestType :: BLOCKING);
        }

        if (pBlock-> IsLoaded ()) // TODO: to check: is timer need?
        {
            CTask * playAnimation = GAME-> GetTasks () -> CreateTaskSimpleRunNamedAnim (
                "DILDO_G",
                pBlock-> GetName (),
                0x10 | 0x2 | 0x08 | 0x40 | 0x80, // flags: unknown, bLoop, bUpdatePosition ,! BFreezeLastFrame
                4.0f
            );

            if (playAnimation! = nullptr)
            {
                playAnimation-> SetAsPedTask (PEDSELF, TASK_PRIORITY_PRIMARY);
            }
        }
    }

Wow Thank you very much, it helped me a lot. : good:
 

Karbun

Участник
112
3
Реализовывал кто-то бег персонажа к определенным координатам с помощью SF API? Если да, можно пожалуйста код?
 

kawa operand

перерывпятьминут
602
333
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.

Vandal™

Известный
55
4
Есть туториалы по работе с GUI в SF API? Локальные диалоги использовать не хочу. Тот же DXUT/Awesomium засунуть в проект могу, а работа с ним не идет.
С MenuManager(SR_team) и ImGUI(Dark_Knight) получается, но я хочу на выходе такие меню, как в CLEO:
8124
 

Revalto

Известный
532
225
Делаю функционал для второго диалога, ничего не выходит.... в чем может быть проблема?
Вот так примерно выглядит код)
814d4mg.png
 

Karbun

Участник
112
3
C++:
SF->getSAMP()->getDialog()->SetInputText()
Как сюда можно вставить переменную с int?