GTAMP.com

Grand Theft Auto Media Press
It is currently Wed Feb 21, 2018 11:14 am

All times are UTC




Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: MISI
PostPosted: Mon Feb 12, 2018 3:05 pm 
Offline
Psycho

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 77
MISI
Library for executing custom scripts
Image

Version: v0.1a
Release: 12 feb 2018
Author: DenLover (aka Logofero)

License:
    This library (hereinafter "application") is distributed by
    license (EULA) free software "as is"
    without any guarantees. The text of the license is inside
    archive. The source code of this application is closed, but third-party
    libraries are integrated/or linked in unchanged
    You can find all the source resources on them in the archive.
    All licenses for used software are also in
    attached file.

What is it?
    Library for running LUA scripts in GTA2.
    The library is loaded at the start of the game and gives you access
    to the game world (as much as the author knows
    useful addresses in the memory of the game).

    The name MISI came to
    me from the derived word of the initial scripts * .MIS
    (which in translation probably means a mission) and together with
    extension ASI (which is used in the game) it turned out
    quite in tune with MISI.ASI.

Example:

    scripts/supermen.lua
    Code:
    -- *** Welcome to Supermen example ***
    -- This script give you speed and 200 hp and 200 armours.\nFor speed Press key Right Mouse
    local supermen = 0
    while(true) do
       local x, y, z = GetPlayerPos()
       if (x > 0 and y > 0 and z > 0) and (supermen == 0) then
          SetPlayerSkin(10)
          supermen = 1
       end
       if (IsKeyPress(2)) then
          SetPlayerSpeed(12)
          SetPlayerHealth(200)
          SetPlayerArmour(200)
       end
       wait(200)
    end

    scripts/messagesound.txt
    Code:
    -- *** Welcome to Message sound example test ***
    -- For play sound Down key space
    local address = 6168620
    while(true) do
       if (IsKeyDown(32)) then
          WriteProcessMemory(address, 62, 4)
       end
       wait(200)
    end


Installation:
    * Requires the installed game GTA2 v11.44

    1. Run the installer misi_setup.exe
    2. Select the installer language
    3. Read and accept the license agreement
    4. Select the root directory of the game
    5. Select components to install
    6. Confirm the installation
    7. Installation complete

What is this for?
    For easy and
    quick creation/editing of game missions, trainers.
    Thanks to the simple LUA syntax, anyone can use it
    To study and write the unpretentious script for GTA2 without spending
    thus it is a lot of time. It is enough to install MISI in the game,
    create a text * .TXT or * .LUA file (name it as
    wish), throw in the root folder script located
    in the root directory of the game (where gta2.exe is located),
    After that, you can run the game and enjoy your
    creation.

History of changes:
    v0.1, 25 jan 2018
    Start MISI project.
    Head developing and testing time...
    Integrated library LUA 5.3.4

    v0.1a, 12 feb 2018 Checksum MD5 fb67add3e1017bc64802b83da250dc25 MISI.ASI
    First alpha relase.

    v0.2b
    >In planing add Sound functions...


Download:
    Removed. Not yet available.
    Download will be available from v0.2b. Soon.

Thanks:
How can I help the project?
    The number of positive reviews depends on the
    project development. I will not hide that if MISI
    will not be updated for modmeykerov updates
    will not be. Also, the library needs useful addresses
    to implement full control over the resources of the game
    so far there is no possibility of creating new objects,
    transport, characters, but if you find the address
    (in memory of the game) and tell about the method
    I need to initialize/delete new objects
    add these functions to the script in the next version and
    I will point you out as the author of the method found.

    You can
    To contribute to the development of MISI by translating the Russian version
    Help and documentation in English
    (since I do not have the knowledge of the language I use
    machine translation). Also the fixes are accepted
    Russian grammar and punctuation. Your work will be
    accounted and marked in the next release.

    If you like this application and you want
    support the author so that he can develop it, you can send
    he donat.

Donate:

Feedback:


Attachments:
misi_logo.png
misi_logo.png [ 23.13 KiB | Viewed 486 times ]

_________________
[GTA2 Map] F-Industry-Live
[GTA2 FAQ] Help for scripters
[GTA2 Scipts] MISI Library


Last edited by Logofero on Sun Feb 18, 2018 10:37 am, edited 8 times in total.
Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Mon Feb 12, 2018 10:26 pm 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1303
Location: GTAMP.com
Nice work. Now the hard part of adding every single GTA2 script command and more. It should still be useful with the limited commands.

