Script Question
Posted: 27 Feb 2018, 22:30
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.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.
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
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
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.
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
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 )