Script Question
Script Question
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.
Re: Script Question
Yes. It's possible.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.
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: Select all
-- 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
Last edited by Logofero on 28 Feb 2018, 15:19, edited 6 times in total.
Re: Script Question
I have seem to have found the address for [Last PED Touched] will post it in a bit.
Re: Script Question
Okay can confirm structure works for Last Ped Touched.
Address:
Ped Structure + Offset #1 = 0x138 + Offset #2 = 0x7C + Offset #3 = 0x216.
Address:
Ped Structure + Offset #1 = 0x138 + Offset #2 = 0x7C + Offset #3 = 0x216.
Re: Script Question
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.
Re: Script Question
Use the methods:BeepBoop wrote:Okay can confirm structure works for Last Ped Touched.
Address:
Ped Structure + Offset #1 = 0x138 + Offset #2 = 0x7C + Offset #3 = 0x216.
Code: Select all
local pointer = ReadProcessMemory(address, size) -- For read address (get pointer)
WriteProcessMemory(address, value, size) -- For write value in address
Re: Script Question
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/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.
Re: Script Question
BeepBoop, I checked your addresses today. Got a prototype of the GetPedTouch(ped)
Code: Select all
-- 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
Re: Script Question
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?
Re: Script Question
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: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?
Code: Select all
CAR_DATA car = CREATE_CAR (x, y, z) rotation color model END
Code: Select all
DELETE_ITEM ( car )
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.