Jump to content

استفسار


Recommended Posts

كيف استعمل TriggerClientEvent

ب arguments من الكلاينت سايد

مثلا انا عايز لما اضغط في الGridlist

اغير الفريق تبعي علي حسب الفريق اللي انا اخترته

--Client
function clientsideResourceStart ()
    local screenW, screenH = guiGetScreenSize()
    teamsWin = guiCreateWindow((screenW - 615) / 2, (screenH - 541) / 2, 615, 541, "Team System </> ProMax", false)
        guiWindowSetSizable(teamsWin, false)
        guiSetVisible(teamsWin,false)
        local joinBTN = guiCreateButton(47, 434, 148, 54, "Join", false, teamsWin)
        local rfrshBTN =  guiCreateButton(230, 434, 148, 54, "Refresh", false, teamsWin)         
        
        teamList =  guiCreateGridList(27, 38, 558, 379, false, teamsWin) -- Create the grid list
    local column = guiGridListAddColumn( teamList, "team", 0.85 )
    if ( column ) then --If the column has been created, fill it with teams
        for id, team in ipairs ( getElementsByType ( "team" ) ) do
            local row = guiGridListAddRow ( teamList )
            local r, g, b = getTeamColor ( team ) -- We get the team nametag color.
            guiGridListSetItemText ( teamList, row, column, getTeamName ( team ), false, false )
            guiGridListSetItemColor ( teamList, row, column, r, g, b ) -- We set the grid list item color to the returned values of getteamNametagColor.
        end
    end
end
addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart )

function ToggleWND()
if guiGetVisible(teamsWin) == false 
    then    
            showCursor(true)
            guiSetVisible(teamsWin,true)
                elseif 
                    guiGetVisible(teamsWin) == true 
                        then 
                            guiSetVisible(teamsWin,false)
               end
           end
addEventHandler ( "onClientResourceStart", resourceRoot, 
function ()
bindKey("F3","down",ToggleWND)
end)
addEventHandler( "onClientGUIDoubleClick", teamList, 
function ( button )
    if ( button == "left" ) then
        if ( source == aTeamList ) then
        if ( guiGridListGetSelectedItem ( teamList ) ~= -1 ) then
        local team = guiGridListGetItemText ( teamList, guiGridListGetSelectedItem ( teamList ), 1 )
        triggerServerEvent ( "aPlayer", getLocalPlayer(), teamSelect, getTeamFromName ( team ) )
               end
        end
    end
    end)
 

--------------------------------

--server
addEvent("aPlayer",true)
addEventHandler("aPlayer",getRootElement(),
function ()
if ( getElementType ( data ) == "team" ) then
                setPlayerTeam ( player, data )
                mdata = getTeamName ( data )
                end 
                end )

السيرفير سايد اخذتها من الادمن بانل بصراحة حاولت اجرب يمكن تشتغل بس ماشتغلت 

Link to comment

تفضل اخوي

--Client
function clientsideResourceStart ()
    local screenW, screenH = guiGetScreenSize()
    teamsWin = guiCreateWindow((screenW - 615) / 2, (screenH - 541) / 2, 615, 541, "Team System </> ProMax", false)
        guiWindowSetSizable(teamsWin, false)
        guiSetVisible(teamsWin,false)
        joinBTN = guiCreateButton(47, 434, 148, 54, "Join", false, teamsWin)
        rfrshBTN =  guiCreateButton(230, 434, 148, 54, "Refresh", false, teamsWin)         
        
        teamList =  guiCreateGridList(27, 38, 558, 379, false, teamsWin) -- Create the grid list
		guiGridListAddColumn( teamList, "team", 0.85 )
end
addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart )

function refresh()
guiGridListClear(teamList)
    for id, team in ipairs ( getElementsByType ( "team" ) ) do
    local row = guiGridListAddRow ( teamList )
    local r, g, b = getTeamColor ( team )
    guiGridListSetItemText ( teamList, row, 1, getTeamName ( team ), false, false )
    guiGridListSetItemColor ( teamList, row, 1, r, g, b )
	end
end

function ToggleWND()
if guiGetVisible(teamsWin) == false 
    then    
            showCursor(true)
            guiSetVisible(teamsWin,true)
			refresh()
                elseif 
                    guiGetVisible(teamsWin) == true 
                        then 
                            guiSetVisible(teamsWin,false)
							showCursor ( false )
               end
           end
bindKey("F3","down",ToggleWND)

addEventHandler( "onClientGUIDoubleClick", root, 
function ( button )
	if button == "left" then
        if ( source == teamList ) then
        if ( guiGridListGetSelectedItem ( teamList ) ~= -1 ) then
        local team = guiGridListGetItemText ( teamList, guiGridListGetSelectedItem ( teamList ), 1 )
        triggerServerEvent ( "setPTeam", getLocalPlayer(), team )
        end
	end
end
end)
 
 
addEventHandler("onClientGUIClick",root, function()
	if source == rfrshBTN then
		refresh()
	elseif source == joinBTN then
		if ( guiGridListGetSelectedItem ( teamList ) ~= -1 ) then
		local team =guiGridListGetItemText ( teamList, guiGridListGetSelectedItem ( teamList ), 1 ) 
		triggerServerEvent ( "setPTeam", getLocalPlayer(), team )
		end
	end
end
)
--Server
addEvent("setPTeam",true)
addEventHandler("setPTeam",getRootElement(),
function (name)
local team = getTeamFromName(name)
local old = getPlayerTeam ( source )
	if old ~= team then
     setPlayerTeam ( source, team ) 
	 outputChatBox("#ccccccYou have been moved to the #ffffff"..getTeamName(team).." #ccccccteam",source,255,255,255,true)
	else
	outputChatBox("#ff0000You already in this team",source,255,0,0,true)
	end
end )

 

