Jump to content

Moving Camera


simstosh

Recommended Posts

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 ) 

Link to comment

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)

Link to comment

@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?

Link to comment

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
Link to comment

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

Link to comment

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...