GTAMP.com

Grand Theft Auto Media Press
It is currently Sat Aug 18, 2018 9:54 pm

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Script Question
PostPosted: Tue Feb 27, 2018 10:30 pm 
Offline
Car Jacker

Joined: Fri Oct 14, 2016 1:32 am
Posts: 41
Do you think it's possible to find the Closest Ped/Nearest to the Player structure? I want to change the nearest peds health to zero easily.


Top
 Profile  
 
 Post subject: Re: Script Question
PostPosted: Tue Feb 27, 2018 10:47 pm 
Offline
Hitman

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 165
BeepBoop wrote:
Do you think it's possible to find the Closest Ped/Nearest to the Player structure? I want to change the nearest peds health to zero easily.

Yes. It's possible.

I planned to add in MISI v0.2.2b a method GET ped from point, which will get the random ped's structure from point.

This is also possible using ready-made methods: GetPedStruct(id), GetPedPos(ped) and GetPedRangeOfPoint(ped, x, y, z) (or GetDisnanceOfPoints(x1, y1, z1, x2, y2, z2)) Then we need to go through all the ped in the loop and get the structure of the player closest to the player.

Example get ped from point
scripts/allpedcops.txt:
Code:
-- Since: v0.2.1b
while(true) do
    if (IsKeyDown(4)) then -- Down key left mouse key
      local ped = GetPedStruct(1)
      for id = 2, 65535, 1 do
           local targetped = GetPedStruct(id)
           if (targetped ~= 0) then -- Cheak ped is exist
               local x, y, z = GetPedPos(targetped)
               if (GetPedRangeOfPoints(ped, x, y, z) < 20.0) then -- Distane for find
                   SetPedModel(targetped, 2) -- Set model
                   SetPedSkin(targetped, 0) -- Set skin cop
                   SetPedOccupation(targetped, 24)
                   SetPedThreatReaction(targetped, 2)
                   SetPedReactionType(targetped, 2)
               end
           end
       end
    end
    wait(200)
end


Edite: Example code.

_________________
Map F-Industry-Live
MISI Library

Twitter channel @TheNonameGames


Last edited by Logofero on Wed Feb 28, 2018 3:19 pm, edited 6 times in total.

Top
 Profile  
 
 Post subject: Re: Script Question
PostPosted: Tue Feb 27, 2018 11:03 pm 
Offline
Car Jacker

Joined: Fri Oct 14, 2016 1:32 am
Posts: 41
I have seem to have found the address for [Last PED Touched] will post it in a bit.


Top
 Profile  
 
 Post subject: Re: Script Question
PostPosted: Tue Feb 27, 2018 11:24 pm 
Offline
Car Jacker

Joined: Fri Oct 14, 2016 1:32 am
Posts: 41
Okay can confirm structure works for Last Ped Touched.

Address:
Ped Structure + Offset #1 = 0x138 + Offset #2 = 0x7C + Offset #3 = 0x216.


Top
 Profile  
 
 Post subject: Re: Script Question
PostPosted: Tue Feb 27, 2018 11:33 pm 
Offline
Car Jacker

Joined: Fri Oct 14, 2016 1:32 am
Posts: 41
I was thinking of making a Medic mod or script, but I am currently not well trained in lua scripting. I almost have everything to make it work just need to put all in a readable script.


Top
 Profile  
 
 Post subject: Re: Script Question
PostPosted: Tue Feb 27, 2018 11:33 pm 
Offline
Hitman

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 165
BeepBoop wrote:
Okay can confirm structure works for Last Ped Touched.

Address:
Ped Structure + Offset #1 = 0x138 + Offset #2 = 0x7C + Offset #3 = 0x216.

Use the methods:
Code:
local pointer = ReadProcessMemory(address, size) -- For read address (get pointer)
WriteProcessMemory(address, value, size) -- For write value in address

As I cited in the example viewtopic.php?f=4&t=700&start=60#p10570

_________________
Map F-Industry-Live
MISI Library

Twitter channel @TheNonameGames


Top
 Profile  
 
 Post subject: Re: Script Question
PostPosted: Tue Feb 27, 2018 11:41 pm 
Offline
Hitman

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 165
BeepBoop wrote:
I was thinking of making a Medic mod or script, but I am currently not well trained in lua scripting. I almost have everything to make it work just need to put all in a readable script.

In this case i recommend studying the basics of LUA, it is a very easy language. Here is the official documentation http://www.lua.org/manual/5.3/

_________________
Map F-Industry-Live
MISI Library

Twitter channel @TheNonameGames


Top
 Profile  
 
 Post subject: Re: Script Question
PostPosted: Wed Feb 28, 2018 3:03 pm 
Offline
Hitman

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 165
BeepBoop, I checked your addresses today. Got a prototype of the GetPedTouch(ped)
Code:
-- Prototype method GetPedTouch(ped)
-- Since: v0.2.1b
function GetPedTouch(ped)
    local ped_touch_ptr = ReadProcessMemory(ped + 138, 4)
    local ped_touch_struct = ReadProcessMemory(ped_touch_ptr + 0x7C, 4)
    return ped_touch_struct
end

while(true)
    local ped = GetPedStruct(1) -- Get ped ID 1 (it player 1)
    if (ped ~= 0) then -- Cheak player 1 is exist
        local touchped = GetPedTouch(ped) -- Get touched ped struct
        if (touchped ~= 0) then -- Cheak touched ped is exist
            SetPedModel(touched, GetPedModel(ped)) -- Set touched ped model as player 1
            SetPedSkin(touchped, GetPedSkin(ped)) -- Set touched ped skin as player 1
        end
    end
    wait(200)
end

_________________
Map F-Industry-Live
MISI Library

Twitter channel @TheNonameGames


Top
 Profile  
 
 Post subject: Re: Script Question
PostPosted: Wed Feb 28, 2018 8:53 pm 
Offline
Car Jacker

Joined: Fri Oct 14, 2016 1:32 am
Posts: 41
Very Cool, I'll see if I can find anything else that is useful. Is there anything or addresses that you are looking for in-game that would be useful in your project? [respect]


Top
 Profile  
 
 Post subject: Re: Script Question
PostPosted: Wed Feb 28, 2018 9:57 pm 
Offline
Hitman

Joined: Wed Dec 09, 2015 2:18 pm
Posts: 165
BeepBoop wrote:
Very Cool, I'll see if I can find anything else that is useful. Is there anything or addresses that you are looking for in-game that would be useful in your project? [respect]

Yes there are. The most important thing now for the progress of the project is to find an addres to the procedure for creating new car. Need to find a permanent address, how to call it through memory:
Code:
CAR_DATA car = CREATE_CAR (x, y, z) rotation color model END

And delete object:
Code:
DELETE_ITEM ( car )

Search the procedure you need in assembler code. The Sector wrote the memory address, where the current map is actually loaded with all SCR structures. viewtopic.php?f=4&t=1124#p10549

You also need a link to the name car, the current speed car. You can also find all the handling for car (speed, acceleration, mass, etc.). For the player, you can find a link to the structure of all his weapons. Number of continuations. Pager enable/disable (messanger). How to enable/disable the new gang counters. Also the address to display the dialog (address for show/hide/rewrite messange text). The address for label text in the menu.

If you find this it will be great.

_________________
Map F-Industry-Live
MISI Library

Twitter channel @TheNonameGames


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 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:  
Powered by phpBB® Forum Software © phpBB Group