Jump to content

[Help]Moving camera


Storm-Hanma

Recommended Posts

hello community members i created a team panel with moving camera function the moving camera and panel works  fine and get team player to scoreboard also working  only the player  spawn not working ,

but when it comes to select (choose)team it must spawn me at the positions  , but its not working 

the screen go black and i stuck in the black screen below r some pics see it ,

Team panel pic :

https://imgur.com/nTKFprq

https://imgur.com/a/NG5mp

Black screen when i click on select team :

https://imgur.com/a/PS5pm

https://imgur.com/LzoQWhN

Scoreboard  works fine shows team+player :

https://imgur.com/A07HHQp

https://imgur.com/a/3fmPl

client code :

--[[-------------------------------------------------
Notes:

> This code is using a relative image filepath. This will only work as long as the location it is from always exists, and the resource it is part of is running.
    To ensure it does not break, it is highly encouraged to move images into your local resource and reference them there.
--]]-------------------------------------------------


GUIEditor = {
    staticimage = {},
    label = {},
    button = {},
    window = {},
    gridlist = {},
    memo = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
    function()
      
        
 setTimer(function()
  startCamera()
  end, 2000, 1)
        GUIEditor.window[2] = guiCreateWindow(-3, 315, 1156, 423, "Team spawn panel", false)
        guiWindowSetSizable(GUIEditor.window[2], false)
        guiSetAlpha(GUIEditor.window[2], 1.00)
        guiSetProperty(GUIEditor.window[2], "CaptionColour", "FF45EE1E")

        GUIEditor.memo[4] = guiCreateMemo(14, 268, 223, 145, "Ballas r pro In gangs theey can take\ndown any gangs ,police or any teamsmebers the main goal of ballas is to take down groove street memebrs and there belonging\n**take down Groove and bikers*", false, GUIEditor.window[2])
        GUIEditor.memo[5] = guiCreateMemo(260, 273, 245, 130, "Groove memebrs are decent and very powerfull with awsome guns skills they \ndo attack with combine members all the work is to take down mother :Oers\nBallas and bikers noobs!!\n\n**Take down Ballas and Bikers******", false, GUIEditor.window[2])
        GUIEditor.memo[6] = guiCreateMemo(549, 279, 232, 128, "Bikers are newbies they dont know much about killing ,teaming so if are pro think to take down all groove and ballas then claim down your memebrs and take down kids around your hood!\n**Take down noobs around hood**", false, GUIEditor.window[2])
        GUIEditor.staticimage[4] = guiCreateStaticImage(14, 28, 218, 188, ":newteampanel/img/Ballas.png", false, GUIEditor.window[2])
        GUIEditor.staticimage[5] = guiCreateStaticImage(259, 34, 240, 172, ":newteampanel/img/groove.png", false, GUIEditor.window[2])
        GUIEditor.staticimage[6] = guiCreateStaticImage(565, 54, 200, 152, ":newteampanel/img/bikers.png", false, GUIEditor.window[2])
        GUIEditor.button[4] = guiCreateButton(838, 340, 129, 41, "Select", false, GUIEditor.window[2])
        guiSetProperty(GUIEditor.button[4], "NormalTextColour", "FF787B84")
        GUIEditor.memo[7] = guiCreateMemo(1340, 284, 0, 20, "", false, GUIEditor.window[2])
        GUIEditor.button[5] = guiCreateButton(981, 338, 126, 43, "Close", false, GUIEditor.window[2])
		
       teamsList = guiCreateGridList(825, 51, 282, 277, false, GUIEditor.window[2])
       column = guiGridListAddColumn(teamsList, "Teams", 0.9)
		for id, team in ipairs(getElementsByType("team")) do
		local row = guiGridListAddRow ( teamsList )
		guiGridListSetItemText ( teamsList, row, 1, getTeamName ( team ), false, false )
		guiGridListSetItemColor ( teamsList, row, 1, getTeamColor ( team ) )
end


 
        for i = 1, 3 do
            guiGridListAddRow(teamsList)
        end
        guiGridListSetItemText(teamsList, 0, 1, "Ballas", false, false)
        guiGridListSetItemColor(teamsList, 0, 1, 249, 31, 2, 255)
        guiGridListSetItemText(teamsList, 1, 1, "Groovestreet", false, false)
        guiGridListSetItemColor(teamsList, 1, 1, 6, 244, 40, 255)
        guiGridListSetItemText(teamsList, 2, 1, "Bikers", false, false)
        guiGridListSetItemColor(teamsList, 2, 1, 224, 17, 232, 255)
        GUIEditor.label[1] = guiCreateLabel(830, 30, 277, 24, "Team selection panel", false, GUIEditor.window[2])
        guiLabelSetColor(GUIEditor.label[1], 249, 31, 2)    
    end
	
)

