Quantcast

Jump to content

» «
Photo

LUA Script: Change Speed of Game

4 replies to this topic
adhome
  • adhome

    Crackhead

  • Members
  • Joined: 06 Dec 2008

#1

Posted 23 December 2008 - 08:00 PM Edited by adhome, 24 December 2008 - 07:14 AM.

Hallo,

this is my first Mod (;
I tried the interesting Command "SET_TIME_SCALE".

Pressing Tab will change Game speed from Normal to Hi-Speed and then slow motion and back to normal.

To use this script, you need ALICE from this thread:
http://www.gtaforums...howtopic=386816

CODE
---------- GTA IV Alice "Speed" script ----------
 ---------- © Alexander Blade 2008 & Adhome----------
-- Change Speed key is TAB. Change betean Normal <> HI Speed <> Low Speed
--global variables
PLAYER_ID, PLAYER_INDEX, PLAYER_CHAR, SAVEDONE = 0
SPEEDF = 1.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 SetTimeScale()
if (SPEEDF == 1.0) then
 SPEEDF = 3.0
elseif (SPEEDF == 3.0) then
 SPEEDF = 0.4
elseif (SPEEDF == 0.4) then
 SPEEDF = 1.0
else
 SPEEDF = 1.0
end

PushFloat(SPEEDF)
CallNative("SET_TIME_SCALE")

end

function main()
 InitScript()
 while true do
   if (IsKeyPressed(9) == 1) then
  WaitForPlayerPoolCreation()
     WaitForValidPlayer()
     if (IsKeyPressed(9) == 1) then
    SetTimeScale()
    Wait(200)
  end
   end  
Wait(300)
 end
end

-- start
main();



All in one Pack:
adhome.kilu.de/Speed%20Change%20Mod.zip

rappzula
  • rappzula

    Player Hater

  • BUSTED!
  • Joined: 24 Mar 2008

#2

Posted 23 December 2008 - 11:06 PM

worked perfectly, thanks! smile.gif makes for good bullet time once in a while.
killing in slow motion is satisfying

adhome
  • adhome

    Crackhead

  • Members
  • Joined: 06 Dec 2008

#3

Posted 24 December 2008 - 07:28 AM Edited by adhome, 24 December 2008 - 07:33 AM.

Try a street race in Hi Speed (;

Now you can not say it's boring devil.gif

My first goal was to increase time/night cycle. Wants to see lots of sunraises.

(Hope some time we can spawn cars. With a loop i will spawn all possible cars in a raw).
Getting name of street function also looks interesting. Never mind, that each road could have differnt name.

Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci
  • Joined: 19 Aug 2006
  • Unknown
  • Contribution Award [Mods]

#4

Posted 24 December 2008 - 08:04 AM

Great script, but make a look to the following mistakes:
  • You have to post the finished scripts in Mod Showroom -> Mission Mods
  • You don't need to use the savedone = 0 global variable

adhome
  • adhome

    Crackhead

  • Members
  • Joined: 06 Dec 2008

#5

Posted 27 December 2008 - 07:28 PM

Sorry, perhaps a mod can move.

Here is a litle Modification. You press Tab und only 5sek. you are in Slow Motion. So, if you get in trouble or a crash, you can fast press tab und see the crash in slow motion.
The duration 5sek can easy be edited.

CODE
-- Change Speed key is TAB. Change betean Normal <> HI Speed <> Low Speed
--global variables
PLAYER_ID, PLAYER_INDEX, PLAYER_CHAR, SAVEDONE = 0
SPEEDF = 1.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 SetTimeScale(NewVal)
PushFloat(NewVal)
CallNative("SET_TIME_SCALE")

end


function main()
 InitScript()
 while true do
   if (IsKeyPressed(9) == 1) then
  WaitForPlayerPoolCreation()
     WaitForValidPlayer()
     if (IsKeyPressed(9) == 1) then
  SetTimeScale(0.3)
  Wait(5000)                 -- 5 Sek Slow Motion
  SetTimeScale(1.0)
  Wait(200)
      end
   end  
Wait(300)
 end
end

-- start
main();






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users