[saco] Implement CPlayerPed::GiveWeapon(...)

This commit is contained in:
RD42 2024-05-03 22:09:09 +08:00
parent 653f8dcc16
commit f6211221c4
2 changed files with 45 additions and 0 deletions

View File

@ -3,6 +3,8 @@
#include "util.h"
#include "keystuff.h"
extern CGame *pGame;
extern BYTE *pbyteCurrentPlayer;
//-----------------------------------------------------------
@ -47,6 +49,47 @@ CPlayerPed::CPlayerPed()
field_2F9 = 0;
}
void CPlayerPed::GiveWeapon(int iWeaponID, int iAmmo)
{
if(!m_pPed) return;
if(!GamePool_Ped_GetAt(m_dwGTAId)) return;
int iModelID = 0;
iModelID = GameGetWeaponModelIDFromWeaponID(iWeaponID);
if(iModelID == -1) return;
if(!pGame->IsModelLoaded(iModelID)) {
pGame->RequestModel(iModelID);
pGame->LoadRequestedModels();
while(!pGame->IsModelLoaded(iModelID)) Sleep(1);
}
//ScriptCommand(&give_actor_weapon,this->m_dwGTAId,iWeaponID,iAmmo);
*pbyteCurrentPlayer = m_bytePlayerNumber;
GameStoreLocalPlayerWeaponSkills();
GameSetRemotePlayerWeaponSkills(m_bytePlayerNumber);
DWORD dwPedPtr = (DWORD)m_pPed;
_asm mov ecx, dwPedPtr
_asm push 1
_asm push iAmmo
_asm push iWeaponID
_asm mov edx, 0x5E6080
_asm call edx
GameSetLocalPlayerWeaponSkills();
SetArmedWeapon(iWeaponID, false);
*pbyteCurrentPlayer = 0;
//pGame->RemoveModel(iModelID);
}
//-----------------------------------------------------------
void CPlayerPed::SetArmedWeapon(int iWeaponType, bool bUnk)

View File

@ -1,6 +1,7 @@
#pragma once
#include "game.h"
#include "aimstuff.h"
#include "entity.h"
@ -17,6 +18,7 @@ public:
WORD GetAmmo();
void GiveWeapon(int iWeaponID, int iAmmo);
void SetArmedWeapon(int iWeaponType, bool bUnk);
WEAPON_SLOT_TYPE * GetCurrentWeaponSlot();
WEAPON_SLOT_TYPE * FindWeaponSlot(DWORD dwWeapon);