Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

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

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

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

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

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

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

    2. Forum Support

    3. Suggestions

[DOC] LUA scripting help


FunGt
 Share

Recommended Posts

 

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
Link to comment
Share on other sites

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();

 

Link to comment
Share on other sites

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

 

Anyway, nothing works for me though...

Edited by Intosia
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

[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?

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

 

 

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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-
Link to comment
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"

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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

 

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

 

---------- 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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 ?

Link to comment
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
 Share

  • 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.