Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
      4. Frontier Pursuits
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

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

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

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

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

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

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

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. 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. 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. News

    2. Forum Support

    3. Site Suggestions

FunGt

[DOC] LUA scripting help

Recommended Posts

FunGt

 

GK: Please post any help relating to LUA here, any topics that arent posted here will be locked.-no requests thanks

 

 

Post here problems releated to LUA, the new script language that we can use with Alice by Alexander. I'm not the one that can help, I created this topic to keep the forum tidy.

 

 

Useful links:

Edited by FunGt

Share this post


Link to post
Share on other sites
Ricksta

Ok i am trying to make a gravity toggle, this is as far as I have got but it only turns gravity off when I press tab, it doesn't turn it back off when i press tab again.

 

Note: Template was from TRASE's clear wanted level script.

 

 

 

---------- GTA IV Alice "Clear Wanted Level" script example -------------------- © -TR45e- 2008 ------------ Save key is TAB--global variablesPLAYER_ID, PLAYER_INDEX, PLAYER_CHAR, SAVEDONE, TIMER = 0function InitScript()-- blah-blah-blahWait(10000)endfunction WaitForPlayerPoolCreation()while (IsPlayerPoolCreated() == 0) do Wait(2000)endendfunction WaitForValidPlayer()PLAYER_CHAR = 0repeat CallNative("GET_PLAYER_ID")PLAYER_ID = GetIntResult()if (PLAYER_ID >= 0) thenPushInt(PLAYER_ID)CallNative("CONVERT_INT_TO_PLAYERINDEX")PLAYER_INDEX = GetIntResult()PushInt(PLAYER_INDEX)   PushVarPtr()CallNative("GET_PLAYER_CHAR")PLAYER_CHAR = GetIntParam(1)if (PLAYER_CHAR <= 0) then  Wait(1000)end  enduntil (PLAYER_CHAR > 0)  endfunction gravityon()SAVEDONE = 0TIMER = 0PushInt(1)CallNative("SET_GRAVITY_OFF")Wait(1000)while (SAVEDONE == 0) and (TIMER < 10000) do TIMER = TIMER + 100Wait(100)SAVEDONE = GetIntResult()endendfunction gravityoff()SAVEDONE = 0TIMER = 0PushInt(0)CallNative("SET_GRAVITY_OFF")Wait(1000)while (SAVEDONE == 0) and (TIMER < 10000) do TIMER = TIMER + 100Wait(100)SAVEDONE = GetIntResult()endendfunction main()InitScript()while true do if (IsKeyPressed(9) == 1) thenWaitForPlayerPoolCreation()   WaitForValidPlayer()   if (IsKeyPressed(9) == 1) then  gravityon()  Wait(10)end end  Wait(10)endendfunction main()InitScript()while true do if (IsKeyPressed(9) == 1) thenWaitForPlayerPoolCreation()   WaitForValidPlayer()   if (IsKeyPressed(9) == 1) then  gravityon()  Wait(10)end end  Wait(10)endend-- startmain();

 

Share this post


Link to post
Share on other sites
Intosia

You cant have 2 Main() functions....

 

Anyway, nothing works for me though...

Edited by Intosia

Share this post


Link to post
Share on other sites
-TRASE-

Ok. i want to ask about Natives.

 

When i see

 

SET_PLAYER_INVINCIBLE=[size=7]2[/size], False

 

 

this mean in the script there needs to be two PushInt?

 

and what do false/true mean? if TRUE is it mean that i can toggle it on or off?

Share this post


Link to post
Share on other sites
aceship

[Q]:If I want Spawn something, Ex: Ctrl+1 To get A weapon,What code did i use?

 

[Q|2]:What is the List Of the Pressed Key?

Share this post


Link to post
Share on other sites
-TRASE-

Ricksta, add another function to enable the gravity

 

 

 

Share this post


Link to post
Share on other sites
Intosia
Ok. i want to ask about Natives.

 

When i see

 

