Jump to content

Moving Camera


simstosh

Recommended Posts

Posted

How can I do a moving camera?

I Want to do a intro moving camera after a player login/register.

When a player login / register, the camera moves to an direction and ends on a fade to black, and fade to normal after 2 seconds.

And using the same topic, how can I set to a player look to a point?

I tried setPedLookAt but he saw that's a nil value on console.

The code is server-side and player = source

setPedLookAt ( player, -688.55078125, 935.2333984375, 13.6328125 ) 

Posted

setPedLookAt = client side function

moving camera with

onClientPreRender event (tip: use onClientPreRender instead of onClientRender to fix "jumping animations" while moving camera) and setCameraMatrix.

there is no function like moveCamera, etc

Posted

Some example to help me?

I've searched on wiki, but haven't understand so much :P

EDIT: Oh, and about the "setPedLookAt", other way to change the player rotation?

EDIT²: Used setPedRotation and works.

Posted

very simple example

  
time = getTickCount() 
x = 1000 
y = 200 
z = 20 
function anim() 
 x = x+0.01 
 y = y+0.02 
 setCameraMatrix(x,y,z, 0, 0, 0) 
 if (getTickCount() - time >= 5000) then --if animation lasts for 5 or more seconds 
  removeEventHandler("onClientPreRender", getRootElement(), anim) -- stop it 
 end 
end 
addEventHandler("onClientPreRender", getRootElement(), anim) 
  

not tested, camera position was totally random!

of course you can use another conditional to stop animation (like when camera its further than specified X,Y or Z value, etc etc)

Posted

@SolidSnake14

I've already do this, thanks anyway.

@varez

I'm gonna try, thanks to help.

How can I remove a dxDrawImage?

Example: I do a menu and some items by the guiEditor, and added a dxDrawImage

-- Direct X Drawing 
addEventHandler("onClientRender",root, 
    function() 
        dxDrawImage(0.0,337.0,497.0,562.0,"images/zmrpfinal.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
    end 
) 

What I need to do to "remove" the dxDrawImage?

Posted (edited)

Thanks, almost finished.

One more question, how can I adjust the gui that I've created to fit in almost all resolutions? (800x600 or better)

I use 1440x900 by default on PC, so the menus works normal on this resolution, but in other resolution not.

Login_Button = guiCreateButton(240,817,90,29,"Logar >>",false) 
  
Login_LLabel = guiCreateLabel(108,750,39,15,"Login:",false) 
guiLabelSetColor(Login_LLabel,0,0,0) 
guiLabelSetVerticalAlign(Login_LLabel,"top") 
guiLabelSetHorizontalAlign(Login_LLabel,"right",false) 
guiSetFont(Login_LLabel,"default-bold-small") 
  
Login_SLabel = guiCreateLabel(108,788,39,15,"Senha:",false) 
guiLabelSetColor(Login_SLabel,0,0,0) 
guiLabelSetVerticalAlign(Login_SLabel,"top") 
guiLabelSetHorizontalAlign(Login_SLabel,"right",false) 
guiSetFont(Login_SLabel,"default-bold-small") 
  
Login_LBox = guiCreateEdit(151,744,179,28,"",false) 
Login_SBox = guiCreateEdit(151,779,179,28,"",false) 
  
function zmrplogo() 
    dxDrawImage(0, 334, 497, 562,"images/zmrpfinal.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
end 
addEventHandler("onClientRender", getRootElement(), zmrplogo) 

position.th.png

/\ This is the gui menu (dxImage + gui functions) what I'm talking about.

Oh, I almost forgot, he's positioned on the bottom left corner of the monitor.

Edited by Guest
Posted

maybe if you create all the GUI + DXdraw elements using Absolute and not Relative.

if you are using GUIEDITOR to make them click this button: Rel/Abs screen

Posted

Fixed. I've changed the dxDrawImage by guiCreateStaticImage.

EDIT: FORGOT ALL WHAT I PUT HERE, HAVE FIXED :)

But i'm getting other problem...

I can't do a comparation to check if account exists, shows the Login's GUI, and if doesn't exists, shows the Register GUI...

function onJoin ( ) 
    local account = getPlayerAccount ( source ) 
    if( account ) then 
        triggerClientEvent ( source, "windowHandlerLogin", getRootElement() ) 
    else 
        triggerClientEvent ( source, "windowHandlerRegister", getRootElement() ) 
    end 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), onJoin ) 

I don't understand why doesn't work ._.

He only show the Register GUI.

Thanks

Posted

when player joins his account is guest account because he is not logged in.. it will always work like that..

better save some xml on client side if player is registered

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...