Jump to content

Add


ZeyadGTX

Recommended Posts

Hello I have Resource but i need to modify this lines bec there are buttons to add in teams

and this is ADD functions its not working

addEvent("addToTeam", true) 
addEventHandler("addToTeam", root, function() 
  local player = getPlayerFromName() 
  local team = getTeamFromName() 
  if player and team then 
    local r, g, b = getTeamColor(team) 
    setPlayerTeam(player, team) 
    setPlayerNametagColor(player, r, g, b) 
    outputChatBox("You have been moved to #FFFFFF" .. getTeamName(team) .. "#FF0000.", player, 255, 0, 0, true) 
  end 
end 
) 

My buttons Client Side :

Clan.Button[1] = guiCreateButton(204, 51, 106, 38, "Add", false, Clan.Window[1]) 
Clan.Button[2] = guiCreateButton(204, 96, 106, 38, "Kick", false, Clan.Window[1]) 
Clan.Button[3] = guiCreateButton(204, 144, 106, 38, "Promote", false, Clan.Window[1]) 
Clan.Button[4] = guiCreateButton(204, 192, 106, 38, "Demote", false, Clan.Window[1]) 
Clan.Button[5] = guiCreateButton(204, 288, 106, 38, "Close", false, Clan.Window[1]) 
Clan.Button[6] = guiCreateButton(13, 62, 87, 23, "Cancel", false, Clan.Window[2]) 
Clan.Button[7] = guiCreateButton(143, 62, 87, 23, "Set", false, Clan.Window[2]) 
Clan.Button[8] = guiCreateButton(13, 62, 87, 23, "Cancel", false, Clan.Window[3]) 
Clan.Button[9] = guiCreateButton(143, 62, 87, 23, "Set", false, Clan.Window[3]) 
Clan.Edit[1] = guiCreateEdit(13, 29, 227, 28, "", false, Clan.Window[2]) 
Clan.Edit[2] = guiCreateEdit(13, 29, 227, 28, "", false, Clan.Window[3]) 
guiSetVisible(Clan.Window[1], false) 
guiSetVisible(Clan.Window[2], false) 
guiSetVisible(Clan.Window[3], false) 

Link to comment

Post client side to help u about the arguments u need to pass getPkayerFromName(here u need a player name) also u can use client or source in this function as the player and u need to pass the team using the triggerServerEvent or get it from an account data post the client side part when u trigger this event

Link to comment

Ok

Client Side

local sx, sy = guiGetScreenSize ( ) 
local y = sy + 20
 
function onRankUpGreet()
    dxDrawRectangle(sx*(707/1024), sy*(425/768), sx*(115/1024), sy*(27/768), tocolor(44, 44, 44, 221), true)
    dxDrawText("Rank up+", sx*(716/1024), sy*(429/768), sx*(808/1024), sy*(448/768), tocolor(0, 255, 0, 221), 0.70, "bankgothic", "left", "top", false, false, true, false, false)
end
 
function onTestExp( )
    if ( y > ( sy / 2 ) ) then
        y = y - 2
    elseif ( y < ( sy / 2 ) ) then
        y = ( sy / 2 )
    end
    dxDrawText ( "+"..tostring(experience).." XP", 400, y, sx, 200, tocolor(255, 255, 0, 255), 0.7, "bankgothic")
end
 
addEvent("onTestExp", true)
addEventHandler( "onTestExp", root,
function(expe)
    if not isTimer(expTimer) then
        expTimer = setTimer(function()
            removeEventHandler("onClientRender", root, onTestExp)
        end, 6000, 1)
        experience = expe
        addEventHandler("onClientRender", root, onTestExp)
    else
        experience = (experience + expe)
        resetTimer(expTimer)
    end
end)
 
function onRankUp( killer )
    local sound = playSound("sounds/level.mp3")
    setSoundVolume(sound, 50)
    setSoundMaxDistance( sound, 5000 )
    addEventHandler("onClientRender", root, onRankUpGreet)
        setTimer(
        function ()
                removeEventHandler ( "onClientRender", root, onRankUpGreet )
        end, 6000, 1)
end
addEvent( "onClientRankUp", true )
addEventHandler( "onClientRankUp", getRootElement(), onRankUp )
 
function getXP ( _, playerName )
    if ( playerName ) then
        local thePlayer = getPlayerFromParticalName ( playerName )
        if ( thePlayer ) then
            local Level = getElementData(thePlayer,"LV") or 0
            local XP = getElementData(thePlayer,"EXP") or 0
            outputChatBox ( getPlayerName ( thePlayer ) .." XP ".. tostring ( XP ) .." LV:".. tostring ( Level ) .." " ,0,255,200)
        else
            outputChatBox ( "Couldn't find '" .. playerName .. "'", source )
        end
    end