How is misi.asi started? What is telling GTA2 to load that DLL on startup? How does it work?


Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Tue Feb 13, 2018 4:49 am 
Offline
Psycho

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 77
Sektor wrote:
Nice work. Now the hard part of adding every single GTA2 script command and more. It should still be useful with the limited commands.

How is misi.asi started? What is telling GTA2 to load that DLL on startup? How does it work?

Thank you for your feedback, Sector.

It loads as a DLL and becomes part of the game process, after which we can work with the memory of the game as with its memory. The sound engine Miles Sound System, which is used in GTA2, loads MISI on game start.

_________________
[GTA2 Map] F-Industry-Live
[GTA2 FAQ] Help for scripters
[GTA2 Scipts] MISI Library


Last edited by Logofero on Wed Feb 14, 2018 5:08 am, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Tue Feb 13, 2018 5:20 am 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1303
Location: GTAMP.com
Yes I tested it and it worked but I didn't know Miles Sound System loaded all those files at startup, that's helpful.

Are most of the commands just for the player? I'm curious how it will handle all the other characters/peds in the future.


Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Tue Feb 13, 2018 6:37 am 
Offline
Psycho

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 77
Sektor wrote:
Yes I tested it and it worked but I didn't know Miles Sound System loaded all those files at startup, that's helpful.

Are most of the commands just for the player? I'm curious how it will handle all the other characters/peds in the future.

I tried to handle other characters, but so far it's only come from the 6th (in theory, since I do not have the ability to test more than 1 player on the computer). Ideally, teams should work with all characters including ped's and cars on the specified id. The same with other objects. I need more useful methods and examples of working with structures then there will be updates. Now I need to find out how MISI works for different users, on which API it drops (since I did not check all my GET/SET methods - this requires a lot of testing). The second task after testing: how to refer to the structures ped, cars, objs, etc in the cycle, also find out how many of them are in the game: the ID's ranges - from which ID to all the objects in the game, the maximum weight of the structures (their offset in bytes). Example: players 1-6, then peds 7-200, cars 201 -... and so on.