SET_PLAYER_INVINCIBLE=[size=7]2[/size], False

 

 

this mean in the script there needs to be two PushInt?

 

and what do false/true mean? if TRUE is it mean that i can toggle it on or off?

I can be Int or Floats. The first would be Player_ID, the second a Int (True/False). But you can only guess what the params should be i guess...

 

That True or False means if the function returns a value or not. Its all in the Readme.txt btw...

Share this post


Link to post
Share on other sites
Ricksta
Ricksta, add another function to enable the gravity

How? I'm thick as sh*t!

I don't even see a D or 13 for TAB on you're script so how are you even using TAB to get rid of the police? sad.gif this is hard.

Share this post


Link to post
Share on other sites
sjaak327

IsKeyPressed(9) is the part where you define the key in this case tab =9, for instance backspace would be 8 if I'm not mistaken.

 

That code might need to be cleaned up, as there are still parts of the orignal save function there that surely aren't needed to clear your wanted level smile.gif

 

 

 

 

Share this post


Link to post
Share on other sites
FunGt
IsKeyPressed(9) is the part where you define the key in this case tab =9, for instance backspace would be 8 if I'm not mistaken.

 

That code might need to be cleaned up, as there are still parts of the orignal save function there that surely aren't needed to clear your wanted level smile.gif

Where can I find the list of IsKeyPressed numbers? How can I know what number to choose for a keyboard button?

Share this post


Link to post
Share on other sites
-TRASE-

Turning gravity is sure working, and its f*cking hilarius! biggrin.gifbiggrin.gifbiggrin.gifbiggrin.gif but i cant turn it off... i used

 

 

function gravon() PushInt(1)  CallNative("SET_GRAVITY_OFF") Wait(1000)endfunction Sgravoff() PushInt(0)  CallNative("SET_GRAVITY_OFF") Wait(1000)end

 

 

gravoff didnt work. no lua errors

Edited by -TRASE-

Share this post


Link to post
Share on other sites
Alexander Blade
IsKeyPressed(9) is the part where you define the key in this case tab =9, for instance backspace would be 8 if I'm not mistaken.

 

That code might need to be cleaned up, as there are still parts of the orignal save function there that surely aren't needed to clear your wanted level smile.gif

Where can I find the list of IsKeyPressed numbers? How can I know what number to choose for a keyboard button?

try to search for "Virtual Key Codes"

Share this post


Link to post
Share on other sites
Flaii
Turning gravity is sure working, and its f*cking hilarius! biggrin.gifbiggrin.gifbiggrin.gifbiggrin.gif but i cant turn it off... i used

 

 

function gravon() PushInt(1)  CallNative("SET_GRAVITY_OFF") Wait(1000)endfunction Sgravoff() PushInt(0)  CallNative("SET_GRAVITY_OFF") Wait(1000)end

 

 

gravoff didnt work. no lua errors

Can you post the full code?

 

I want to try it out and see how its built.

Share this post


Link to post
Share on other sites
adhome

Perhaps we can fist find out, how to spawn a car (by Name or index)

 

I found this interesting functions:

GET_SPAWN_COORDINATES_FOR_CAR_NODE=6, False

GET_CAR_MODEL=2, False

CREATE_CAR=6, False

GET_RANDOM_CAR_NODE=9, True

GET_RANDOM_CAR_MODEL_IN_MEMORY=3, False

 

CREATE_CAR_GENERATOR=15, False is perhaps to complicated.

Edited by adhome

Share this post


Link to post
Share on other sites
aceship

Doesn't work

 

---------- GTA IV Alice "WeaponSpawn" script example ----------

---------- © Alexander Blade 2008 ----------

--Numpad 1 to spawn weapon

--global variables

  PLAYER_ID, PLAYER_INDEX, PLAYER_CHAR = 0

 

function InitScript()

  -- blah-blah-blah

  Wait(10000)

end

 

