Jump to content

SetCameraMatrix problem


JoZeFSvK

Recommended Posts

Hey i wanna create camera matrix but dont work :x i dont know where is problem. :/

nacitavanie = 0 
createPed(40, 173.35345, -1320.99438, 79.13128) 
function load() 
    nacitavanie = nacitavanie + 1 
    if getPedOccupiedVehicle(localPlayer) then 
        local x, y, z = getElementPosition(getPedOccupiedVehicle(localPlayer)) 
        setElementPosition(getPedOccupiedVehicle(localPlayer), x, y, z) 
    end 
    if nacitavanie > 3350 then 
        setCameraMatrix(-437.14282226563 + nacitavanie, -1320 + nacitavanie - 3350, 80, 2580, -1628.5712890625, -300, 0, 70) 
    else 
        setCameraMatrix(-437.14282226563 + nacitavanie, -1320, 80, 2580, -1628.5712890625, -300, 0, 70) 
    end 
end 
  
addEvent( "onTravelScreenStart", true ) 
addEventHandler( "onTravelScreenStart", getRootElement(), load ) 
  

Link to comment
I think it's because line 1 and line 4 got similar locals ..

Try changing one of them ( Not sure ..! )

I don't think it's a problem, he just defines a variable in the first line and then raises it with 1 on thee fourth.

@JoZeFSvK: If you want to move the camera continuously, then use your load() function with "onClientPreRender" event.

Link to comment

see this work

nacitavanie = 0 
createPed(40, 173.35345, -1320.99438, 79.13128) 
function drawBackround() 
    nacitavanie = nacitavanie + 1 
    if getPedOccupiedVehicle(localPlayer) then 
        local x, y, z = getElementPosition(getPedOccupiedVehicle(localPlayer)) 
        setElementPosition(getPedOccupiedVehicle(localPlayer), x, y, z) 
    end 
    if nacitavanie > 3350 then 
        setCameraMatrix(-437.14282226563 + nacitavanie, -1320 + nacitavanie - 3350, 80, 2580, -1628.5712890625, -300, 0, 70) 
    else 
        setCameraMatrix(-437.14282226563 + nacitavanie, -1320, 80, 2580, -1628.5712890625, -300, 0, 70) 
    end 
end 
  
addEventHandler("onClientRender", getRootElement(), drawBackround) 
  

but when i add

addEvent( "onTravelScreenStart", true ) 
  

and i see travelling map ... i see black background why ?

Link to comment

I didn't understand your problem really...Try this maybe:

addEvent( "onTravelScreenStart", true ) 
addEventHandler ( "onTravelScreenStart", root,  
    function () 
        addEventHandler ( "onClientPreRender", root, drawBackround ) 
    end) 
  
  

Link to comment
nacitavanie = 0 
createPed ( 40, 173.35345, -1320.99438, 79.13128 ) 
  
function load ( ) 
    nacitavanie = nacitavanie + 1 
    if getPedOccupiedVehicle(localPlayer) then 
        local x, y, z = getElementPosition(getPedOccupiedVehicle(localPlayer)) 
        setElementPosition(getPedOccupiedVehicle(localPlayer), x, y, z) 
    end 
    fadeCamera ( true ) 
    if nacitavanie > 3350 then 
        setCameraMatrix(-437.14282226563 + nacitavanie, -1320 + nacitavanie - 3350, 80, 2580, -1628.5712890625, -300, 0, 70) 
    else 
        setCameraMatrix(-437.14282226563 + nacitavanie, -1320, 80, 2580, -1628.5712890625, -300, 0, 70) 
    end 
end 
addEvent ( "onTravelScreenStart", true ) 
addEventHandler ( "onTravelScreenStart", getRootElement(), load ) 

Link to comment

ok i edit race client :) work, but can you help me with dx text which will write when the game loads the map, in race when i edit i always have problem with nametags in debugscript and race dont work :/

so

  
local sw, sh = guiGetScreenSize() 
function createText ( ) 
dxDrawText ("Hey world", 0, sh/2-200, sw, sh, tocolor (255,255,255,255), 2, "default-bold", "center", "top") 
end 
addEvent( "onTravelScreenStart", true ) 
addEventHandler( "onTravelScreenStart", getRootElement(), createText ) 
  
function manageTravelScreenStop () 
    removeEventHandler ( "onClientRender", root, createText) 
end 
  

dont work :/ i see city "edit travelling" but text no :/

Link to comment

1. You never trigger the event "onTravelScreenStart".

2. If you don't need the event to be triggered from the server-side, you don't need to set second parameter of addEvent to true.

3. You never call "manageTravelScreenStop".

4. DirectX functions need to be updated every frame, so you must use onClientRender event.

@Razor., that has nothing to do, he's not declaring the variable twice (well, actually he is, but before the end of the value assignment to the variable, the old variable is still "active" so it's like if he is just modifying the value of the variable).

Link to comment

an example of how you can use it "race_client.lua"

nacitavanie = 0 
createPed ( 40, 173.35345, -1320.99438, 79.13128 ) 
  
function load ( ) 
    nacitavanie = nacitavanie + 1 
    if getPedOccupiedVehicle(localPlayer) then 
        local x, y, z = getElementPosition(getPedOccupiedVehicle(localPlayer)) 
        setElementPosition(getPedOccupiedVehicle(localPlayer), x, y, z) 
    end 
    fadeCamera ( true ) 
    if nacitavanie > 3350 then 
        setCameraMatrix(-437.14282226563 + nacitavanie, -1320 + nacitavanie - 3350, 80, 2580, -1628.5712890625, -300, 0, 70) 
    else 
        setCameraMatrix(-437.14282226563 + nacitavanie, -1320, 80, 2580, -1628.5712890625, -300, 0, 70) 
    end 
