JoZeFSvK Posted March 2, 2013 Share Posted March 2, 2013 Hey i wanna create camera matrix but dont work 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
PaiN^ Posted March 2, 2013 Share Posted March 2, 2013 I think it's because line 1 and line 4 got similar locals .. Try changing one of them ( Not sure ..! ) Link to comment
csiguusz Posted March 2, 2013 Share Posted March 2, 2013 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
JoZeFSvK Posted March 2, 2013 Author Share Posted March 2, 2013 blee i dont think onClientPreRender and .. its bad i dont like it Link to comment
JoZeFSvK Posted March 2, 2013 Author Share Posted March 2, 2013 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
csiguusz Posted March 2, 2013 Share Posted March 2, 2013 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
JoZeFSvK Posted March 3, 2013 Author Share Posted March 3, 2013 my problem is ... when start map travelling i will dont see black screen but camera matrix in city ^^ when travelling stop i normal see map this is for mode race (i dont need client "pre"render) Link to comment
Castillo Posted March 3, 2013 Share Posted March 3, 2013 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
JoZeFSvK Posted March 4, 2013 Author Share Posted March 4, 2013 i try this but dont work when i add line addEventHandler ( "onClientRender", root, load ) and start script work but when start map loading dont work. Link to comment
Castillo Posted March 4, 2013 Share Posted March 4, 2013 You are triggering the event: "onTravelScreenStart" when exactly? because that event is not part of race. Link to comment
JoZeFSvK Posted March 5, 2013 Author Share Posted March 5, 2013 hmm but then i must edit race client part travel screen and there write Link to comment
JoZeFSvK Posted March 5, 2013 Author Share Posted March 5, 2013 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
Anderl Posted March 5, 2013 Share Posted March 5, 2013 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
JoZeFSvK Posted March 5, 2013 Author Share Posted March 5, 2013 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. Link to comment
Anony# Posted March 5, 2013 Share Posted March 5, 2013 (edited) 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 March 5, 2013 by Guest Link to comment
Anderl Posted March 5, 2013 Share Posted March 5, 2013 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
Anony# Posted March 5, 2013 Share Posted March 5, 2013 @ Anderl, looking at "function initRace()" \o/ ^^ removeEventHandler ( "onClientPreRender", getRootElement(), load ) Link to comment
JoZeFSvK Posted March 5, 2013 Author Share Posted March 5, 2013 Anony# thank you but i this have fixed i need dxdrawtext in loagind map Link to comment
Anderl Posted March 5, 2013 Share Posted March 5, 2013 @ Anderl, looking at "function initRace()" \o/ ^^ removeEventHandler ( "onClientPreRender", getRootElement(), load ) And? Link to comment
Anony# Posted March 5, 2013 Share Posted March 5, 2013 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now