function WaitForPlayerPoolCreation()

  while (IsPlayerPoolCreated() == 0) do

    Wait(2000)

  end

end

 

function WaitForValidPlayer()

  PLAYER_CHAR = 0

  repeat

    CallNative("GET_PLAYER_ID")

PLAYER_ID = GetIntResult()

if (PLAYER_ID >= 0) then

  PushInt(PLAYER_ID)

  CallNative("CONVERT_INT_TO_PLAYERINDEX")

  PLAYER_INDEX = GetIntResult()

  PushInt(PLAYER_INDEX)

      PushVarPtr()

  CallNative("GET_PLAYER_CHAR")

  PLAYER_CHAR = GetIntParam(1)

  if (PLAYER_CHAR <= 0) then

    Wait(1000)

  end 

end

  until (PLAYER_CHAR > 0) 

end

 

function SetPlayerProperties()

  PushInt(PLAYER_INDEX)

  PushInt(1)

  CallNative("ENABLE_MAX_AMMO_CAP")

  GiveWeapon(6)

end

 

function main()

  InitScript()

  while true do

    if (IsKeyPressed(60) == 1) then

  WaitForPlayerPoolCreation()

    WaitForValidPlayer()

    if (IsKeyPressed(60) == 1) then

    giveweapon()

    Wait(2000)

  end

  end 

Wait(300)

end

end

 

-- start

main();

Doesn't do anything

 

Share this post


Link to post
Share on other sites
Andrew

Good idea FunGT. I've edited the top post to mention that any outside of this topic get locked.

Share this post


Link to post
Share on other sites
alecto123
Turning gravity is sure working, and its f*cking hilarius!  biggrin.gif  biggrin.gif  biggrin.gif  biggrin.gif  but i cant turn it off... i used

 

 

function gravon() PushInt(1)  CallNative("SET_GRAVITY_OFF") Wait(1000)endfunction Sgravoff() PushInt(0)  CallNative("SET_GRAVITY_OFF") Wait(1000)end

 

 

gravoff didnt work. no lua errors

Can you post the full code?

 

I want to try it out and see how its built.

Maybe it would work if you create a separate script to enable gravity using a different key.

 

Share this post


Link to post
Share on other sites
berbatov

"ENABLE_SHADOWS=$009b9eb0" in natives config file..

 

so is there a way closing shadows now pls ? ( i have no idea lua scripting smile.gif )

Share this post


Link to post
Share on other sites
aceship

Yes!My Weapon Spawner Are Completed!

If you Want It ,Just Say,I don Want Banned

Share this post


Link to post
Share on other sites
Flaii
Yes!My Weapon Spawner Are Completed!

If you Want It ,Just Say,I don Want Banned

I'm interested, post it here or send me a PM with it, thanks!

Share this post


Link to post
Share on other sites
aceship

 

---------- GTA IV Alice "WeaponSpawn" script example ----------

---------- © Alexander Blade 2008 ----------

--middle button to spawn weapon

--global variables

  PLAYER_ID, PLAYER_INDEX, PLAYER_CHAR = 0

 

function InitScript()

  -- blah-blah-blah

  Wait(10000)

end

 

function WaitForPlayerPoolCreation()

  while (IsPlayerPoolCreated() == 0) do

    Wait(2000)

  end

end

 

function WaitForValidPlayer()

  PLAYER_CHAR = 0

  repeat

    CallNative("GET_PLAYER_ID")

PLAYER_ID = GetIntResult()

if (PLAYER_ID >= 0) then

  PushInt(PLAYER_ID)

  CallNative("CONVERT_INT_TO_PLAYERINDEX")

  PLAYER_INDEX = GetIntResult()

  PushInt(PLAYER_INDEX)

      PushVarPtr()

  CallNative("GET_PLAYER_CHAR")

  PLAYER_CHAR = GetIntParam(1)

  if (PLAYER_CHAR <= 0) then

    Wait(1000)

  end 

end

  until (PLAYER_CHAR > 0) 