end 
--addEvent ( "onTravelScreenStart", true ) 
--addEventHandler ( "onTravelScreenStart", getRootElement(), load ) 
  
  
-- Called from server 
function notifyLoadingMap( mapName, authorName ) 
    fadeCamera( false, 0.0, 0,0,0 ) -- fadeout, instant, black 
    TravelScreen.show( mapName, authorName ) 
  
     addEventHandler ( "onClientPreRender", getRootElement(), load ) 
  
end 
  
  
-- Called from server 
function initRace(vehicle, checkpoints, objects, pickups, mapoptions, ranked, duration, gameoptions, mapinfo, playerInfo) 
    outputDebug( 'MISC', 'initRace start' ) 
    unloadAll() 
     
    g_Players = getElementsByType('player') 
    g_MapOptions = mapoptions 
    g_GameOptions = gameoptions 
    g_MapInfo = mapinfo 
    g_PlayerInfo = playerInfo 
    triggerEvent('onClientMapStarting', g_Me, mapinfo ) 
     
    g_dxGUI.mapdisplay:text("Map: "..g_MapInfo.name) 
     
    fadeCamera(true) 
    showHUD(false) 
     
      removeEventHandler ( "onClientPreRender", getRootElement(), load ) 
  
    g_Vehicle = vehicle 
    setVehicleDamageProof(g_Vehicle, true) 
    OverrideClient.updateVars(g_Vehicle) 
     
    --local x, y, z = getElementPosition(g_Vehicle) 
    setCameraBehindVehicle(vehicle) 
    --alignVehicleToGround(vehicle) 
    updateVehicleWeapons() 
    setCloudsEnabled(g_GameOptions.cloudsenable) 
    setBlurLevel(g_GameOptions.blurlevel) 
    g_dxGUI.mapdisplay:visible(g_GameOptions.showmapname) 
    if engineSetAsynchronousLoading then 
        engineSetAsynchronousLoading( g_GameOptions.asyncloading ) 
    end 

Edited by Guest
Link to comment
ok when i use onClientRender what do i get? when i start script i will see message hey world, i need see this message when is loading the map.

Add the handler to the event when the map starts loading, and remove it when it stops. Functions called when the map starts loading/stop loading are almost on top of the file "race_client.lua".

Link to comment

example

  
  
  
local sw, sh = guiGetScreenSize() 
function createText ( ) 
dxDrawText ("Hey world", 0, sh/2-200, sw, sh, tocolor (255,255,255,255), 2, "default-bold", "center", "top") 
end 
--addEvent( "onTravelScreenStart", true ) 
--addEventHandler( "onTravelScreenStart", getRootElement(), createText ) 
  
nacitavanie = 0 
createPed ( 40, 173.35345, -1320.99438, 79.13128 ) 
  
function load ( ) 
    nacitavanie = nacitavanie + 1 
    if getPedOccupiedVehicle(localPlayer) then 
        local x, y, z = getElementPosition(getPedOccupiedVehicle(localPlayer)) 
        setElementPosition(getPedOccupiedVehicle(localPlayer), x, y, z) 
    end 
    fadeCamera ( true ) 
    if nacitavanie > 3350 then 
        setCameraMatrix(-437.14282226563 + nacitavanie, -1320 + nacitavanie - 3350, 80, 2580, -1628.5712890625, -300, 0, 70) 
    else 
        setCameraMatrix(-437.14282226563 + nacitavanie, -1320, 80, 2580, -1628.5712890625, -300, 0, 70) 
    end 
end 
--addEvent ( "onTravelScreenStart", true ) 
--addEventHandler ( "onTravelScreenStart", getRootElement(), load ) 
  
  
-- Called from server 
function notifyLoadingMap( mapName, authorName ) 
    fadeCamera( false, 0.0, 0,0,0 ) -- fadeout, instant, black 
    TravelScreen.show( mapName, authorName ) 
  
     addEventHandler ( "onClientPreRender", getRootElement(), load ) 
  
      addEventHandler ( "onClientRender", getRootElement(), createText ) 
  
end 
  
  
-- Called from server 
function initRace(vehicle, checkpoints, objects, pickups, mapoptions, ranked, duration, gameoptions, mapinfo, playerInfo) 
    outputDebug( 'MISC', 'initRace start' ) 
    unloadAll() 
    
    g_Players = getElementsByType('player') 
    g_MapOptions = mapoptions 
    g_GameOptions = gameoptions 
    g_MapInfo = mapinfo 
    g_PlayerInfo = playerInfo 
    triggerEvent('onClientMapStarting', g_Me, mapinfo ) 
    
    g_dxGUI.mapdisplay:text("Map: "..g_MapInfo.name) 
    
    fadeCamera(true) 
    showHUD(false) 
    
      removeEventHandler ( "onClientPreRender", getRootElement(), load ) 
  
      removeEventHandler ( "onClientRender", getRootElement(), createText ) 
  
    g_Vehicle = vehicle 
    setVehicleDamageProof(g_Vehicle, true) 
    OverrideClient.updateVars(g_Vehicle) 
    
    --local x, y, z = getElementPosition(g_Vehicle) 
    setCameraBehindVehicle(vehicle) 
    --alignVehicleToGround(vehicle) 
    updateVehicleWeapons() 
    setCloudsEnabled(g_GameOptions.cloudsenable) 
    setBlurLevel(g_GameOptions.blurlevel) 
    g_dxGUI.mapdisplay:visible(g_GameOptions.showmapname) 
    if engineSetAsynchronousLoading then 
        engineSetAsynchronousLoading( g_GameOptions.asyncloading ) 
    end 

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