Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (86,159 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Forum Support

    2. Site Suggestions

BH Team

MoonLoader — Development

Recommended Posts

BH Team

I have a question about this,

 

  • 'moonloader\resource' - for all the resources used by scripts (textures, models, etc)

 

So it's possible to load models from \resource right? If so,could you show me a quick example of that.I'm a bit lost on how to do it.

No, it's just a standard directory to put all the script's resources, currently MoonLoader doesn't have native functionality to load custom models.

Share this post


Link to post
Share on other sites
Sanmodder

I wanted to do my first lua script
trainer with 5 commands
but I do not want to act and where to look for opcodes
and how to make it come back fo label
and what are the keys
I once repaired such a trainer for gta 4
but it was
ready source
I know that I did a lot of things wrong
I'm still learning
but I know very well on cleo script
help me

script_name("first lua trainer")script_authors("fan script")script_version_number(1)script_description("first lua")--- Configlocal bar_color = 0local bar_pos = 84.0local selected_items = 1    setGxtEntry("key_1", 	"add text")			--> null	setGxtEntry("key_2", 	"add text")			--> null	setGxtEntry("key_3", 	"add text")			--> null	setGxtEntry("key_4", 	"add text")			--> null	setGxtEntry("key_5", 	"add text")			--> null--- Mainfunction main()  while true do    wait(0)    if isPlayerPlaying(playerHandle) then    if isButtonPressed(playerHandle, 15) then -- sprint     break    end  endendendsetPlayerControl(playerHandle, false)function main()while true dowait(5)drawRect (float 90.0, 201.0 float, float 139.0, float 271.0, int y, int g, b int, int)drawRect (float 90.0, 79.0 float, float 140.0, float 1.0, int y, int g, b int, int)drawRect (float 90.0, 327.0 float, float 139.0, float 1.0, int y, int g, b int, int)setTextColour(255, 255, 255, 255)setTextScale(0.3, 0.8)setTextDropshadow(50, 50, 255, 255)displayText(23.0, 80.0, 'key_1')setTextColour(255, 255, 255, 255)setTextScale(0.3, 0.8)setTextDropshadow(50, 50, 255, 255)displayText(23.0, 89.0, 'key_2')setTextColour(255, 255, 255, 255)setTextScale(0.3, 0.8)setTextDropshadow(50, 50, 255, 255)displayText(23.0, 98.0, 'key_3')setTextColour(255, 255, 255, 255)setTextScale(0.3, 0.8)setTextDropshadow(50, 50, 255, 255)displayText(23.0, 107.0, 'key_4')setTextColour(255, 255, 255, 255)setTextScale(0.3, 0.8)setTextDropshadow(50, 50, 255, 255)displayText(23.0, 116.0, 'key_5')drawRect (float 90.0, bar_pos float, float 140.0, float 1.0, int y, int bar_color, b int, int)bar_color + 1if   bar_color > 255 then   bar_color = 0end   if    isButtonPressed(playerHandle, 16) then    if    selected_items == 5    then    wait(45)    selected_items = 1    bar_pos = 84.0    return    end    wait(45)    selected_items + 1    bar_pos + 9.0    returnendif  isButtonPressed(playerHandle, 16) then    if    selected_items == 1    then    wait(45)    selected_items = 5    bar_pos = 120.0    return    end    wait(45)    selected_items - 1    bar_pos - 9.0    returnend  if  isButtonPressed(playerHandle, 17) then    setPlayerControl(PLAYER_HANDLE, true)    return endif  selected_items == 1 then    if    isButtonPressed(playerHandle, 16) then    wait(5)    return    endend if  selected_items == 2 then    if    isButtonPressed(playerHandle, 16) then    wait(5)    return  endend if  selected_items == 3 then    if    isButtonPressed(playerHandle, 16) then    wait(5)    return  endend if  selected_items == 4 then    if    isButtonPressed(playerHandle, 16) then    wait(5)    return  endend  if  selected_items == 5 then    if    isButtonPressed(playerHandle, 16) then    wait(5)    return    endend endend

Share this post


Link to post
Share on other sites
jayd00

I'm confused with -As Pack- animation sequence, for some reason this code doesn't work:

script_name("testAnim")script_moonloader(025)require 'lib.moonloader'local vk = require 'lib.vkeys'local anim = {	pack = "DANCING",	--+-- JUMP animations	danceA  = "DNCE_M_A",	danceB   = "DAN_LOOP_A",	danceC  = "DNCE_M_D",}function loadAnimation(string)	if not hasAnimationLoaded(string) then		requestAnimation(string)		loadAllModelsNow()	endendfunction main()	while true do		if isPlayerPlaying(playerHandle) and wasKeyPressed(vk.VK_B) and wasKeyPressed(vk.VK_N) then			loadAnimation(anim.pack)			local taskDance = openSequenceTask()			taskPlayAnimNonInterruptable(-1, anim.danceA, anim.pack, 4.0, false, true, true, false, -1)			taskPlayAnimNonInterruptable(-1, anim.danceB, anim.pack, 4.0, false, true, true, false, -1)			taskPlayAnimNonInterruptable(-1, anim.danceC, anim.pack, 4.0, false, true, true, false, -1)			setSequenceToRepeat(taskDance, true)			closeSequenceTask(taskDance)			performSequenceTask(playerPed, taskDance)			printString("dancing...", 1000)			wait(1500)			repeat				wait(0)			until wasKeyPressed(vk.VK_M)			clearSequenceTask(taskDance)			clearCharTasks(playerPed)			printString("STOP...", 1000)			wait(1500)		end		wait(0)	endend

But if I use a simple animation it works:

function main()	while true do		if isPlayerPlaying(playerHandle) and wasKeyPressed(vk.VK_B) and wasKeyPressed(vk.VK_N) then			loadAnimation(anim.pack)			taskPlayAnimNonInterruptable(playerPed, anim.danceB, anim.pack, 16.0, true, true, true, false, -1)			printString("dancing...", 1000)			wait(1500)			repeat				wait(0)			until wasKeyPressed(vk.VK_M)			clearCharTasks(playerPed)			printString("STOP...", 1000)			wait(1500)		end		wait(0)	endend

am I wrong? there is something in lua that I have to know about this?

thanks :cookie::cookie:

Share this post


Link to post
Share on other sites
Reameb

Ok so i have been trying to do this project i have in mind and it needs pickups.

 

Have been making it in cleo and talked to silent, he said that pickups created with cleo stay on the savegame, even after removing the script, so i made the script again, this time in lua, and it happens again, does anyone know a way to avoid this?

Share this post


Link to post
Share on other sites
goodidea82

In cleo I did it the following, probably you can do it in lua the same.

 

 

In my Camping Mobile Safehouse mod version 1 I deleted the pickup every time when the save screen appearch. In version 2 of the mod, it is created either as a pickup or as an object. This is controlled by the USE_PICKUP_Bit in the script below

 

:CREATE_SAVE_DISK_W    if        08B7:   test SCRIPT_FLAGS bit USE_PICKUP_Bit    then        ////0662: write_debug_message "CREATE DISK PICKUP"        0213: DISK_PICKUP_HANDLE = create_pickup DISK_PICKUP_ID type 3 at CARX CARY CARZ        0AB1: call_scm_func @Pickup2Object 1 DISK_PICKUP_HANDLE DISK_PICKUP_OBJECT    else        ////0662: write_debug_message "CREATE DISK OBJ"        Object.Create(DISK_PICKUP_HANDLE, DISK_PICKUP_ID, CARX, CARY, CARZ)        Object.RemoveReferences(DISK_PICKUP_HANDLE)        Object.CollisionDetection(DISK_PICKUP_HANDLE) = False        Object.ToggleInMovingList(DISK_PICKUP_HANDLE) = True        DISK_PICKUP_OBJECT = DISK_PICKUP_HANDLE            end.....if    not DISK_PICKUP_HANDLE == 0 then        if            03CA:   object DISK_PICKUP_HANDLE exists        then            if                 08B7:   test SCRIPT_FLAGS bit USE_PICKUP_Bit            then                ////0662: write_debug_message "Destroy pickup"                0215: destroy_pickup DISK_PICKUP_HANDLE                ////0662: write_debug_message "Destroyed"            else                ////0662: write_debug_message "Destroy object"                Object.Destroy(DISK_PICKUP_HANDLE)                                end        end        DISK_PICKUP_HANDLE = 0        DISK_PICKUP_OBJECT = 0          ////0662: write_debug_message "MS6: pickup handle destroyed"           end
And the function Pickup2Object is defined here:

 

//---------------------------------------------------------------------------------//Utility function. Taken from http://www.gtamodding.com/index.php?title=Pickup_to_object:Pickup2Object    if        08B7:   test SCRIPT_FLAGS bit USE_PICKUP_Bit    then        //0662: write_debug_message "Warning:Pickup2Obj A"        wait 1000        end    // [email protected] - input param (pickup handle)    // get pickup pointer    0085: [email protected] = [email protected]     0A91: [email protected] = [email protected] / 65536    0A90: [email protected] = [email protected] * 65536    0062: [email protected] -= [email protected]    [email protected] *= 32    [email protected] += 0x9788C0    // read index    0A8E: [email protected] = [email protected] + 0x1A    0A8D: [email protected] = read_memory [email protected] size 2 virtual_protect 0    if        003B: [email protected] == [email protected]    then            // obtain pickup's object pointer        [email protected] += 4        0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0        if            [email protected] > 0        then            // convert object pointer to a handle            0A8D: [email protected] = read_memory 0xB7449C size 4 virtual_protect 0            0AA8: call_function_method 0x465070 struct [email protected] num_params 1 pop 0 [email protected] [email protected]            if                03CA:   object [email protected] exists             then                0485: return_true                0AB2: ret 1 [email protected]            end        end    end    059A: return_false0AB2: ret 1 [email protected]

 

Edited by goodidea82

Share this post


Link to post
Share on other sites
BH Team

Ok so i have been trying to do this project i have in mind and it needs pickups.

 

Have been making it in cleo and talked to silent, he said that pickups created with cleo stay on the savegame, even after removing the script, so i made the script again, this time in lua, and it happens again, does anyone know a way to avoid this?

I'll try to figure out how to disable auto saving of script entities. For now, yes, as goodidea82 said, the only way to prevent that is to destroy unwanted stuff during game saving.

Share this post


Link to post
Share on other sites
guru_guru

If Google Translate doesn't fail me :p , it says here that is better to use FFI instead of callMethod for perfomance reasons.

 

Could you give an example of this?

Share this post


Link to post
Share on other sites
BH Team
Posted (edited)

If Google Translate doesn't fail me :p , it says here that is better to use FFI instead of callMethod for perfomance reasons.

 

Could you give an example of this?

Here is an example of obtaining the world coordinates of a character's bone:

local ffi = require "ffi"local getBonePosition = ffi.cast("int (__thiscall*)(void*, float*, int, bool)", 0x5E4280)function getCharBoneCoordinates(ped, bone)  local coords = ffi.new("float[3]", {})  local pped = ffi.cast("void*", getCharPointer(ped))  getBonePosition(pped, coords, bone, true)  return vec[0], vec[1], vec[2]end

More about FFI: http://luajit.org/ext_ffi_api.html

Edited by BH Team

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.