Jump to content

[Q] Change camera via lua-script?


Recommended Posts

Hello,

To get the game's camera ID use this :

 

PushVarPtr()CallNative("GET_GAME_CAM_CHILD")IDCam = GetIntParam(0)

 

then use "SET_CAM_ROT" like that :

 

PushInt(IDCam)PushFloat(AngleX)PushFloat(AngleY)PushFloat(AngleZ)CallNative("SET_CAM_ROT")

 

Thank you very much! You couldn't write a script for me that centers the camera, could you?! smile.gif I have no idea of lua. sad.gif

Hello,

To get the game's camera ID use this :

 

PushVarPtr()CallNative("GET_GAME_CAM_CHILD")IDCam = GetIntParam(0)

 

then use "SET_CAM_ROT" like that :

 

PushInt(IDCam)PushFloat(AngleX)PushFloat(AngleY)PushFloat(AngleZ)CallNative("SET_CAM_ROT")

 

Please, could someone help with this? smile.gif

Hello,

To get the game's camera ID use this :

 

PushVarPtr()CallNative("GET_GAME_CAM_CHILD")IDCam = GetIntParam(0)

 

then use "SET_CAM_ROT" like that :

 

PushInt(IDCam)PushFloat(AngleX)PushFloat(AngleY)PushFloat(AngleZ)CallNative("SET_CAM_ROT")

 

Hey, I still need help here, please! sad.gif

To became the players view point (like in first person schooters), i think this will give you the correct viewpoint. but lua is not my used script lang and im on work. function not testest !!

 

function GetNewCamCoords()

PushInt(PLAYER_CHAR)

PushFloat(0.0)

PushFloat(0.2)

PushFloat(0.0)

PushVarPtr()

PushVarPtr()

PushVarPtr()

CallNative("GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS")

X = GetFloatParam(4)

Y = GetFloatParam(5)

Z = GetFloatParam(6)

end

 

Became actual cam id like postet before:

 

function GetActualCamID

PushVarPtr()

CallNative("GET_GAME_CAM_CHILD")

IDCam = GetIntParam(0)

end

 

Set the new coordinates to cam

 

SetCamCoords(IDCam)

GetNewCamCoords()

PushInt(IDCam)

PushFloat(AngleX)

PushFloat(AngleY)

PushFloat(AngleZ)

CallNative("SET_CAM_ROT")

end

 

To start functions

 

GetActualCamID()

SetCamCoords(IDCam)

 

I think that this is all what you need to set actual cam in first person mode. Like i told before ... this are only the functions and THEY ARE NOT TESTET. I use other script languages for myself.

Edited by SEKoner

I've a bit time between my work and made this script to test if it works like i think :

 

 

-- First-Person Cam Test-Script by SEKoner --globale variablenPLAYER_ID, PLAYER_INDEX, PLAYER_CHAR, TIMER = 0function InitScript()-- Wake up neo ... wake up ....;)Wait(10000)endfunction WaitForPlayerPoolCreation() while (IsPlayerPoolCreated() == 0) do   Wait(2000) endendfunction 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)  endfunction getNewCam() PushInt(PLAYER_CHAR) PushFloat(0.1) PushFloat(0.2) PushFloat(0.1) PushVarPtr() PushVarPtr() PushVarPtr() CallNative("GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS") X = GetFloatParam(4) Y = GetFloatParam(5) Z = GetFloatParam(6)endfunction getActualCamId() PushVarPtr() CallNative("GET_GAME_CAM_CHILD") IDCam = GetIntParam(0) SetCamCoords(IDCam) wait(100)endSetCamCoords(ID) getNewCam() PushInt(ID) PushFloat(X) PushFloat(Y) PushFloat(Z) CallNative("SET_CAM_ROT")endfunction Test() getActualCamId() wait(300)endfunction main()InitScript()while true do  WaitForPlayerPoolCreation()  WaitForValidPlayer()   if (IsKeyPressed(112) == 1) then     Test()  end  Wait(1700)endendmain();

 

 

Can someone test it ??

i dont think its that simple... in most vanilla scripts there are commands like CREATE_CAM and START_scripted_cams and a few i dont remember...

1st person might be refreshing icon14.gif

Well, I didn't actually want "firstperson". I just wanted the camera centered behind Niko, on foot and in cars (currently off-set).

you get the camera rolling ill get the first person, DEAL??

colgate.gif

Yeah, there's only one problem: I know almost nothing about scripting. I know there are "if" and "else" and "end". And I know just a bit about how to use that, but I know nothing about "lua". sad.gif

  • 2 weeks later...
  • 1 month later...
Download this http://www.gtaforums.com/index.php?showtopic=398667

Press M when in car

done.

Thank you for the link! I think I must quote myself:

 

 

Is it possibe to center the camera behind Niko and in the car center the camera behind the car, not Niko, using a lua-script?!
It's best to create your own camera then activate it.

Don't change the game's camera.

The first person camera attaches an object to niko's head then sets the camera on that object, for example.

Ok, thanks. If I knew how to do that I would have done it by now.

  • 8 months later...
  • 10 months later...

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
  • 0 User Currently Viewing
    0 members, 0 Anonymous, 0 Guests

×
×
  • Create New...

Important Information

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