end
addCommandHandler ( "getxp", getXP )
addCommandHandler ( "getXP", getXP )
 
function getPlayerFromParticalName(thePlayerName)
    local thePlayer = getPlayerFromName(thePlayerName)
    if thePlayer then
        return thePlayer
    end
    for _,thePlayer in ipairs(getElementsByType("player")) do
        if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then
            return thePlayer
        end
    end
return false
end
 
Clan = {
    Button = {},
    Window = {},
    Gridlist = {},
    Edit = {}
}
Clan.Window[1] = guiCreateWindow(306, 174, 320, 346, "Clan panel", false)
guiWindowSetSizable(Clan.Window[1], false)
Clan.Window[2] = guiCreateWindow(401, 281, 252, 99, "Set Player Rank", false)
guiWindowSetSizable(Clan.Window[2], false)
Clan.Window[3] = guiCreateWindow(401, 281, 252, 99, "Set Player Rank", false)
guiWindowSetSizable(Clan.Window[3], false)
 
Clan.Gridlist[1] = guiCreateGridList(9, 25, 188, 311, false, Clan.Window[1])
local column = guiGridListAddColumn(Clan.Gridlist[1], "Players", 0.9)
if ( column ) then --If the column has been created, fill it with players
    for _,v in ipairs(getElementsByType("player"))do
        local row = guiGridListAddRow(Clan.Gridlist[1])
        local players = getPlayerName(v)
        guiGridListSetItemText(Clan.Gridlist[1],row,column,players,false,false)
    end
end
Clan.Button[1] = guiCreateButton(204, 51, 106, 38, "Add", false, Clan.Window[1])
Clan.Button[2] = guiCreateButton(204, 96, 106, 38, "Kick", false, Clan.Window[1])
Clan.Button[3] = guiCreateButton(204, 144, 106, 38, "Promote", false, Clan.Window[1])
Clan.Button[4] = guiCreateButton(204, 192, 106, 38, "Demote", false, Clan.Window[1])
Clan.Button[5] = guiCreateButton(204, 288, 106, 38, "Close", false, Clan.Window[1])
Clan.Button[6] = guiCreateButton(13, 62, 87, 23, "Cancel", false, Clan.Window[2])
Clan.Button[7] = guiCreateButton(143, 62, 87, 23, "Set", false, Clan.Window[2])
Clan.Button[8] = guiCreateButton(13, 62, 87, 23, "Cancel", false, Clan.Window[3])
Clan.Button[9] = guiCreateButton(143, 62, 87, 23, "Set", false, Clan.Window[3])
Clan.Edit[1] = guiCreateEdit(13, 29, 227, 28, "", false, Clan.Window[2])
Clan.Edit[2] = guiCreateEdit(13, 29, 227, 28, "", false, Clan.Window[3])
guiSetVisible(Clan.Window[1], false)
guiSetVisible(Clan.Window[2], false)
guiSetVisible(Clan.Window[3], false)
showCursor(false)
if getElementData(localPlayer, "clan.rank") == "leader" or getElementData(localPlayer, "player.key") == "Zeyad" or getElementData(localPlayer, "player.key") == "" or getElementData(localPlayer, "player.key") == "" or getElementData(localPlayer, "player.key") == "" then
guiSetEnabled(Clan.Button[3], true)
guiSetEnabled(Clan.Button[4], true)
else
guiSetEnabled(Clan.Button[3], false)
guiSetEnabled(Clan.Button[4], false)
end
 
function toggleClanControl( source )
if getElementData(localPlayer, "player.key") == "Zeyad" or getElementData(localPlayer, "player.key") == "Azer" or getElementData(localPlayer, "player.key") == "ryder" or getElementData(localPlayer, "player.key") == "Sayari" then
    if not guiGetVisible( Clan.Window[1] ) then
        showCursor ( true )
        guiSetVisible( Clan.Window[1], true )
        guiGridListClear ( Clan.Gridlist[1] )
        if ( column ) then
            guiGridListClear ( Clan.Gridlist[1] )
            for _,v in ipairs(getElementsByType("player"))do
                local row = guiGridListAddRow(Clan.Gridlist[1])
                local playerName = getPlayerName(v)
                guiGridListSetItemText(Clan.Gridlist[1],row,column,playerName,false,false)
            end
        end
        if getElementData(localPlayer, "clan.rank") == "leader" or getElementData(localPlayer, "player.key") == "Zeyad" or getElementData(localPlayer, "player.key") == "Azer" or getElementData(localPlayer, "player.key") == "ryder" or getElementData(localPlayer, "player.key") == "Script" then
            guiSetEnabled(Clan.Button[3], true)
            guiSetEnabled(Clan.Button[4], true)
        else
            guiSetEnabled(Clan.Button[3], false)
            guiSetEnabled(Clan.Button[4], false)
        end
    else
        showCursor ( false )
        guiSetVisible( Clan.Window[1], false )
    end
