FunGt Posted December 23, 2008 Share Posted December 23, 2008 (edited) 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: LUA Wiki IsKeyPressed Code List Edited July 5, 2009 by FunGt Link to comment Share on other sites More sharing options...
Ricksta Posted December 23, 2008 Share Posted December 23, 2008 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 More sharing options...
Intosia Posted December 23, 2008 Share Posted December 23, 2008 (edited) You cant have 2 Main() functions.... Anyway, nothing works for me though... Edited December 23, 2008 by Intosia Link to comment Share on other sites More sharing options...
-TRASE- Posted December 23, 2008 Share Posted December 23, 2008 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 More sharing options...
aceship Posted December 23, 2008 Share Posted December 23, 2008 [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 More sharing options...
-TRASE- Posted December 23, 2008 Share Posted December 23, 2008 Ricksta, add another function to enable the gravity Link to comment Share on other sites More sharing options...
Intosia Posted December 23, 2008 Share Posted December 23, 2008 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 More sharing options...
Ricksta Posted December 23, 2008 Share Posted December 23, 2008 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? this is hard. Link to comment Share on other sites More sharing options...
sjaak327 Posted December 23, 2008 Share Posted December 23, 2008 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 Link to comment Share on other sites More sharing options...
FunGt Posted December 23, 2008 Author Share Posted December 23, 2008 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 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 More sharing options...
-TRASE- Posted December 23, 2008 Share Posted December 23, 2008 (edited) Turning gravity is sure working, and its f*cking hilarius! 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 December 23, 2008 by -TRASE- Link to comment Share on other sites More sharing options...
Alexander Blade Posted December 23, 2008 Share Posted December 23, 2008 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 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 More sharing options...
Flaii Posted December 23, 2008 Share Posted December 23, 2008 Turning gravity is sure working, and its f*cking hilarius! 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 More sharing options...
ZomBuster Posted December 23, 2008 Share Posted December 23, 2008 No wait this is what you need for the keys http://delphi.about.com/od/objectpascalide/l/blvkc.htm Link to comment Share on other sites More sharing options...
adhome Posted December 23, 2008 Share Posted December 23, 2008 (edited) 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 December 23, 2008 by adhome Link to comment Share on other sites More sharing options...
aceship Posted December 23, 2008 Share Posted December 23, 2008 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 More sharing options...
Andrew Posted December 23, 2008 Share Posted December 23, 2008 Good idea FunGT. I've edited the top post to mention that any outside of this topic get locked. Link to comment Share on other sites More sharing options...
alecto123 Posted December 23, 2008 Share Posted December 23, 2008 Turning gravity is sure working, and its f*cking hilarius! 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 More sharing options...
Intosia Posted December 23, 2008 Share Posted December 23, 2008 No wait this is what you need for the keys http://delphi.about.com/od/objectpascalide/l/blvkc.htm Watched out those codes are in HEX make em DEC Link to comment Share on other sites More sharing options...
berbatov Posted December 23, 2008 Share Posted December 23, 2008 "ENABLE_SHADOWS=$009b9eb0" in natives config file.. so is there a way closing shadows now pls ? ( i have no idea lua scripting ) Link to comment Share on other sites More sharing options...
aceship Posted December 23, 2008 Share Posted December 23, 2008 Yes!My Weapon Spawner Are Completed! If you Want It ,Just Say,I don Want Banned Link to comment Share on other sites More sharing options...
Flaii Posted December 23, 2008 Share Posted December 23, 2008 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 More sharing options...
aceship Posted December 23, 2008 Share Posted December 23, 2008 (edited) ---------- 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 December 28, 2008 by aceship Link to comment Share on other sites More sharing options...
FunGt Posted December 23, 2008 Author Share Posted December 23, 2008 Yes!My Weapon Spawner Are Completed!If you Want It ,Just Say,I don Want Banned Upload here. Link to comment Share on other sites More sharing options...
aceship Posted December 23, 2008 Share Posted December 23, 2008 (edited) 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 December 23, 2008 by aceship Link to comment Share on other sites More sharing options...
adhome Posted December 23, 2008 Share Posted December 23, 2008 (edited) 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 December 23, 2008 by adhome Link to comment Share on other sites More sharing options...
aceship Posted December 23, 2008 Share Posted December 23, 2008 (edited) 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 December 23, 2008 by aceship Link to comment Share on other sites More sharing options...
Shadow-Link Posted December 23, 2008 Share Posted December 23, 2008 (edited) 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 Edited December 23, 2008 by Prince-Link Link to comment Share on other sites More sharing options...
adhome Posted December 23, 2008 Share Posted December 23, 2008 (edited) Found my misstake. In Top I must write "=0" I will release a corrected version in other Forum. Will look and feel great (; http://www.gtaforums.com/index.php?showtopic=386995 Edited December 23, 2008 by adhome Link to comment Share on other sites More sharing options...
BeatFK Posted December 23, 2008 Share Posted December 23, 2008 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now