Jump to content

Someone help me with a script (TEAMS), please!


GuilhermeP

Recommended Posts

----------------------------------------------CLIENT------------------------------------------------------------------------------

function wey()
local screenW, screenH = guiGetScreenSize()
        chus = guiCreateWindow((screenW - 294) / 2, (screenH - 345) / 2, 294, 345, "Select your team !", false)
        guiWindowSetMovable(chus, false)
        guiWindowSetSizable(chus, false)

        gridlist = guiCreateGridList(12, 29, 267, 251, false, chus)
        guiGridListAddColumn(gridlist, "Teams", 0.9)
        for i = 1, 2 do
            guiGridListAddRow(gridlist)
        end
        guiGridListSetItemText(gridlist, 0, 1, "SWAT Team", false, false)
        guiGridListSetItemColor(gridlist, 0, 1, 0, 2, 124, 255)
        guiGridListSetItemText(gridlist, 1, 1, "Military Team", false, false)
        guiGridListSetItemColor(gridlist, 1, 1, 7, 125, 0, 255)
        boton = guiCreateButton(86, 296, 129, 38, "Play !", false, chus)    
		showCursor(true)
		end
addEventHandler( "onClientResourceStart", getRootElement(), wey)

addEventHandler("onClientGUIClick", guiRoot, 
function() 
    if source == boton then 
        local row = guiGridListGetSelectedItem(gridlist) 
        if row == 0 then 
		triggerServerEvent("spawnSwat", localPlayer)
		setTimer ( function()
		setElementModel ( localPlayer, 285 )
		end, 1000, 1 )
		playSoundFrontEnd(46)
		showCursor(false)
		guiSetVisible(chus, false)
		addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), swat )
	elseif row == 1 then 
  triggerServerEvent("spawnMilit", localPlayer)
  playSoundFrontEnd(46)
  		setTimer ( function()
		setElementModel ( localPlayer, 287 )
		end, 1000, 1 )
  		showCursor(false)
		guiSetVisible(chus, false)
  addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), milit )
        end 
    end 
end)

function swat()
		setTimer ( function()
		setElementModel ( localPlayer, 285 )
		end, 1000, 1 )
triggerServerEvent("spawnSwat2", localPlayer)
playSoundFrontEnd(46)
end

function milit()
  		setTimer ( function()
		setElementModel ( localPlayer, 287 )
		end, 1000, 1 )
triggerServerEvent("spawnMilit2", localPlayer)
playSoundFrontEnd(46)
end

------------------------------------------SERVER------------------------------------------------------

addEvent("spawnSwat", true)
function swat()
spawnPlayer(source, 61.94140625, 1930.7470703125, 17.640625)
fadeCamera (source, true)
setCameraTarget (source, source)
end
addEventHandler("spawnSwat", getRootElement(), swat)

addEvent("spawnMilit", true)
function military()
spawnPlayer(source, 187.92578125, 1909.6396484375, 17.66947555542)
fadeCamera (source, true)
setCameraTarget (source, source)
end
addEventHandler("spawnMilit", getRootElement(), military)



addEvent("spawnSwat2", true)
function swat2()

spawnPlayer(source, 61.94140625, 1930.7470703125, 17.640625)

fadeCamera (source, true)
setCameraTarget (source, source)
end
addEventHandler("spawnSwat2", getRootElement(), swat2)

addEvent("spawnMilit2", true)
function swat2()
spawnPlayer(source, 187.92578125, 1909.6396484375, 17.66947555542)

fadeCamera (source, true)
setCameraTarget (source, source)
end
addEventHandler("spawnMilit2", getRootElement(), swat2)

 

Link to comment
9 hours ago, <~KaMiKaZe~> said:

----------------------------------------------CLIENT------------------------------------------------------------------------------

function wey()
local screenW, screenH = guiGetScreenSize()
        chus = guiCreateWindow((screenW - 294) / 2, (screenH - 345) / 2, 294, 345, "Select your team !", false)
        guiWindowSetMovable(chus, false)
        guiWindowSetSizable(chus, false)

        gridlist = guiCreateGridList(12, 29, 267, 251, false, chus)
        guiGridListAddColumn(gridlist, "Teams", 0.9)
        for i = 1, 2 do
            guiGridListAddRow(gridlist)
        end
        guiGridListSetItemText(gridlist, 0, 1, "SWAT Team", false, false)
        guiGridListSetItemColor(gridlist, 0, 1, 0, 2, 124, 255)
        guiGridListSetItemText(gridlist, 1, 1, "Military Team", false, false)
        guiGridListSetItemColor(gridlist, 1, 1, 7, 125, 0, 255)
        boton = guiCreateButton(86, 296, 129, 38, "Play !", false, chus)    
		showCursor(true)
		end
addEventHandler( "onClientResourceStart", getRootElement(), wey)

addEventHandler("onClientGUIClick", guiRoot, 
function() 
    if source == boton then 
        local row = guiGridListGetSelectedItem(gridlist) 
        if row == 0 then 
		triggerServerEvent("spawnSwat", localPlayer)
		setTimer ( function()
		setElementModel ( localPlayer, 285 )
		end, 1000, 1 )
		playSoundFrontEnd(46)
		showCursor(false)
		guiSetVisible(chus, false)
		addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), swat )
	elseif row == 1 then 
  triggerServerEvent("spawnMilit", localPlayer)
  playSoundFrontEnd(46)
  		setTimer ( function()
		setElementModel ( localPlayer, 287 )
		end, 1000, 1 )
  		showCursor(false)
		guiSetVisible(chus, false)
  addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), milit )
        end 
    end 