Add:
Another thing worth mentioning is that now all MISI methods work with the player's structure under id 1, if you spawn under this id then everything will work as it should, but if you are another id like 2..6, the script probably does not load and displays a syntax error in MISI.log: Error in LUA: <script file> ... 'nil' value. Maybe the game will crash or nothing will happen but the script with this method will be unloaded. Or if you are a host in multiplayer, you may be able to change the player's data to id 1, but this is only a theory (because in practice I did not check MISI's work with other players in the game in multiplayer).

In order for your script to work only in a single player and not run in multiplayer, I recommend doing a test:
Code:
while(true) do
   if (~IsNetwork()) then
      if (IsKeyDown(13)) then -- Press enter for set skin
         SetPlayerSkin(0)
      end
   end
   wait(200)
end


Edited: Fixed code example

_________________
[GTA2 Map] F-Industry-Live
[GTA2 FAQ] Help for scripters
[GTA2 Scipts] MISI Library


Last edited by Logofero on Wed Feb 14, 2018 3:13 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Tue Feb 13, 2018 12:51 pm 
Offline
User avatar

Joined: Sat Dec 26, 2009 11:53 pm
Posts: 1089
that looks very promising. about running multiple games at once: you can do that by playing in window mode and creating a game with gta2.exe -c and join with -j with as many players as you want as long as your computer is fast enough which should not be a problem with multi core systems. im curious if the network game stays in sync. that would be really great.

_________________
yur sa'nok ngeyä


Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Tue Feb 13, 2018 9:35 pm 
Offline
Psycho

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 77
elypter wrote:
that looks very promising. about running multiple games at once: you can do that by playing in window mode and creating a game with gta2.exe -c and join with -j with as many players as you want as long as your computer is fast enough which should not be a problem with multi core systems. im curious if the network game stays in sync. that would be really great.

I'll try when I get back to working out. Thank you.

I also wanted to warn you there are unsolved moments: If set SetPlayerHealth(0) health is removed, the sex of the heart does not remain completely. I do not know why it is so. Why the player does not die. Maybe it's protection from cheating through memory. I also tried to change the position of the player but instead the position of the camera changed, the addresses might be confused:

    ped+1AC=x coordinate (coordinates are 0 to 255 multiplied by 16384)
    ped+1B0=y coordinate
    ped+1B4=z coordinate

Also wanted to find out who found out the addresses of give money, weapons and car remap

Added:
If you have found addresses and structures, write me here and I will add them to MISI next update

Added2:
When you change the health of the car, it does not light up/stew if it burns. It has not been decided yet and I'm not sure that it will be possible to solve it somehow. It is possible to update the status of the structure with an additional call, but the address of this method is not known to me and how to find it, too

_________________
[GTA2 Map] F-Industry-Live
[GTA2 FAQ] Help for scripters
[GTA2 Scipts] MISI Library


Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Tue Feb 13, 2018 10:46 pm 
Offline
User avatar

Joined: Sat Dec 26, 2009 11:53 pm
Posts: 1089
i assume the code to kill the player works like

Code:
take_damage_bullet(p, angle){
play_blood_animation(p,angle)
p.health=p.health-5
if p.health(<=0){
  kill_player(p)
}
}


if you just decrease health then the if loop does not get executed.

with cars its probably similar. if i remember correctly running over cars with a tank also doesnt make them burn and even removes fire.


Quote:
the sex of the heart does not remain completely

i dont quite understand that sentence. do you mean that the last heart icon doesnt disappear if you have 0 health?

_________________
yur sa'nok ngeyä


Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Wed Feb 14, 2018 4:56 am 
Offline
Psycho

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 77
elypter wrote:
i assume the code to kill the player works like

Code:
take_damage_bullet(p, angle){
play_blood_animation(p,angle)
p.health=p.health-5
if p.health(<=0){
  kill_player(p)
}
}


if you just decrease health then the if loop does not get executed.

with cars its probably similar. if i remember correctly running over cars with a tank also doesnt make them burn and even removes fire.


Quote:
the sex of the heart does not remain completely

i dont quite understand that sentence. do you mean that the last heart icon doesnt disappear if you have 0 health?

Yes. The heart does not decrease.

To implement the death and explosion, the addresses of these procedures are needed. If there are fans of the cheat engine they will be able to cope and find them. I can add them to MISI if they are found. If not someone does not do this, then everything will remain as it is now Create a text file kill.txt in the scripts folder and paste the following code into it:
Code:
while(true)
    if (IsKeyDown(1)) then -- Press Left Mouse Button to kill self       
       SetPlayerHealth(0)   
    end   
    wait(200)
end

_________________
[GTA2 Map] F-Industry-Live
[GTA2 FAQ] Help for scripters
[GTA2 Scipts] MISI Library


Last edited by Logofero on Wed Feb 14, 2018 6:17 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Wed Feb 14, 2018 6:08 am 
Offline
User avatar

Joined: Sat Dec 26, 2009 11:53 pm
Posts: 1089
Quote:
Yes. The heart does not decrease.


i assume it works like this internally:

Code:
case health==100:
display_5_hearts()
case 90<health<100:
display_4_and_a_half_hearts()
...
default:
display_half_a_heart()


i havent played it in a while but this should be testable by exploding with low health. getting hit by an explosion makes you lose health but it is the explsion that kills you but not instantly if you fly through the air. if a hit by a rocket launcher costs 3 health and you have less than 3 there should be 0 hearts left but if i remember correctly there is always half a hear left. i could be totally wrong thoguh.

_________________
yur sa'nok ngeyä


Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Wed Feb 14, 2018 6:15 am 
Offline
Psycho

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 77
Updated:
I found what I was looking for. As well as calling the "death" procedure, the player will die. You do not even need to reset hp. In this case there is animation id 9. Animation found by BeepBooop viewtopic.php?f=4&t=1123
Thanks to him for this

_________________
[GTA2 Map] F-Industry-Live
[GTA2 FAQ] Help for scripters
[GTA2 Scipts] MISI Library


Last edited by Logofero on Thu Feb 15, 2018 8:22 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Wed Feb 14, 2018 6:39 am 
Offline
Psycho

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 77
You can test write health to memory address
scripts/testwritehp.txt
Code:
while(true)
   if (IsKeyDown(1)) then
       -- This method SetPlayerHealth(value)
       local player_offset = tonumber("0x5EB4FC") -- Address founded by Sector
       player_offset = player_offset + tonumber("0x4")
       local player_ptr = ReadProcessMemory(player_offset, 4)
       player_ptr = player_ptr + tonumber("0xC4")
       local player_struct = ReadProcessMemory(player_ptr, 4) -- Get player 1 struct
       player_struct = player_struct + tonumber("0x216")
       local player_health_ptr = ReadProcessMemory(player_struct, 4) -- Get hp pointer player 1
       WriteProcessMemory(player_health_ptr, 0, 2) -- Write 0 hp to player 1
   end
   wait(200)
end


Added:
Set player cam and dont change position

scripts/testsetpos.txt
Code:
while(true)
   if (IsKeyPress(13)) then -- Press enter for set pos
       -- Dont released method SetPlayerCamPos(x, y, z)
       -- Address player offset founded by Sector
       local player_offset = tonumber("0x5EB4FC")
       player_offset = player_offset + tonumber("0x4")
       local player_ptr = ReadProcessMemory(player_offset, 4)
       player_ptr = player_ptr + tonumber("0xC4")
       local player_struct = ReadProcessMemory(player_ptr, 4) -- Get player 1 struct
       -- Address cam position founded by Jones (http://gtamp.com/forum/viewtopic.php?f=4&t=700&start=20#p9357             
       local player_posx_ptr = player_struct + tonumber("0x1AC")
       local player_posy_ptr = player_struct + tonumber("0x1B0")
       local player_posz_ptr = player_struct + tonumber("0x1B4")
       local x = 150 * 16384
       local y = 150 * 16384
       local z = 2 * 16384
       -- Set x, y, z to 150.0, 150.0, 2.0
       WriteProcessMemory(player_posx_ptr, x, 4)
       WriteProcessMemory(player_posy_ptr, y, 4)
       WriteProcessMemory(player_posz_ptr, z, 4)
   end
   wait(200)
end


Edited:
Fixed in line tonumber()

_________________
[GTA2 Map] F-Industry-Live
[GTA2 FAQ] Help for scripters
[GTA2 Scipts] MISI Library


Last edited by Logofero on Wed Feb 14, 2018 1:22 pm, edited 4 times in total.

Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Wed Feb 14, 2018 8:51 am 
Offline
Psycho

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 77
For convert hex to integer in LUA

scripts/testoffset.txt
Code:
WriteInLog("Game offset in integer: " ..tonumber("0x3F0000")) -- or tonumber("3F0000", 16)
WriteInLog("Game offset in hex: " ..format("0x%X", GetGameOffset()))

_________________
[GTA2 Map] F-Industry-Live
[GTA2 FAQ] Help for scripters
[GTA2 Scipts] MISI Library


Last edited by Logofero on Wed Feb 14, 2018 1:20 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Wed Feb 14, 2018 9:26 am 
Offline
Psycho

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 77
I found the reason why the player did not change position. The addresses are confused.

This is not a player's position but a camera position viewtopic.php?f=4&t=700

Maby this pos x,y,z
    dword[player+128h] = game camera x,y,z

_________________
[GTA2 Map] F-Industry-Live
[GTA2 FAQ] Help for scripters
[GTA2 Scipts] MISI Library


Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Wed Feb 14, 2018 9:44 am 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1303
Location: GTAMP.com
Yes sorry, I added the word camera to that part of the memory address topic now.

for moving a ped:

Pedsprite = peek dword [p1 + 168h] 360
anglepointer = peek dword [pedprite + 80h] 128
peek word [anglepointer]
peek word [anglepointer] + 20 = x
peek word [anglepointer] + 24 = y
peek word [anglepointer] + 28 = z


Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Wed Feb 14, 2018 2:18 pm 
Offline
Psycho

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 77
Sektor wrote:
Yes sorry, I added the word camera to that part of the memory address topic now.

for moving a ped:

Pedsprite = peek dword [p1 + 168h] 360
anglepointer = peek dword [pedprite + 80h] 128
peek word [anglepointer]
peek word [anglepointer] + 20 = x
peek word [anglepointer] + 24 = y
peek word [anglepointer] + 28 = z

Sector, player is 0x5EB4FC + 0x1C? So what is the offset for x, y, z in this structure 4 bytes?

    dword [player + 128h] = game camera x, y, z
    dword [player + 1E4h] = view camera x, y, z
    dword [player + 2A0h] = aux camera x, y, z

_________________
[GTA2 Map] F-Industry-Live
[GTA2 FAQ] Help for scripters
[GTA2 Scipts] MISI Library


Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Thu Feb 15, 2018 4:14 am 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1303
Location: GTAMP.com
Logofero wrote:
Sektor, player is 0x5EB4FC + 0x1C? So what is the offset for x, y, z in this structure 4 bytes?


I don't understand the question.

Here's a LUA example for writing to the player coordinates.

Syntax: [ Download ] [ Hide ]
Using Lua Syntax Highlighting
-- left mouse button teleports player to 44.5 , 103.125 , 2 , intended for Industrial

function setPed(x, y, z, a)
    local p = {addr, ptr, id, coord_addr, x, y, z, a, speed_addr, speed, car_ptr, car, sprite_ptr, sprite_addr, key_ptr, key, jump_addr, jump, count}
    local pinfo_ptr = tonumber("0x5EB4FC")
    local pinfo_addr = 0
    local arrayofplayerptrs
    local player_info
    local temp
    pinfo_addr = ReadProcessMemory(pinfo_ptr, 4)
    arrayofplayerptrs = pinfo_addr + 0x4
    player_info = ReadProcessMemory(arrayofplayerptrs, 4)
    if (player_info ~= NIL) then
        p.ptr = player_info+0xC4
        p.addr = ReadProcessMemory(p.ptr, 4)
        p.sprite_ptr=p.addr+360
        p.sprite_addr = ReadProcessMemory(p.sprite_ptr, 4)
        temp = p.addr+512 -- ped ID
        p.id = ReadProcessMemory(temp, 4)
        temp = p.sprite_addr+128 -- ped coord addr
        p.coord_addr = ReadProcessMemory(temp, 4)
    end
   
    if (p.coord_addr ~= NIL) then
        p.a = ReadProcessMemory(p.coord_addr, 4)
        WriteProcessMemory(p.coord_addr + 20, x * 16384, 4)
        WriteProcessMemory(p.coord_addr + 24, y * 16384, 4)
        WriteProcessMemory(p.coord_addr + 28, z * 16384 +1, 4)
        WriteProcessMemory(p.coord_addr, a, 4) -- angle write doesn't seem to work on the player
    end
end
   
while(true) do
    if (IsKeyDown(1)) then
        setPed(44.5 , 103.125 , 2, 180)
    end
   
    wait(200)
end
 
Parsed in 0.005 seconds, using GeSHi 1.0.8.10


Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Thu Feb 15, 2018 7:00 am 
Offline
Psycho

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 77
Sektor wrote:
Logofero wrote:
Sektor, player is 0x5EB4FC + 0x1C? So what is the offset for x, y, z in this structure 4 bytes?


I don't understand the question.

I meant how to get a pointer to [player]. Player pointer it is ped pointer?
    dword [player <<? + 2C4h] = player Ped pointer?
    dword [ped <<? + 15Ch] = player pointer

Sektor wrote:
Logofero wrote:
Here's a LUA example for writing to the player coordinates.

Syntax: [ Download ] [ Hide ]
Using Lua Syntax Highlighting
-- left mouse button teleports player to 44.5 , 103.125 , 2 , intended for Industrial

function setPed(x, y, z, a)
    local p = {addr, ptr, id, coord_addr, x, y, z, a, speed_addr, speed, car_ptr, car, sprite_ptr, sprite_addr, key_ptr, key, jump_addr, jump, count}
    local pinfo_ptr = tonumber("0x5EB4FC")
    local pinfo_addr = 0
    local arrayofplayerptrs
    local player_info
    local temp
    pinfo_addr = ReadProcessMemory(pinfo_ptr, 4)
    arrayofplayerptrs = pinfo_addr + 0x4
    player_info = ReadProcessMemory(arrayofplayerptrs, 4)
    if (player_info ~= NIL) then
        p.ptr = player_info+0xC4
        p.addr = ReadProcessMemory(p.ptr, 4)
        p.sprite_ptr=p.addr+360
        p.sprite_addr = ReadProcessMemory(p.sprite_ptr, 4)
        temp = p.addr+512 -- ped ID
        p.id = ReadProcessMemory(temp, 4)
        temp = p.sprite_addr+128 -- ped coord addr
        p.coord_addr = ReadProcessMemory(temp, 4)
    end
   
    if (p.coord_addr ~= NIL) then
        p.a = ReadProcessMemory(p.coord_addr, 4)
        WriteProcessMemory(p.coord_addr + 20, x * 16384, 4)
        WriteProcessMemory(p.coord_addr + 24, y * 16384, 4)
        WriteProcessMemory(p.coord_addr + 28, z * 16384 +1, 4)
        WriteProcessMemory(p.coord_addr, a, 4) -- angle write doesn't seem to work on the player
    end
end
   
while(true) do
    if (IsKeyDown(1)) then
        setPed(44.5 , 103.125 , 2, 180)
    end
   
    wait(200)
end
 
Parsed in 0.005 seconds, using GeSHi 1.0.8.10

Yep. Im also already experimented with teleport. Now we need to find a way to update the camera. Player cam moves very slowly towards at tp point

Edited: Question

_________________
[GTA2 Map] F-Industry-Live
[GTA2 FAQ] Help for scripters
[GTA2 Scipts] MISI Library


Last edited by Logofero on Thu Feb 15, 2018 3:22 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Thu Feb 15, 2018 9:45 am 
Offline
Psycho

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 77
Found a useful procedure for kill player (address found by BeepBoop viewtopic.php?f=4&t=1123). The method will be added to the next MISI update.

scripts/testtask.txt
Code:
-- Prototype method GetPlayerTask()
-- 0 run/walk
-- 1 state idle (no control)
-- 2 enter/exit car rotation (no control)
-- 3 enter car
-- 4 exit car (eject from player car)
-- 7 state idle
-- 9 death
-- 10 seat in car (put in player car)
-- 11.. state idle (no control)
function GetPlayerTask()
   local player_offset = GetGameOffset() + tonumber("0x001FB4FC") -- Address found by BeepBoop http://gtamp.com/forum/viewtopic.php?f=4&t=1123
   local player_array_ptr = ReadProcessMemory(player_offset, 4)
   player_array_ptr = player_array_ptr + 0x4
   local player_address = ReadProcessMemory(player_array_ptr, 4)
   player_address = player_address + 0x63C
   local player_struct = ReadProcessMemory(player_address, 4)
   player_struct = player_struct + 0x2C4
   local player_task_ptr = ReadProcessMemory(player_struct, 4)
   player_task_ptr = player_task_ptr + 0x278 -- Get player task
   local value = ReadProcessMemory(player_task_ptr, 1)
   return value
end
-- Prototype method SetPlayerTask(value)
function SetPlayerTask(value)
   local player_offset = GetGameOffset() + tonumber("0x001FB4FC") -- Address found by BeepBoop http://gtamp.com/forum/viewtopic.php?f=4&t=1123
   local player_array_ptr = ReadProcessMemory(player_offset, 4)
   player_array_ptr = player_array_ptr + 0x4
   local player_address = ReadProcessMemory(player_array_ptr, 4)
   player_address = player_address + 0x63C
   local player_struct = ReadProcessMemory(player_address, 4)
   player_struct = player_struct + 0x2C4
   local player_task_ptr = ReadProcessMemory(player_struct, 4)
   player_task_ptr = player_task_ptr + 0x278
   WriteProcessMemory(player_task_ptr, value, 1)
end
-- Prototype method IsPlayerAlive() return 1 if player in game
function IsPlayerAlive()
   local x, y, z = GetPlayerPos()
   if (x > 0) and (x < 256) and (y > 0) and (y < 256) and (z > 0) and (z < 8) then
      return true
   end
   return false
end
-- Gamemode
while(true) do
   if (IsPlayerAlive()) then
      if (GetPlayerHealth() <= 0) then
         SetPlayerTask(9) -- Set player task id 9 "death"
         wait(2000)
      end
   end
   if (IsKeyDown(4)) then -- Down key middle mouse wheel for kill self
      SetPlayerHealth(0)
   end
   wait(200)
end


Edited: It's more like a task than an animation. Therefore changed to task

_________________
[GTA2 Map] F-Industry-Live
[GTA2 FAQ] Help for scripters
[GTA2 Scipts] MISI Library


Top
 Profile  
 
 Post subject: Re: MISI
PostPosted: Thu Feb 15, 2018 3:33 pm 
Offline
Psycho

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 77
I found a method to give out weapons and ammunition. The method SetPlayerWeapon(weaponid, ammo) will be added to the upcoming MISI v0.2b update.

All MISI documentation is inside the installer. If you want to write a script in LUA, download the archive attached to the main header and install it on the PC after that you will be available MISI docks in text format. Enjoy!

_________________
[GTA2 Map] F-Industry-Live
[GTA2 FAQ] Help for scripters
[GTA2 Scipts] MISI Library


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group