Link to comment
1 hour ago, Rakan# said:

تفضل اخوي


--Client
function clientsideResourceStart ()
    local screenW, screenH = guiGetScreenSize()
    teamsWin = guiCreateWindow((screenW - 615) / 2, (screenH - 541) / 2, 615, 541, "Team System </> ProMax", false)
        guiWindowSetSizable(teamsWin, false)
        guiSetVisible(teamsWin,false)
        joinBTN = guiCreateButton(47, 434, 148, 54, "Join", false, teamsWin)
        rfrshBTN =  guiCreateButton(230, 434, 148, 54, "Refresh", false, teamsWin)         
        
        teamList =  guiCreateGridList(27, 38, 558, 379, false, teamsWin) -- Create the grid list
		guiGridListAddColumn( teamList, "team", 0.85 )
end
addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart )

function refresh()
guiGridListClear(teamList)
    for id, team in ipairs ( getElementsByType ( "team" ) ) do
    local row = guiGridListAddRow ( teamList )
    local r, g, b = getTeamColor ( team )
    guiGridListSetItemText ( teamList, row, 1, getTeamName ( team ), false, false )
    guiGridListSetItemColor ( teamList, row, 1, r, g, b )
	end
end

function ToggleWND()
if guiGetVisible(teamsWin) == false 
    then    
            showCursor(true)
            guiSetVisible(teamsWin,true)
			refresh()
                elseif 
                    guiGetVisible(teamsWin) == true 
                        then 
                            guiSetVisible(teamsWin,false)
							showCursor ( false )
               end
           end
bindKey("F3","down",ToggleWND)

addEventHandler( "onClientGUIDoubleClick", root, 
function ( button )
	if button == "left" then
        if ( source == teamList ) then
        if ( guiGridListGetSelectedItem ( teamList ) ~= -1 ) then
        local team = guiGridListGetItemText ( teamList, guiGridListGetSelectedItem ( teamList ), 1 )
        triggerServerEvent ( "setPTeam", getLocalPlayer(), team )
        end
	end
end
end)
 
 
addEventHandler("onClientGUIClick",root, function()
	if source == rfrshBTN then
		refresh()
	elseif source == joinBTN then
		if ( guiGridListGetSelectedItem ( teamList ) ~= -1 ) then
		local team =guiGridListGetItemText ( teamList, guiGridListGetSelectedItem ( teamList ), 1 ) 
		triggerServerEvent ( "setPTeam", getLocalPlayer(), team )
		end
	end
end
)

--Server
addEvent("setPTeam",true)
addEventHandler("setPTeam",getRootElement(),
function (name)
local team = getTeamFromName(name)
local old = getPlayerTeam ( source )
	if old ~= team then
     setPlayerTeam ( source, team ) 
	 outputChatBox("#ccccccYou have been moved to the #ffffff"..getTeamName(team).." #ccccccteam",source,255,255,255,true)
	else
	outputChatBox("#ff0000You already in this team",source,255,0,0,true)
	end
end )

 

شكرا اخي بس انا كذا ما تعلمت اي شي

Link to comment
1 minute ago, Deep thinker said:

triggerServerEvent كيف استعملتها وكيف عرفت التيم

خليت ال onClientGUIDoubleClick روت باختصار لجميع ال GUI بسبب انك معرفه if source == teamList then

وخليت حق التيم اللي يطلع بـ فنكشن عشان طريقتك لازم رستارت للمود , وسويت لها guiGridListClear عشان مايتكرر التيمات

وارسلت  للترايقر بس اسم التيم وبالسيرفر جبت التيم من اسمه getTeamFromName وتحققت ان التيم حق اللاعب مايساوي التيم اللي بيدخله

ودخلته التيم , وغيرت اسم الترايقر لانه نفس ترايقر اللوحه فـ اكيد بيخرب وانت ماعرفت التيم بـ السيرفر وكان مخبص السيرفر م ادري وش مكتوب به

لو مافهمت شي قل لي , اعرف شرحي غبي معليش :lol: 

Link to comment
2 minutes ago, Rakan# said:

خليت ال onClientGUIDoubleClick روت باختصار لجميع ال GUI بسبب انك معرفه if source == teamList then

وخليت حق التيم اللي يطلع بـ فنكشن عشان طريقتك لازم رستارت للمود , وسويت لها guiGridListClear عشان مايتكرر التيمات

وارسلت  للترايقر بس اسم التيم وبالسيرفر جبت التيم من اسمه getTeamFromName وتحققت ان التيم حق اللاعب مايساوي التيم اللي بيدخله

ودخلته التيم , وغيرت اسم الترايقر لانه نفس ترايقر اللوحه فـ اكيد بيخرب وانت ماعرفت التيم بـ السيرفر وكان مخبص السيرفر م ادري وش مكتوب به

لو مافهمت شي قل لي , اعرف شرحي غبي معليش :lol: 

للاسف ما فهمت :lol:

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