Home / Forums / Modders Corner / Mafia Editing / Mafia II mods / LUA script (Entity)

LUA script (Entity)

Home / Forums / Modders Corner / Mafia Editing / Mafia II mods / LUA script (Entity)

10 replies
13 years, 1 month ago
#6448

Hello. I’ve got problem. I want to make LUA script to add NPCs, but it looks like it’s not working. Can somebody please help?

 

Here’s my script (to add Bomber in front of Vito’s Villa):

game.sds:ActivateStreamMapLine("fr_bomber_m01_load")



game.entitywrapper:GetEntityByName("enemy1"):Activate()

game.entitywrapper:GetEntityByName("enemy1"):SetPos(Math:newVector( -1315, 1005,-19))

game.entitywrapper:GetEntityByName("enemy1"):SetDir(Math:newVector( 0,-1,0))

game.entitywrapper:GetEntityByName("enemy1"):InventoryAddWeapon(5,92)

game.entitywrapper:GetEntityByName("enemy1"):Attack(game.game:GetActivePlayer())
13 years, 1 month ago
#16538

Sorry, i canôt help you. I even tried scripting myself but run into trouble sometimes, but i would like to use this lua script if you get it working <img decoding=” data-emoticon=”” srcset=”/wp-content/uploads/invision_emoticons/smile@2x.png 2x” width=”20″ height=”20″>

13 years, 1 month ago
#16539

Sorry’ date=’ i canôt help you. I even tried scripting myself but run into trouble sometimes, but i would like to use this lua script if you get it working <img decoding=” data-emoticon=”” srcset=”/wp-content/uploads/invision_emoticons/smile@2x.png 2x” width=”20″ height=”20″> [/quote’] 

Use it If you want to. I think what I wrote is absolutely wrong, but maybe I just did small mistake somewhere.

13 years ago
#16567

It is normal that it does not work.

in your script, all command is activated directly. one after the other but very quickly.

 

But StreamMapLine activation requires some time to be fully activated before activation NPC.

 

test this : NPC activation is effected three seconds after

game.sds:ActivateStreamMapLine(“fr_bomber_m01_load”) 

DelayBuffer:Insert(function(l_1_0)

game.entitywrapper:GetEntityByName(“enemy1”):Activate()

game.entitywrapper:GetEntityByName(“enemy1”):SetPos(Math:newVector( -1315, 1005,-19))

game.entitywrapper:GetEntityByName(“enemy1”):SetDir(Math:newVector( 0,-1,0))

game.entitywrapper:GetEntityByName(“enemy1”):InventoryAddWeapon(5,92)

game.entitywrapper:GetEntityByName(“enemy1”):Attack(game.game:GetActivePlayer())

end,{l_1_0},3000,1,false)

13 years ago
#16573

Many many thanks. Now I understand how it works, but there is still a problem with my Lua Script injector (I’ve got version v6). This script crashes 3 seconds after activation. Maybe the scripts needs more time to load or something.

13 years ago
#16574

test this

 

DelayBuffer:Insert(function(l_1_0)

CommandBuffer:Insert(l_1_0,{

function(l_1_0)return game.sds:ActivateStreamMapLine(“fr_bomber_m01_load”)end,

function(l_2_0)

game.entitywrapper:GetEntityByName(“enemy1”):Activate()

game.entitywrapper:GetEntityByName(“enemy1”):SetPos(Math:newVector(-1315, 1005,-19))

game.entitywrapper:GetEntityByName(“enemy1”):SetDir(Math:newVector( 0,-1,0))

game.entitywrapper:GetEntityByName(“enemy1”):InventoryAddWeapon(5,92)

game.entitywrapper:GetEntityByName(“enemy1”):Attack(game.game:GetActivePlayer())

end})

end,{l_1_0},100,1,false)

 

one thing, the injector has not been improved since December 2010.

13 years ago
#16575

It’s not working. The problem has to be somewhere else. Is that script working in FR JA v3.0?

13 years ago
#16577

Ok, so this is not working in FR JA? Is there any other way how to add entities (NPCs) to FR JA 3.0? I think the problem might be in file size limitation.

13 years ago
#16578
13 years ago
#16596

you can not add like that NPCs in FR.

 

“StreamMapLine” : These commands are used to enable different chapter and sub-chapter of the game or DLC.

but after you are no longer in the FR. it is not that simple, to use it.

  • You must be logged in to reply to this topic.