Skip to content

Commit 7e40397

Browse files
committed
add functions add hot fix
Добавил функции для работы с диалогами, а так же исправил критические ошибки: 1. Исправил директории require 2. Обновил структуру stLocalPlayer
1 parent 5ddae65 commit 7e40397

15 files changed

Lines changed: 117 additions & 94 deletions

SA-MP API/init.lua

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
--[[
22
Project: SA-MP API
3-
Author: LUCHARE
4-
Website: BlastHack.Net
5-
Copyright (c) 2018
3+
Author: LUCHARE, Tim4ukys
4+
Website: BlastHack.Net, vk.com/tim4ukys
5+
Copyright (c) 2018, 2021
66
]]
77

88
local mem = require( 'memory' )
99
local ffi = require( 'ffi' )
1010

1111
local module = {
12-
_version = 1.11,
12+
_version = 2.1,
1313

1414
Version = nil,
1515
Handle = 0x0,
@@ -38,7 +38,10 @@ local offset = {
3838
fnDisableScoreboard = {['0_3_7-R1'] = 0x06A320, ['0_3_7-R3'] = 0x06E270, ['0_3_DL-R1'] = 0x06E410, ['0_3_7-R4-2'] = 0x06E9E0};
3939
fnSetSpecialAction = {['0_3_7-R1'] = 0x0030C0, ['0_3_7-R3'] = 0x0030C0, ['0_3_DL-R1'] = 0x003110, ['0_3_7-R4-2'] = 0x0030F0};
4040

41+
-- Update v1.1.1(Jun 2, 2021)
4142
fnTakeScreenshot = {['0_3_7-R1'] = 0x070FC0, ['0_3_7-R3'] = 0x074EB0, ['0_3_DL-R1'] = 0x075040, ['0_3_7-R4-2'] = 0x075620};
43+
-- Update v2.1(Aug 23, 2021)
44+
fnShowDialog = {['0_3_7-R1'] = 0x06B9C0, ['0_3_7-R3'] = 0x06F8C0, ['0_3_DL-R1'] = 0x06FA50, ['0_3_7-R4-2'] = 0x070010};
4245
};
4346

4447
local define = require( 'SA-MP API.samp.definitions' )
@@ -77,13 +80,13 @@ end
7780
function module.Get()
7881
if ( define ~= nil ) then define( module.Version ); define = nil end
7982
return {
80-
pChat = cast( 'stChatInfo' ),
81-
pChatInput = cast( 'stInputInfo' ),
82-
pKillList = cast( 'stKillInfo' ),
83-
pBase = cast( 'stSAMP' ),
84-
pScoreboard = cast( 'stScoreboardInfo' ),
85-
pRecentDialog = cast( 'stDialogInfo' ),
86-
pMisc = cast( 'stGameInfo' ),
83+
pChat = cast( 'stChatInfo' ),
84+
pChatInput = cast( 'stInputInfo' ),
85+
pKillList = cast( 'stKillInfo' ),
86+
pBase = cast( 'stSAMP' ),
87+
pScoreboard = cast( 'stScoreboardInfo' ),
88+
pRecentDialog = cast( 'stDialogInfo' ),
89+
pMisc = cast( 'stGameInfo' ),
8790

8891
-- see samp/%version%/enums.lua
8992
Enum = require( 'SA-MP API.samp.' .. module.Version .. '.enums' )
@@ -164,10 +167,6 @@ function module._RegisterClientCommand( cmd, func )
164167
ffi.cast( 'void ( __thiscall * )( void *, char *, CMDPROC )', module.Handle + offset.fnAddChatCmd[module.Version] )( this, cmd, callback )
165168
end
166169

167-
function module.TakeScreenshot()
168-
ffi.cast( 'void ( __cdecl * )( void )', module.Handle + offset.fnTakeScreenshot[module.Version] )( )
169-
end
170-
171170
function module.RequestSpawn()
172171
local this = module.Get().pBase.pPools.pPlayer.pLocalPlayer
173172
if ( this == 0x0 ) then return end
@@ -244,7 +243,12 @@ function module.SetSpecialAction( actionId )
244243
ffi.cast( 'void ( __thiscall * )( void *, char )', module.Handle + offset.fnSetSpecialAction[module.Version] )( this, actionId )
245244
end
246245

247-
-- Update
246+
-- Update v1.1.1(Jun 2, 2021)
247+
248+
function module.TakeScreenshot()
249+
ffi.cast( 'void ( __cdecl * )( void )', module.Handle + offset.fnTakeScreenshot[module.Version] )( )
250+
end
251+
248252
function module.AddChatMessage( msgColor, msg )
249253
module.AddMessageToChat( 8, msg, nullptr, msgColor, 0 )
250254
end
@@ -268,4 +272,20 @@ function module.TextdrawGetString( id )
268272
return ''
269273
end
270274

271-
return module
275+
-- Update v2.1(Aug 23, 2021)
276+
277+
function module.ShowDialog( iID, iStyle, szCaption, szText, szButton1, szButton2, bSendRequestToServer )
278+
local this = module.Get().pRecentDialog
279+
if ( this == 0x0 ) then return end
280+
281+
ffi.cast( 'void ( __thiscall * )( void *, int, int, const char*, const char*, const char*, const char*, bool )', module.Handle + offset.fnShowDialog[module.Version] )( this, iID, iStyle, szCaption, szText, szButton1, szButton2, bSendRequestToServer )
282+
end
283+
284+
function module.GetCurrentWeaponID( )
285+
local this = module.Get().pBase.pPools.pPlayer.pLocalPlayer
286+
if ( this == 0x0 ) then return 0 end
287+
288+
return this.byteCurrentWeapon
289+
end
290+
291+
return module

SA-MP API/samp/0_3_7-R4-2/stChatInfo.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
local sys = require 'SA-MP API.kernel'
99

10-
sys.safely_include 'SA-MP API.samp.0_3_7-R3.stChatEntry'
11-
sys.safely_include 'SA-MP API.samp.0_3_7-R3.stFontRenderer'
10+
sys.safely_include 'SA-MP API.samp.0_3_7-R4-2.stChatEntry'
11+
sys.safely_include 'SA-MP API.samp.0_3_7-R4-2.stFontRenderer'
1212

1313
sys.ffi.cdef[[
1414
struct stChatInfo {

SA-MP API/samp/0_3_7-R4-2/stGameInfo.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
local sys = require 'SA-MP API.kernel'
99

10-
sys.safely_include 'SA-MP API.samp.0_3_7-R3.stSAMPPed'
10+
sys.safely_include 'SA-MP API.samp.0_3_7-R4-2.stSAMPPed'
1111

1212
sys.ffi.cdef[[
1313
struct stAudio

SA-MP API/samp/0_3_7-R4-2/stGangzonePool.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
local sys = require 'SA-MP API.kernel'
99

10-
sys.safely_include 'SA-MP API.samp.0_3_7-R3.stGangzone'
10+
sys.safely_include 'SA-MP API.samp.0_3_7-R4-2.stGangzone'
1111

1212
sys.ffi.cdef[[
1313
struct stGangzonePool {

SA-MP API/samp/0_3_7-R4-2/stKillInfo.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
local sys = require 'SA-MP API.kernel'
99

10-
sys.safely_include 'SA-MP API.samp.0_3_7-R3.stKillEntry'
10+
sys.safely_include 'SA-MP API.samp.0_3_7-R4-2.stKillEntry'
1111

1212
sys.ffi.cdef[[
1313
struct stKillInfo {

SA-MP API/samp/0_3_7-R4-2/stLocalPlayer.lua

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,56 @@
66
]]
77
local sys = require 'SA-MP API.kernel'
88

9-
sys.safely_include 'SA-MP API.samp.0_3_7-R3.stSAMPPed'
10-
sys.safely_include 'SA-MP API.samp.0_3_7-R3.sync'
9+
sys.safely_include 'SA-MP API.samp.0_3_7-R4-2.stSAMPPed'
10+
sys.safely_include 'SA-MP API.samp.0_3_7-R4-2.sync'
1111

1212
sys.ffi.cdef[[
1313
struct stCameraTarget {
14-
unsigned short sTargetObjectID;
15-
unsigned short sTargetVehicleID;
16-
unsigned short sTargetPlayerID;
17-
unsigned short sTargetActorID;
14+
unsigned short sTargetObjectID;
15+
unsigned short sTargetVehicleID;
16+
unsigned short sTargetPlayerID;
17+
unsigned short sTargetActorID;
1818
} __attribute__ ((packed));
1919

2020
struct stLocalPlayer {
21-
stSAMPPed *pSAMP_Actor;
22-
2321
stInCarData inCarData;
2422
stAimData aimData;
2523
stTrailerData trailerData;
2624
stOnFootData onFootData;
2725
stPassengerData passengerData;
2826

29-
int iIsActive;
30-
int iIsWasted;
31-
unsigned short sCurrentVehicleID;
32-
unsigned short sLastVehicleID;
27+
int iIsActive; // -- +ECh
28+
int iIsWasted; // -- +F0h
29+
unsigned short sCurrentVehicleID; // -- +F4h
30+
unsigned short sLastVehicleID; // -- +F6h
31+
32+
// -- stAnimation
33+
unsigned short sCurrentAnimID; // -- +F8h
34+
unsigned short sAnimFlags; // -- +FAh
35+
unsigned int ulUnk0; // -- +FCh
3336

34-
// -- stAnimation | Not tested
35-
unsigned short sCurrentAnimID;
36-
unsigned short sAnimFlags;
37-
unsigned int ulUnk0;
37+
int iIsSpectating; // -- +100h
38+
stSAMPPed *pSAMP_Actor; // -- +104h
39+
unsigned char byteTeamID2; // -- +108h
3840

39-
int iIsSpectating;
40-
unsigned char byteTeamID2;
41-
unsigned short usUnk2;
42-
unsigned int ulSendTick;
43-
unsigned int ulSpectateTick;
44-
unsigned int ulAimTick;
45-
unsigned int ulStatsUpdateTick;
41+
unsigned short usUnk2; // -- +109h
42+
43+
unsigned int ulSendTick; // -- +10Bh
44+
unsigned int ulSpectateTick; // -- +10Fh
45+
unsigned int ulAimTick; // -- +113h
46+
unsigned int ulStatsUpdateTick; // -- 117h
4647

4748
// -- stCameraTarget
48-
struct stCameraTarget m_CameraTarget;
49-
unsigned int ulCameraTargetUpdate;
49+
struct stCameraTarget m_CameraTarget; // -- 11Bh
50+
unsigned int ulCameraTargetUpdate; // -- 123h
5051

51-
stHeadSync headSyncData;
52-
53-
unsigned int ulAnyUpdate;
54-
int iSpawnClassLoaded;
55-
unsigned int ulSpawnSelectionTick;
56-
unsigned int ulSpawnSelectionStart;
52+
stHeadSync headSyncData; // -- 127h
53+
54+
unsigned int ulAnyUpdate; // -- 13Bh
55+
56+
int iSpawnClassLoaded; // -- 13Fh
57+
unsigned int ulSpawnSelectionTick; // -- 143h
58+
unsigned int ulSpawnSelectionStart; // -- 147h
5759

5860
// -- stSpawnInfo
5961
unsigned char byteTeamID;
@@ -64,16 +66,17 @@ sys.ffi.cdef[[
6466
int iSpawnWeapon[3];
6567
int iSpawnAmmo[3];
6668

67-
int iIsActorAlive;
69+
int iIsActorAlive; // -- 179h
6870

69-
unsigned int ulWeapUpdateTick;
71+
unsigned int ulWeapUpdateTick;
7072
// -- stWeaponsData
71-
unsigned short sAimingAtPid;
72-
unsigned short usUnk3;
73-
unsigned char byteCurrentWeapon;
74-
unsigned char byteWeaponInventory[13];
75-
int iWeaponAmmo[13];
73+
unsigned short sAimingAtPid;
74+
unsigned short usUnk3;
75+
unsigned char byteCurrentWeapon;
76+
unsigned char byteWeaponInventory[13];
77+
int iWeaponAmmo[13];
7678

79+
// -- Далее я ничего не меня и не тестил
7780
int iPassengerDriveBy;
7881
unsigned char byteCurrentInterior;
7982
int iIsInRCVehicle;

SA-MP API/samp/0_3_7-R4-2/stObjectPool.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
local sys = require 'SA-MP API.kernel'
1010

11-
sys.safely_include 'SA-MP API.samp.0_3_7-R3.stObject'
11+
sys.safely_include 'SA-MP API.samp.0_3_7-R4-2.stObject'
1212

1313
sys.ffi.cdef[[
1414
struct stObjectPool {

SA-MP API/samp/0_3_7-R4-2/stPickupPool.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
local sys = require 'SA-MP API.kernel'
99

10-
sys.safely_include 'SA-MP API.samp.0_3_7-R3.stPickup'
10+
sys.safely_include 'SA-MP API.samp.0_3_7-R4-2.stPickup'
1111

1212
sys.ffi.cdef[[
1313
struct stPickupPool {

SA-MP API/samp/0_3_7-R4-2/stPlayerPool.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
local sys = require 'SA-MP API.kernel'
99

10-
sys.safely_include 'SA-MP API.samp.0_3_7-R3.stLocalPlayer'
11-
sys.safely_include 'SA-MP API.samp.0_3_7-R3.stRemotePlayer'
10+
sys.safely_include 'SA-MP API.samp.0_3_7-R4-2.stLocalPlayer'
11+
sys.safely_include 'SA-MP API.samp.0_3_7-R4-2.stRemotePlayer'
1212

1313
sys.ffi.cdef[[
1414
struct stPlayerPool {
@@ -18,7 +18,7 @@ sys.ffi.cdef[[
1818
void *pVTBL_txtHandler;
1919
char strLocalPlayerName[24];
2020
int iLocalPlayerPing;
21-
stLocalPlayer *pLocalPlayer;
21+
stLocalPlayer *pLocalPlayer; // -- +26h
2222

2323
int iIsListed[1004];
2424
unsigned int dwPlayerIP[1004];

SA-MP API/samp/0_3_7-R4-2/stSAMP.lua

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@
77

88
local sys = require 'SA-MP API.kernel'
99

10-
sys.safely_include 'SA-MP API.samp.0_3_7-R3.stServerPresets'
11-
sys.safely_include 'SA-MP API.samp.0_3_7-R3.stSAMPPools'
10+
sys.safely_include 'SA-MP API.samp.0_3_7-R4-2.stServerPresets'
11+
sys.safely_include 'SA-MP API.samp.0_3_7-R4-2.stSAMPPools'
1212

1313
sys.ffi.cdef[[
1414
struct stSAMP {
15-
void *pRakClientInterface;
16-
char unk1[44];
15+
void *pRakClientInterface;
16+
char unk1[44];
1717

18-
char szIP[257];
19-
char szHostname[257];
18+
char szIP[257];
19+
char szHostname[257];
2020

21-
bool m_bDisableCollision;
22-
bool m_bUpdateCameraTarget;
23-
bool bNametagStatus;
21+
bool m_bDisableCollision;
22+
bool m_bUpdateCameraTarget;
23+
bool bNametagStatus;
2424

25-
int ulPort;
26-
int iLanMode;
25+
int ulPort;
26+
int iLanMode;
2727

28-
unsigned int ulMapIcons[100];
28+
unsigned int ulMapIcons[100];
2929

30-
int iGameState;
31-
unsigned int ulConnectTick;
30+
int iGameState;
31+
unsigned int ulConnectTick;
3232

33-
stServerPresets *pSettings;
34-
char unk2[5];
35-
stSAMPPools *pPools;
33+
stServerPresets *pSettings;
34+
char unk2[5];
35+
stSAMPPools *pPools; // -- +3DEh
3636
} __attribute__ ((packed));
3737
]]

0 commit comments

Comments
 (0)