end)

function swat()
		setTimer ( function()
		setElementModel ( localPlayer, 285 )
		end, 1000, 1 )
triggerServerEvent("spawnSwat2", localPlayer)
playSoundFrontEnd(46)
end

function milit()
  		setTimer ( function()
		setElementModel ( localPlayer, 287 )
		end, 1000, 1 )
triggerServerEvent("spawnMilit2", localPlayer)
playSoundFrontEnd(46)
end

------------------------------------------SERVER------------------------------------------------------

addEvent("spawnSwat", true)
function swat()
spawnPlayer(source, 61.94140625, 1930.7470703125, 17.640625)
fadeCamera (source, true)
setCameraTarget (source, source)
end
addEventHandler("spawnSwat", getRootElement(), swat)

addEvent("spawnMilit", true)
function military()
spawnPlayer(source, 187.92578125, 1909.6396484375, 17.66947555542)
fadeCamera (source, true)
setCameraTarget (source, source)
end
addEventHandler("spawnMilit", getRootElement(), military)



addEvent("spawnSwat2", true)
function swat2()

spawnPlayer(source, 61.94140625, 1930.7470703125, 17.640625)

fadeCamera (source, true)
setCameraTarget (source, source)
end
addEventHandler("spawnSwat2", getRootElement(), swat2)

addEvent("spawnMilit2", true)
function swat2()
spawnPlayer(source, 187.92578125, 1909.6396484375, 17.66947555542)

fadeCamera (source, true)
setCameraTarget (source, source)
end
addEventHandler("spawnMilit2", getRootElement(), swat2)

 

in this script can I add more than 2 teams?

Link to comment

Try using something like this

-- NOTE This code is not tested and may need to be edited to work properly.

-- Client Side
local teams = {}

function addTeam(name,color,type,spawnx,spawny,spawnz,camerax,cameray,cameraz,skins)
    if name and color and type and spawnx and spawny and spawnz and camerax and cameray and cameraz and skins then
    	local self = {}
    	self.name = name
    	self.color = color
    	self.type = type
    	self.skins = skins
    	self.spawnPos = Vector3(spawnx,spawny,spawnz)
    	self.cameraPos = Vector3(camerax,cameray,cameraz)
    	
    	table.insert(teams,self)
    	return self
    end
end

function createTeams()
    for i=1,#teams do
        createTeam(teams[i].name,teams[i].color)
    end
end

local selection = 1
function startSelection()
    for i=1,#teams do
        if i == selection then
            setCameraMatrix(teams[i].cameraPos,teams[i].spawnPos)
        end
    end
    bindKey('arrow_l','down',function()
        if selection-1 < 1 then
            selection = #teams
        else
            selection = selection-1
        end
    end)
    bindKey('arrow_r','down',function()
        if selection+1 > #teams then
            selection = 1
        else
            selection = selection+1
        end
    end)
    bindKey('enter','down',selectTeam)
end

function selectTeam()
    for i=1,#teams do
        if i == selection then
            triggerServerEvent('spawnPlayer',root,localPlayer,teams[i])
        end
    end
end

-- Server Side
addEvent('spawnPlayer',true)
addEventHandler('spawnPlayer',root,function(player,teamData)
    local skinID = math.random(1,#teamData.skins)
    spawnPlayer(player,teamData.spawnPos,0,teamData.skins[skinID])
    setCameraTarget(player,player)
end)

I hope this has helped you, have a nice day.

This is an example of how to use the code above.

addEventHandler('onClientResourceStart',resourceRoot,function()
    addTeam('Freeroam',{0,255,255},'player',0,0,0,20,20,5)
    startSelection()
end)

 

Link to comment
18 hours ago, <~KaMiKaZe~> said:




 
            
         
         

     
          
           
            
        
             
              
             
              
          
		
		
  

 
 
     
          
           
		
		  
		   
		   
		
		
		 
		   
	   
  
  
  		  
		   
		   
  		
		 
  addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), milit )
        end 
    end 
end)

function swat()
		setTimer ( function()
		setElementModel ( localPlayer, 285 )
		end, 1000, 1 )
triggerServerEvent("spawnSwat2", localPlayer)
playSoundFrontEnd(46)
end

function milit()
  		setTimer ( function()
		setElementModel ( localPlayer, 287 )
		end, 1000, 1 )
triggerServerEvent("spawnMilit2", localPlayer)
playSoundFrontEnd(46)
end

------------------------------------------SERVER------------------------------------------------------

addEvent("spawnSwat", true)
function swat()
spawnPlayer(source, 61.94140625, 1930.7470703125, 17.640625)
fadeCamera (source, true)
setCameraTarget (source, source)
end
addEventHandler("spawnSwat", getRootElement(), swat)

addEvent("spawnMilit", true)
function military()
spawnPlayer(source, 187.92578125, 1909.6396484375, 17.66947555542)
fadeCamera (source, true)
setCameraTarget (source, source)
end
addEventHandler("spawnMilit", getRootElement(), military)



addEvent("spawnSwat2", true)
function swat2()

spawnPlayer(source, 61.94140625, 1930.7470703125, 17.640625)

fadeCamera (source, true)
setCameraTarget (source, source)
end
addEventHandler("spawnSwat2", getRootElement(), swat2)

addEvent("spawnMilit2", true)
function swat2()
   

  
 

 

 

ok tudo certo, configurei de acordo como eu queria muito obrigado mesmo amigo..só falta algo se n for te encomodar me responder...Como consigo configurar ele para iniciar apos meu 'login"
Os 2 Abrem juntos entao n da para acesar nenhum dos 2

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