end

 

function GiveWeapon(Num)

  PushInt(PLAYER_CHAR)

  PushInt(Num)

  CallNative("HAS_CHAR_GOT_WEAPON")

  if (GetIntResult() == 0)

  then

    PushInt(PLAYER_CHAR)

    PushInt(Num)

    PushInt(30000)

    PushInt(0)

    CallNative("GIVE_WEAPON_TO_CHAR")

  else

    PushInt(PLAYER_CHAR)

PushInt(Num)

PushInt(30000)

CallNative("SET_CHAR_AMMO")

  end

end

 

function SetPlayerProperties()

  PushInt(PLAYER_INDEX)

  PushInt(0)

  CallNative("ENABLE_MAX_AMMO_CAP")

  GiveWeapon(6)

end

 

function main()

  InitScript()

  while true do

    if (IsKeyPressed(04) == 1) then

  WaitForPlayerPoolCreation()

      WaitForValidPlayer()

      if (IsKeyPressed(04) == 1) then

    SetPlayerProperties()

    Wait(2000)

  end

    end 

Wait(300)

  end

end

 

-- start

main();

 

if you want

Chance Giveweapon(Num)

Num:

 

Giveweapon(num)

1:Baseball bat

2:Pool Cue

3:Knife

4:Grenade

5:Molotov

6:Rocket

7:Glock Pistol

8:don't know yet

9:deagle

10:Shotgun

11:barreta shotgun

12:uzi

13:mp5

14:ak

Edit:

15:m4

16:Sniper rifle

17:M401a Sniper

18:rocket launcher

 

Thanks for ilidan for the quick respond

 

Edit:

 

21:episodic_1

|       

44:episodic_24

 

 

Edited by aceship

Share this post


Link to post
Share on other sites
FunGt

 

Yes!My Weapon Spawner Are Completed!

If you Want It ,Just Say,I don Want Banned

Upload here.

Share this post


Link to post
Share on other sites
aceship

already Posted,

[Q]how to change The ammo,it seems to be unlimited when use it

[Q2]Can i use a combo like this?:

(IsKeyPressed(11) == 1) And (IsKeyPressed(30) == 1) then

Oh,Can Anyone search the Unused0 and episodic_1-24 Weapon code?

It can be a discovery for who Editing the weapon

 

Edited by aceship

Share this post


Link to post
Share on other sites
adhome

Found SET_TIME_SCALE and I set it to 10.0

It wasa great. You run very fast and alle Cars drive fast and so....

With low parameter all was in slow motion. Looks very great.

 

I tried a script with float variable. But i get allways error 1 on start game.

 

How can i use float variable ?

 

 

DELETED beacause it was wrong

 

 

PushFloat(2.0)

CallNative("SET_TIME_SCALE")

 

was working!

Edited by adhome

Share this post


Link to post
Share on other sites
aceship

I think You should change The "Save everywhere" Title,It can Make People Confused,

Edit:

What is"EXPLODE_CHAR_HEAD"

Is this exploding the character Head?

it will Be a ZOMBIE Game!

Edited by aceship

Share this post


Link to post
Share on other sites
Shadow-Link

Does anyone know how to get the Car the player is currently driving?

 

I've tried this code:

 

function getPlayerCar() PLAYER_CAR = 0 repeat   PushInt(PLAYER_CHAR)   PushVarPtr()   CallNative("GET_CAR_CHAR_IS_USING")   PLAYER_CAR = GetIntParam(1)   if (PLAYER_CAR <= 0) then     Wait(1000)   end until (PLAYER_CAR > 0)end

 

 

With a global var: PLAYER_CAR

 

EDIT: Nevermind it works smile.gif

Edited by Prince-Link

Share this post


Link to post
Share on other sites
BeatFK

aceship, I don't understand exactly how your LUA works.

 

 

I have created a "WeaponSpawn.lua" in my Alice folder and copy your code inside

 

 

and then what do I have to do ?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

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