5150 Posted March 22, 2016 Share Posted March 22, 2016 so i have this handy dandy resource that is a skin selector, but its also a team creator/manager and all that cool crap. theres a small bug though and this is too good of a script to just throw away. sometimes, at random times when i want to spawn it will say failed to spawn. try another skin. well i try another skin and nothing, i have to restart the resource. anyone have any solutions? anything is greatly appreciated. P.S. i deleted the custom skins and some of the teams, but that shouldnt matter, as i made sure all parts to them were deleted, as if they were never added/scripted heres the resource: https://community.multitheftauto.com/in ... ls&id=6429 here are my files (not the stock ones), to see the difference: 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 ) - 119, screenSize[ 2 ] - 125, 115, 100, false ); groupsGridList: Alpha( .8 ); groupsGridList: AddColumn( "Category", .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 ] - 185, screenSize[ 2 ] - screenSize[ 2 ] / 3, 180, screenSize[ 2 ] / 3 - 5, false ); gridList:AddColumn( "Class:", .85 ); gridList:Alpha( .8 ); gridList:SortingEnabled( false ); gridList:AddOnClick( classSelected ); gridList:Visible( false ); local gridSize = { gridList:Size( false ) }; spawnBtn = Button:Create( screenSize[ 1 ] - gridList:Size( false ) - 120, screenSize[ 2 ] - 25, 115, 20, "SPAWN", false ); spawnBtn:Font( "default-bold-small" ); spawnBtn:ColorOnHover( "FF5500FF" ); 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 createPasswordWnd( ) passwordWnd = Window:Create( screenSize[ 1 ] / 2 - 200, screenSize[ 2 ] / 2 - 30, 400, 80, "" ); passwordWnd:AddLabel( 20, 35, "Password:" ); passTextBox = passwordWnd:AddTextBox( 80, 33, 150, 20, "" ); passTextBox:Masked( true ); passSpawnBtn = passwordWnd:AddButton( 315, 31, 70, 25, "Spawn" ); passSpawnBtn:AddOnClick( requestSpawn ); passCancelBtn = passwordWnd:AddButton( 235, 31, 70, 25, "Cancel" ); passCancelBtn:AddOnClick( function() passwordWnd:Visible( false ); fadeCamera( true ); showSpawnMenu( true, false ); end ); passwordWnd:Movable( false ); passwordWnd:Sizable( false ); passwordWnd:Visible( false ); end function classSelected ( ) selectedRow = gridList:SelectedItem( ); if selectedRow ~= -1 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 ]; local skin = classGroups[ selectedGroup + 1 ].classes[ classIndex ].skinMngr.skins[ skinIndex ]; enableSpawn( false ); if previousClass ~= classIndex then resizeWeaponsWnd( class.weaponMngr ); fadeCamera( false ); --setTimer( fadeCamera, 1000, 1 ); 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( pass ) selectedRow = gridList:SelectedItem(); if ( selectedGroup ~= -1 ) and ( selectedRow ~= -1 ) 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 ]; local skin = classGroups[ selectedGroup + 1 ].classes[ classIndex ].skinMngr.skins[ skinIndex ]; fadeCamera( false ); if pass == spawnBtn then setTimer( triggerServerEvent, 1000, 1, "spawn_clientRequestSpawn", g_root, selectedGroup + 1, classIndex, skinIndex ); return; end setTimer( triggerServerEvent, 1000, 1, "spawn_clientRequestSpawn", g_root, selectedGroup + 1, classIndex, skinIndex, passTextBox:Text( ) ); 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) / 2 - 70, ( screenSize[ 2 ] / 1.6 ) * .8, 10 ) 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) / 2 - 70, ( screenSize[ 2 ] / 1.6 ) * .8, 11 ) 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, "Class information:", false, descrGridList.gui ); descrTitleLbl:Font( "default-bold-small" ); descrTitleLbl:Color( 255, 150, 0 ); descrLabel = Memo:Create( 10, 25, 280, 90, "", false, descrGridList.gui ); descrLabel:ReadOnly( true ); descrGridList:Alpha( 0.8 ); descrGridList:Visible( false ); end function createClassWeaponWnd( ) local descrSize = { descrGridList:Size( false ) }; weaponsGrid = GridList:Create( screenSize[ 1 ] - 120, descrSize[ 2 ] + 4, 115, 40, false ); weaponsGrid:Alpha( .8 ); 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 = 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