Jacobob14 Posted February 22, 2014 Share Posted February 22, 2014 Hola tengo el spawn de 50 p lo e editado un poco pero no se como hacer para que la camara no se teletransporte al selecionar un spawn si no que se mueva hasta el lugar del spawn alguien podria ayudarme en eso c_gui.lua local selectedRow = -1; local selectedGroup = -1; previousClass = -1; local weaponIcons = { }; local weaponLabels = { }; local weaponAmmoLabels = { }; function createGroupSelectionWnd( ) local selectionPos = { gridList:Position( false ) }; groupsGridList = GridList:Create( screenSize[ 1 ] - gridList:Size( false ) - 4, screenSize[ 2 ] - 425, 180, 200, false ); groupsGridList: Alpha( .9 ); groupsGridList: AddColumn( "zone to respawn", .8 ); groupsGridList: SortingEnabled( false ); for _, group in ipairs( classGroups ) do groupsGridList:AddRow( false, group.name ); end groupsGridList:AddOnClick( groupSelected ); groupsGridList:Visible( false ); end function groupSelected( ) descrGridList:Visible( false ); weaponsGrid:Visible( false ); selectedGroup = groupsGridList:SelectedItem( ); if selectedGroup ~= -1 then populateClassesGrid( classGroups[ selectedGroup + 1 ].classes ); else gridList:Clear( ); end previousClass = -1; end function createClassSelectionWnd( ) gridList = GridList:Create( screenSize[ 1 ] - 184, screenSize[ 2 ] -225, 180, 220, false ); gridList:AddColumn( "Selection to spawn :", .85 ); gridList:Alpha( .9 ); gridList:SortingEnabled( false ); gridList:AddOnClick( classSelected ); gridList:Visible( false ); local gridSize = { gridList:Size( false ) }; spawnBtn = Button:Create( screenSize[ 1 ] - gridList:Size( false ) - 255, screenSize[ 2 ] - 45, 115, 40, "SPAWN", false ); spawnBtn:Font( "default-bold-small" ); spawnBtn:ColorOnHover( "0000FFFF" ); spawnBtn:AddOnClick( requestSpawn ); spawnBtn:Visible( false ); end function populateClassesGrid( classes ) gridList:Clear( ); for classIndex, class in pairs( classes ) do gridList:AddRow( true, class.name ); for skinIndex, skin in ipairs( class.skinMngr:GetSkins( ) ) do local row = gridList:AddRow( false, skin.name ); gridList:ItemData( row, 1, tostring( classIndex ) .."," .. tostring( skinIndex ) ); end end end function classSelected ( ) selectedRow = gridList:SelectedItem( ); if selectedRow ~= -1 then playSound( "Menu.mp3", false ) local data = split( gridList:ItemData( selectedRow, 1 ), string.byte(',') ); local classIndex = tonumber( data[ 1 ] ); local skinIndex = tonumber( data[ 2 ] ); local class = classGroups[ selectedGroup + 1 ].classes[ classIndex ]; local skin = classGroups[ selectedGroup + 1 ].classes[ classIndex ].skinMngr.skins[ skinIndex ]; enableSpawn( false ); if previousClass ~= classIndex then resizeWeaponsWnd( class.weaponMngr ); fadeCamera( false ); setTimer( moveCameraTo, 1000, 1, class, skin ); else teleportTempPed( skin ); end previousClass = classIndex; local classDescr = class.info; if classDescr then descrLabel:Text( classDescr ); descrGridList:Visible( true ); else descrGridList:Visible( false ); weaponsGrid:Visible( false ); end else descrGridList:Visible( false ); weaponsGrid:Visible( false ); end end function requestSpawn( ) selectedRow = gridList:SelectedItem(); if ( selectedGroup ~= -1 ) and ( selectedRow ~= -1 ) then playSound( "Menu.mp3", false ) local data = split( gridList:ItemData( selectedRow, 1 ), string.byte(',') ); local classIndex = tonumber( data[ 1 ] ); local skinIndex = tonumber( data[ 2 ] ); local class = classGroups[ selectedGroup + 1 ].classes[ classIndex ]; local skin = classGroups[ selectedGroup + 1 ].classes[ classIndex ].skinMngr.skins[ skinIndex ]; fadeCamera( false ); setTimer( triggerServerEvent, 1000, 1, "spawn_clientRequestSpawn", g_root, selectedGroup + 1, classIndex, skinIndex ); end end function moveCameraTo( class, skin ) local camX, camY, camZ = class.cameraMngr.pos.x, class.cameraMngr.pos.y, class.cameraMngr.pos.z; local lookAtX, lookAtY, lookAtZ = class.cameraMngr.lookAt.x, class.cameraMngr.lookAt.y, class.cameraMngr.lookAt.z; fadeCamera( true ); --outputDebugString( "fading camera in" ); setCameraMatrix( camX, camY, camZ, lookAtX, lookAtY, lookAtZ ); setTimer( teleportTempPed, 500, 1, skin ); end local losTests = 0; -- line of sight function teleportTempPed( skin ) local x, y, z = getWorldFromScreenPosition( screenSize[ 1 ] - gridList:Size(false) -295, ( screenSize[ 2 ]) -250, 5 ) local cX, cY, cZ; cX, cY, cZ = getCameraMatrix(); if not tempPed then createTempPed( skin.modelId ); else setElementPosition( g_ground, x, y, z - 1.02 ); setElementPosition( tempPed, x, y, z ); setElementModel( tempPed, skin.modelId ); x, y, z = getWorldFromScreenPosition( screenSize[ 1 ] - gridList:Size(false) -295, ( screenSize[ 2 ]) -250, 5 ) end if not processLineOfSight( cX, cY, cZ, x, y, z ) then losTests = losTests + 1; if losTests < 3 then setTimer( teleportTempPed, 300, 1, skin ); return else destroyElement( g_ground ); destroyElement( tempPed ); tempPed = nil; createTempPed( skin.modelId ); enableSpawn( true ); losTests = 0; end else enableSpawn( true ); end end function createClassDescriptionWnd( ) descrGridList = GridList:Create( screenSize[ 1 ] - 305, 5, 300, 125, false ); descrTitleLbl = Label:Create( 8, 5, 100, 30, "Information :", false, descrGridList.gui ); descrTitleLbl:Font( "default-bold-small" ); descrTitleLbl:Color( 255, 100, 5 ); descrLabel = Memo:Create( 10, 25, 280, 90, "", false, descrGridList.gui ); descrLabel:ReadOnly( true ); descrGridList:Alpha( 1 ); descrGridList:Visible( false ); end function createClassWeaponWnd( ) local descrSize = { descrGridList:Size( false ) }; weaponsGrid = GridList:Create( screenSize[ 1 ] - 1, descrSize[ 2 ] + 4, 1, 1, false ); weaponsGrid:Alpha( .0 ); weaponsGrid:Visible( false ); end function enableSpawn( enable ) bringSpawnMenuToFront( ); gridList:Enabled( enable ); spawnBtn:Enabled( enable ); descrGridList:Visible( enable ); if enable == true then local data = split( gridList:ItemData( selectedRow, 1 ), string.byte(',') ); local classIndex = tonumber( data[ 1 ] ); local skinIndex = tonumber( data[ 2 ] ); local class = classGroups[ selectedGroup + 1 ].classes[ classIndex ]; if class.weaponMngr:WeaponCount( ) > 0 then weaponsGrid:Visible( enable ); else weaponsGrid:Visible( false ); end end end function resizeWeaponsWnd( weaponManager ) local minHeight = 18; local weapCount = weaponManager:WeaponCount( ); local weapons = weaponManager:GetWeapons( ); weaponsGrid:Size( 115, minHeight + ( weapCount * 40 ), false ); if weapCount > 0 then for i, icon in pairs( weaponIcons ) do if icon and icon.gui then destroyElement( icon.gui ); end end weaponIcons = nil; weaponIcons = { }; for i, lbl in pairs( weaponLabels ) do if lbl and lbl.gui then destroyElement( lbl.gui ); end end weaponLabels = nil weaponLabels = { }; for i, weapon in ipairs( weapons ) do weaponIcons[ i ] = StaticImage:Create( 10, ( (i-1) * 40 ) + 10, iconWidths[ weapon.id ], 20, icons[ weapon.id ], false, weaponsGrid.gui ); weaponLabels[ i ] = Label:Create( 10, ( (i-1) * 40 ) + 17, 95, 35, "\nAmmo: x" .. tostring( weapon.ammo ), false, weaponsGrid.gui ); weaponLabels[ i ]:Font( "pricedown" ); weaponLabels[ i ]:HorizontalAlign( "left" ); end weaponsGrid:Visible( true ); else weaponsGrid:Visible( false ); Link to comment
BorderLine Posted February 22, 2014 Share Posted February 22, 2014 usa createObject setElementAlpha moveObject getElementPosition setCameraMatrix onClientRender La idea es crear 2 objetos y que se muevan sincronisando los primeros 3 argumentos de camera matrix a la posicion de un objeto y los otros 3 argumentos de camera matrix que es a donde apunta la camara al otro objeto. de esta manera por cada render obtienes la pocicion de los objetos que claro se moveran con moveObject y la camara se ira moviendo junto con los objetos Link to comment
PhantomDamn Posted February 22, 2014 Share Posted February 22, 2014 osea no quieres que la camara se ponga oscura y luego aparezca donde sera spawneado el team? quieres que la camara viaje hasta el punto del spawn? Link to comment
Jacobob14 Posted February 22, 2014 Author Share Posted February 22, 2014 osea no quieres que la camara se ponga oscura y luego aparezca donde sera spawneado el team? quieres que la camara viaje hasta el punto del spawn? se eso mismo Link to comment
Daniel1zD Posted February 23, 2014 Share Posted February 23, 2014 Puedes usar estas funciones creo espero que te sirvan setCameraMatrix setElementAlpha getElementPosition createObject addEventHandler setTimer https://wiki.multitheftauto.com/wiki/OnClientPreRender https://wiki.multitheftauto.com/wiki/SetCameraMatrix espero que te sirvan las funciones Link to comment
PhantomDamn Posted February 24, 2014 Share Posted February 24, 2014 Una vez vi un servidor Resident Evil creo que se llamaba, que usaba el Spawn de 50p de esta manera.. Link to comment
diegofkda Posted February 24, 2014 Share Posted February 24, 2014 No es lo propio ocupar objetos para aquello. Es algo tan simple como ocupar: interpolateBetween setCameraMatrix getElementPosition setTimer ó "onClientRender" Link to comment
MTA Team 0xCiBeR Posted February 24, 2014 MTA Team Share Posted February 24, 2014 Sugiero que lo intentes, y si te topas con algún error, pides por ayuda. Tus compañeros mas arriba te han dado posibles soluciones, solo es cuestión de que te lances a por ello. Si no eres muy experimentado en scriptear, te sugiero que estudies bien cada una de las funciones que te escribieron mas arriba. Mis mejores deseos para vos. Saludos. Link to comment
Eduardoh1997 Posted February 27, 2014 Share Posted February 27, 2014 Podrias hacer tu propio spawn , con las funciones que te dieron y esta de además podrias hacer como iSG , XLATINO que tienen propio spawn guiCreateGridList --https://wiki.multitheftauto.com/wiki/GuiCreateGridList Te recomiendo leer todo lo que tiene que ver con GridList , usa las funciones que te dieron y saca las funciones del 50p spawn que tienes editado y has uno tullo propio . Link to comment
Recommended Posts