Giter Site home page Giter Site logo

Comments (4)

quiret avatar quiret commented on August 20, 2024

CPed is also a CMatrix. Try using the "SetTranslate" method of CMatrix.

https://github.com/DK22Pac/plugin-sdk/blob/master/plugin_vc/game_vc/CMatrix.h#L49

This is actually very different from SA because CPed is not a CMatrix there but has a CMatrixLink pointer as member.

from plugin-sdk.

EightyVice avatar EightyVice commented on August 20, 2024

well i wrote that code and it crashes when i press TAB
the code

#include "plugin_vc.h"
#include <game_vc\CHud.h>
#include <game_vc\CPed.h>
#include <game_vc\CCivilianPed.h>
#include <game_vc\CWorld.h>
#include <game_vc\CPopulation.h>
#include <game_vc\CPedType.h>
#include <game_vc\ePedType.h>
#include <game_vc\CVector.h>
#include <game_vc\CPlayerPed.h>
#include <iostream>
#include <string>
using namespace plugin;

class MyPlugin {
public:
	MyPlugin() {
		Events::gameProcessEvent += [] {
			if (KeyPressed(VK_TAB))
			{
				const CVector place = CVector::CVector(0.0, 0.0, 0.0);
				//CPed *ped = new CCivilianPed(CPopulation::AddPed(ePedType::PEDTYPE_DUMMY, 0, place, 0));
				CPed *ped = CPopulation::AddPed(ePedType::PEDTYPE_DUMMY, (unsigned int)0, place, 0);
				CWorld::Add(ped);
				CHud::SetHelpMessage((unsigned short*)"Done", false, false, true);
			}
		};
	}
} myPlugin;

and can you show a small example about using CMatrix because its confusing

from plugin-sdk.

quiret avatar quiret commented on August 20, 2024
#include "plugin_vc.h"
#include <game_vc\CHud.h>
#include <game_vc\CPed.h>
#include <game_vc\CCivilianPed.h>
#include <game_vc\CWorld.h>
#include <game_vc\CPopulation.h>
#include <game_vc\CPedType.h>
#include <game_vc\ePedType.h>
#include <game_vc\CVector.h>
#include <game_vc\CPlayerPed.h>
#include <iostream>
#include <string>
using namespace plugin;

class MyPlugin {
public:
	MyPlugin() {
		Events::gameProcessEvent += [] {
			if (KeyPressed(VK_TAB))
			{
				const CVector place = CVector::CVector(0.0, 0.0, 0.0);
				//CPed *ped = new CCivilianPed(CPopulation::AddPed(ePedType::PEDTYPE_CIVMALE, 0, place, 0));
				CPed *ped = CPopulation::AddPed(ePedType::PEDTYPE_CIVMALE, (unsigned int)0, place, 0);
				CWorld::Add(ped);
				CHud::SetHelpMessage((unsigned short*)L"Done", false, false, true);
			}
		};
	}
} myPlugin;

This code should work, I tested it. Regarding CHud class of Vice City, we can hack and use wchar_t mapping to unsigned short. But remember that CHud does not actually support unicode, so be careful. If used wrong it leads to a deadlock.

Also, if you use dxwnd to put Vice City into windowed mode you can attach a debugger to it if your debug ASI is loaded. Then you can put breakpoints into your code. This way you could find out that ped can be NULL sometimes.

from plugin-sdk.

quiret avatar quiret commented on August 20, 2024

"and can you show a small example about using CMatrix because its confusing"

To answer your last question, here is a player teleportation example that moves you up into the sky when you press/hold Tab key.

#include "plugin_vc.h"
#include "game_vc/common.h"

using namespace plugin;

class MyPlugin {
public:
    MyPlugin() {
        Events::gameProcessEvent += []()
        {
            if (KeyPressed(VK_TAB))
            {
                CPed *player = FindPlayerPed();

                if ( player != NULL )
                {
                    CVector oldPos = player->m_placement.pos;
                    player->m_placement.SetTranslateOnly( oldPos.x, oldPos.y, oldPos.z + 3.0f );
                }
            }
        };
    }
} myPlugin;

Please note that CPlacement is a CMatrix. I may have mistakenly said previously that CPed is a CPlacement, but no it just has a member called m_placement (same thing really). So calling player->m_placement.SetTranslateOnly is calling a method of CMatrix.

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.