Quantcast

Jump to content

» «
Photo

LUA TUTORIAL

4 replies to this topic
-TRASE-
  • -TRASE-

    Punk-ass Bitch

  • Members
  • Joined: 07 Feb 2008

#1

Posted 23 December 2008 - 11:29 AM Edited by -TRASE-, 23 December 2008 - 01:53 PM.

ok, unless someone post a tutorial, i will update this post when i find somthing useful!


YYYES!
Finally got somthing working!
Press TAB and your wanted level is clear.
http://ifolder.ru/9703915

Solving problems
Ok, i found some sort of a tutorial, i will post it here, ile try to figure it out! [HEhe, ROckstar, i dont need your DLC smile.gif we will have somthing cooler, and for FREE]

QUOTE
† GTA IV has many script functions called "Native API" or "natives".
† Alice lua script can call any of this functions from itself.
† Everyone who knows something about assembler and function call
† concept will understand all this native-sh1t what i wrote below
† without any problems :
† [!!! its recomended to look at examples and read this at one time]
† ----- General functions -----
†† To push integer/float parameter into the calling native func use
† †† PushInt(Value) / PushFloat(Value)
†† To push script pointer use
† †† PushVarPtr() -- no params, if native changes pushed value
† † -- u must use this function and after native
† † † † † † † † † -- calling read the value of this variable
†† To get integer/float param from stack after native call use
† †† Value = GetIntParam(ParamNumber) /
† †† Value = GetFloatParam(ParamNumber)
†† To get the integer/float result of function (if exists) use
† †† Val = GetIntResult() / Val = GetFloatResult()†
†† At least, to call native function use
† †† CallNative("NATIVE_FUNCTION_NAME") -- names are declared in
† †† -- other files
† †† (WARNING : You can't use functions which operate with models,
† † † † † † † † and now i don't know what is the reason of this .)
†† ----- Other needed functions (not for natives) -----
†† Game must be started to use native functions, so we need a check:
† †† bool IsPlayerPoolCreated() -- if player pool is ok then we can
† † -- use some native functions
† †† bool IsKeyPressed(AnsiKeyNum) -- checking any ansi key state
† †† Wait(Milliseconds) -- stops script for a needed time
† †† PrintFloatToLog(Value) / PrintStrToLog("STRING") -- prints
† † † † † † -- to log
† ††
†† ----- Call example -----
† † † --† GET_PLAYER_CHAR(0, &Var)
† † † --† declarations of functions u will see soon ,
† † † --† and now look at additional files†
† † † PushInt(0) -- 0 param
† † † PushVarPtr() -- 1 param (this is our &Var)
† † † CallNative("GET_PLAYER_CHAR") -- making a call
† † † PLAYER_CHAR = GetIntParam(1) -- reading the value
† † †† -- from 1 parameter

†† ----- Player structure organization -----
† † † int GET_PLAYER_ID() -- get player id , using only for getting
† † † † † † † † † † † † † -- results of next functions
† † † † † † † † † † † † † --† (always 0 in single player mode);
† † † int CONVERT_INT_TO_PLAYERINDEX( GET_PLAYER_ID() ) -- get player
† † † † † †† -- index from id , this is player definition variable
† † † † † †† -- (in SA was $PLAYER_CHAR) (always 0 in single player mode);
† † † GET_PLAYER_CHAR( CONVERT_INT_TO_PLAYERINDEX( GET_PLAYER_ID() ), &PlayerChar )
† † † † † †† -- get player char from player index , this is "player as ped/actor"
† † † † † †† -- definition variable (in SA was $PLAYER_ACTOR);


" I wasted 2 days to fill free with lua coding , it's not so hard as you thought ." - says the author.

Dont forget to say Thanks to these guys!
QUOTE
4. About :
† † Authors : Alexander /Alexander Blade / Alexander Koryakin ,
† † †† flacs
†† THX 2 :† † GooD, Listener, Seemann, Sacky, Lua developers ...

wait... GooD? i know this guy!

edit: i dont know how, but i have a pool cue now

~Rick
  • ~Rick

    gibbed

  • Members
  • Joined: 25 Sep 2003

#2

Posted 23 December 2008 - 11:49 AM

Don't call native functions without first looking at how to use them. Pushing a single argument to a native that takes two is a bit iffy you know. anuj_cop.gif

In the case of DONT_DISPATCH_COPS_FOR_PLAYER, it takes two arguments.

Try:
CODE
PushInt(PLAYER_INDEX)
PushInt(1)
CallNative("SET_PLAYER_INVINCIBLE")


Or:
CODE
PushInt(1)
PushInt(PLAYER_INDEX)
CallNative("SET_PLAYER_INVINCIBLE")



And this isn't a lua tutorial.

-TRASE-
  • -TRASE-

    Punk-ass Bitch

  • Members
  • Joined: 07 Feb 2008

#3

Posted 23 December 2008 - 11:59 AM

I know nothing about the LUA coding, but im a fast learner smile.gif

i need a script, when you press a button, a selected native function activates, can you help me?

~Rick
  • ~Rick

    gibbed

  • Members
  • Joined: 25 Sep 2003

#4

Posted 23 December 2008 - 12:05 PM

The examples provided should suffice.

LunR
  • LunR

    Player Hater

  • Members
  • Joined: 18 Jan 2009

#5

Posted 19 January 2009 - 12:30 AM

I installed afew lua and asi script things but now its telling me just after the loading screen something about 'Lua-native player id' and then gta just closes.
Wat the hell is goin on?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users