Git Product home page Git Product logo

Comments (4)

DK22Pac avatar DK22Pac commented on June 12, 2024

It's possible to "call" an opcode in this way:

#include "extensions\ScriptCommands.h"
using namespace plugin::test;
// ...
ScriptCommand<PRINT_NOW>("FEC_INC", 150, 1);
#include "plugin_III.h"
#include "extensions\ScriptCommands.h"

using namespace plugin;
using namespace plugin::test;

class Gta3ScriptCommandsTest {
public:
    Gta3ScriptCommandsTest() {
        Events::processScriptsEvent += [] {

            int PlayerChar, PlayerCar;
            float CoordX, CoordY, CoordZ;

            if (ScriptCommand<IS_PLAYER_PLAYING>(0))
            {
                ScriptCommand<GET_PLAYER_CHAR>(0, &PlayerChar);
                if (ScriptCommand<IS_CHAR_IN_ANY_CAR>(PlayerChar))
                {
                    ScriptCommand<STORE_CAR_CHAR_IS_IN_NO_SAVE>(PlayerChar, &PlayerCar);
                    ScriptCommand<GET_CAR_COORDINATES>(PlayerCar, &CoordX, &CoordY, &CoordZ);
                    ScriptCommand<DRAW_SHADOW>(3, CoordX, CoordY, CoordZ, 0.0f, 3.0f, 150, 255, 0, 0);
                    ScriptCommand<PRINT_NOW>("FEC_INC", 150, 1);
                }
            }
        };
    }
} test;

from plugin-sdk.

goodidea82 avatar goodidea82 commented on June 12, 2024

Thanks for the quick reply.
I have a special use case where wrapper functions are automatically generated for opcodes.

Can I use hex-numbers instead of opcode names? E.g.
ScriptCommand< 0x00AA >(PlayerCar, &CoordX, &CoordY, &CoordZ);

Do I need the "Events::processScriptsEvent += [] {...}" to call an opcode and what does it mean?

I want the called opcode have the same effect on the current thread as a normal opcode would have. How do I pass the thread-pointer to the ScriptCommand? (or obtain a thread pointer if it has its own thread) In my code I have a function "copyThreadAttrToWrapper" that translates the state from the current thread to the fastman's SCMwrapper's thread and "copyWrapperToThread" to translate it back.

Here is an example of what I mean:

void op00A0(DWORD actHandle1, float& varX2, float& varY3, float& varZ4){
SCMwrapper.PushInt(actHandle1, true);
SCMwrapper.PushFloat(varX2, true);
SCMwrapper.PushFloat(varY3, true);
SCMwrapper.PushFloat(varZ4, true);
copyThreadAttrToWrapper(curThread, SCMwrapper, (curThread->notFlag? 0x80A0: 0x00A0));
cmdResult = SCMwrapper.CallCommand(curThread->notFlag? 0x80A0: 0x00A0);
copyWrapperToThread(SCMwrapper, curThread);
SCMwrapper.SaveReturnedValues(retVal);
varX2 = varX(retVal.returnedValues[1].Float);
varY3 = varY(retVal.returnedValues[2].Float);
varZ4 = varZ(retVal.returnedValues[3].Float);
}

The easiest for me would be if fastman's SCMwrapper API would be added back.

from plugin-sdk.

DK22Pac avatar DK22Pac commented on June 12, 2024

Can I use hex-numbers instead of opcode names?

Yes.

Do I need the "Events::processScriptsEvent += [] {...}" to call an opcode and what does it mean?

It's recommended to 'call' opcodes when scripts are 'processed' (i.e. executed). That's why processScriptsEvent event is used in this example.

How do I pass the thread-pointer to the ScriptCommand?

Not possible yet.

from plugin-sdk.

goodidea82 avatar goodidea82 commented on June 12, 2024

I have copied this thread here: http://gtaforums.com/topic/838490-cleo-plugin-how-to-call-an-opcode-within-a-cleo-plugin/?p=1069733231
because I don't know where to find again it when the issue is closed.

from plugin-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.