كيف استعمل 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 )
السيرفير سايد اخذتها من الادمن بانل بصراحة حاولت اجرب يمكن تشتغل بس ماشتغلت