end
end
bindKey( "M", "down", toggleClanControl )
addCommandHandler("clan", toggleClanControl)
 
addEventHandler("onClientGUIClick", guiRoot,
function()
    if source == Clan.Button[1] then
        local row, column = guiGridListGetSelectedItem(Clan.Gridlist[1])
        if row == -1 then return end
        local playerName = guiGridListGetItemText(Clan.Gridlist[1],row,column)
        local player = getPlayerFromName(playerName)
        local team = getPlayerTeam(localPlayer)
        local teamName = getTeamName(team)
        if not playerName then
            guiGridListRemoveRow(row)
            return
        end
            triggerServerEvent("addToTeam", localPlayer,playerName,teamName)
        end
end)
 
addEventHandler("onClientGUIClick", guiRoot,
function()
    if source == Clan.Button[2] then
        local row, column = guiGridListGetSelectedItem(Clan.Gridlist[1])
        if row == -1 then return end
        local playerName = guiGridListGetItemText(Clan.Gridlist[1],row,column)
        local player = getPlayerFromName(playerName)
        local team = getPlayerTeam(localPlayer)
        local teamName = getTeamName(team)
        if not playerName then
            guiGridListRemoveRow(row)
            return
        end
            triggerServerEvent("kickFromTeam", localPlayer,playerName,teamName)
        end
end)
 
function closeClan()
    if guiGetVisible(Clan.Window[1]) then
        guiSetVisible(Clan.Window[1],false)
        showCursor(false)
    end
end
addEventHandler ("onClientGUIClick", Clan.Button[5], closeClan, false)
 
function togglePromote( source )
-- Show the panel
    if not guiGetVisible( Clan.Window[2] ) then
        showCursor ( true )
        guiSetVisible( Clan.Window[2], true )
        guiMoveToBack( Clan.Window[1] )
    else
        showCursor ( true )
        guiSetVisible( Clan.Window[2], false )
    end
end
addEventHandler ( "onClientGUIClick", Clan.Button[3], togglePromote, false )
 
addEventHandler("onClientGUIClick",Clan.Button[7],
function()
        local row, column = guiGridListGetSelectedItem(Clan.Gridlist[1])
        if row == -1 then return end
        local playerName = guiGridListGetItemText(Clan.Gridlist[1],row,column)
        local player = getPlayerFromName(playerName)
        if not playerName then
        guiGridListRemoveRow(row)
        return
        end
    triggerServerEvent("promotePlayer",localPlayer,playerName,tostring(guiGetText(Clan.Edit[1])) or "Member")
    guiSetVisible( Clan.Window[2], false )
    showCursor ( true )
end,false)
 
function closeClan()
    if guiGetVisible(Clan.Window[2]) then
        guiSetVisible(Clan.Window[2],false)
        showCursor(true)
    end
end
addEventHandler ("onClientGUIClick", Clan.Button[6], closeClan, false)
 
function toggleDemote( source )
-- Show the panel
    if not guiGetVisible( Clan.Window[2] ) then
        showCursor ( true )
        guiSetVisible( Clan.Window[2], true )
        guiMoveToBack( Clan.Window[1] )
    else
        showCursor ( true )
        guiSetVisible( Clan.Window[2], false )
    end
end
addEventHandler ( "onClientGUIClick", Clan.Button[4], toggleDemote, false )
 
addEventHandler("onClientGUIClick",Clan.Button[9],
function()
        local row, column = guiGridListGetSelectedItem(Clan.Gridlist[1])
        if row == -1 then return end
        local playerName = guiGridListGetItemText(Clan.Gridlist[1],row,column)
        local player = getPlayerFromName(playerName)
        if not playerName then
        guiGridListRemoveRow(row)
        return
        end
    triggerServerEvent("DemotePlayer",localPlayer,playerName,tostring(guiGetText(Clan.Edit[2])) or "Member")
   
Link to comment

Thats

addEvent("addToTeam", true) 
addEventHandler("addToTeam", root, function (playerName, teamName) 
  local player = getPlayerFromName(playerName) 
  local team = getPlayerFromName(teamName) 
  if player and team then 
    local r, g, b = getTeamColor(team) 
    setPlayerTeam(player, team) 
    setPlayerNametagColor(player, r, g, b) 
    outputChatBox("You have been moved to #FFFFFF" .. getTeamName(team) .. "#FF0000.", player, 255, 0, 0, true) 
  end 
end 
) 

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