addEventHandler( 'onClientGUIClick', root,
function()
if source == GUIEditor.button[5] then
guiSetVisible(GUIEditor.window[2], false) showCursor(false)
end
end
)


addEventHandler( 'onClientGUIClick', root,
function ( button )
if source == GUIEditor.button[4] then
if button == "left" then
local row, col = guiGridListGetSelectedItem ( teamsList )
local teamName = guiGridListGetItemText ( teamsList, row, col )
triggerServerEvent ( "onPlayerChooseTeam", getLocalPlayer(), teamName )
removeEventHandler("onClientPreRender", root, moveItNow)
if isElement(dumpy) then destroyElement(dumpy) end
destroyElement(GUIEditor.window[2])
 guiSetInputEnabled(false)
 fadeCamera(false, 1.0, 0, 0, 0) 
 
end
end
end)

---MOVING CAMERA
       
cams = {
    --X, Y, Z, X2, Y2, TX, TY, TZ
    [1]={1859, -1516, 48, 1952, -1513, 1919, -1423, 22}, --LS Skatepark
    [2]={2077, -1245, 46, 2077, -1148, 1987, -1200, 24}, --Glen Park
    [3]={1526, -1004, 63, 1484, -950, 1478, -989, 61}, --Burger King AD LS
    [4]={1471, -1606, 44, 1470, -1697, 1552, -1675, 21} --LSPD
}

pos = nil

function startCamera()
    pos = math.random(1, #cams)
    local x, y, z = cams[pos][1], cams[pos][2], cams[pos][3]
    local tx, ty = cams[pos][4], cams[pos][5]
    local cx, cy, cz = cams[pos][6], cams[pos][7], cams[pos][8]
    setCameraMatrix(x, y, z, cx, cy, cz, 1, 90)
    startCamAction(x, y, z, tx, ty, 12)
end
    
function startCamAction(x, y, z, tx, ty, time)
    fadeCamera(true, 1.0, 0, 0, 0)
    dumpy = createObject(1337, x, y, z)
    setElementAlpha(dumpy, 0)
    setElementCollisionsEnabled(dumpy, false)
    moveObject(dumpy, time*1000, tx, ty, z)
end
        
function moveItNow()
    if not isElement(dumpy) then return end
    local x, y, z = getElementPosition(dumpy)
    setCameraMatrix(x, y, z, cams[pos][6], cams[pos][7], cams[pos][8], 1, 90)
    if (getDistanceBetweenPoints3D(x, y, z, cams[pos][4], cams[pos][5], z) <= 1) then
        if isElement(dumpy) then destroyElement(dumpy) end
        fadeCamera(false, 1.0, 0, 0, 0)
        setTimer(function() startCamera() end, 1200, 1)
    end
end
addEventHandler("onClientPreRender", root, moveItNow)

 

Edited by Khadeer143
  • Like 1
Link to comment
  • Moderators

Debug your code manually. Easiest way for us to help you and to help yourself.

 

I assume you have already seen this topic, but fortunately it is exactly what you need to do in this situation. Locate bugs...

:buzzsaw:

and annihilate them.

 

  • Like 1
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...