Jump to content

طلب فنكشات #


Recommended Posts

-- source code ( isPlayerInTeam ) -- 
  
function isPlayerInTeam(player, team) 
    assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring(player) .. "]") 
    assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring(team) .. "]") 
    return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true))) 
end 
  
-------------------- 
 bindKey(source,"s", 'down', "chatbox", saya) 
addCommandHandler("saya", function( plr, cmd,... ) 
  
if isPlayerInTeam(plr,"اسم_التيم") then 
  for _, v in ipairs ( getPlayersInTeam( "اسم_التيم"  ) ); 
     local table = {...} 
     text = table.concat(table," ") 
     outputChatBox(getPlayerName(plr).." : "..text, v[1],255,255,255,true) 
       end 
   end 
end) 
  

-- SERVER SIDE --

الكود سيرفر

جربه ورجع لي خبـر

Link to comment
-- source code ( isPlayerInTeam ) -- 
  
function isPlayerInTeam(player, team) 
    assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring(player) .. "]") 
    assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring(team) .. "]") 
    return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true))) 
end 
  
-------------------- 
 bindKey(source,"s", 'down', "chatbox", saya) 
addCommandHandler("saya", function( plr, cmd,... ) 
  
if isPlayerInTeam(plr,"اسم_التيم") then 
  for _, v in ipairs ( getPlayersInTeam( "اسم_التيم"  ) ); 
     local table = {...} 
     text = table.concat(table," ") 
     outputChatBox(getPlayerName(plr).." : "..text, v[1],255,255,255,true) 
       end 
   end 
end) 
  

-- SERVER SIDE --

الكود سيرفر

جربه ورجع لي خبـر

X

---------

جرب,

local teamName = "" -- إسم التيم 
local key = "" -- المفتاح 
  
addCommandHandler ( "teamChat", 
    function ( player, _, ... ) 
        local msg = table.concat ( { ... }, " " ); 
        local playerName = getPlayerName ( player ); 
        local playerTeam = getPlayerTeam ( player ); 
        if playerTeam and teamName then 
            local r, g, b = getTeamColor ( playerTeam ); 
            for _, players in ipairs ( getElementsByType ( "player" ) ) do 
                if playerTeam == teamName then 
                    outputChatBox ( "(" .. teamName .. ") " .. playerName .. ": #FFFFFF" .. msg, players, r, g, b, true ); 
                end 
            end 
        end 
    end 
); 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function (  ) 
        for _, players in ipairs ( getElementsByType ( "player" ) ) do 
            bindKey ( players, key, "down", "chatBox", "teamChat" ); 
        end 
    end 
); 
  
addEventHandler ( "onPlayerJoin", root, 
    function (  ) 
        bindKey ( source, key, "down", "chatBox", "teamChat" ); 
    end 
); 

Link to comment
local teamName = "" -- إسم التيم 
local key = "" -- الزر 
  
addCommandHandler("TeamChat", 
function (player, _, ...) 
    local msg = table.concat({...}, " ") 
    local pName = getPlayerName(player) 
    local team = getPlayerTeam(player) 
    if team and getTeamName(team) == teamName then 
        local r, g, b = getTeamColor(team) 
        for _, p in ipairs (getPlayersInTeam(team)) do 
            outputChatBox("("..teamName..") "..pName..": #FFFFFF"..msg, p, r, g, b, true) 
        end 
    else 
        if isKeyBound(player, key, "down", nothing) then 
            unbindKey(player, key, "down", "chatbox", "TeamChat") 
            unbindKey(player, key, "down", nothing) 
        end 
    end 
end) 
  
addEventHandler("onResourceStart", resourceRoot, 
function() 
    for i, player in ipairs (getElementsByType("player")) do 
        local team = getPlayerTeam(player) 
        if team and getTeamName(team) == teamName then 
            bindKey(player, key, "down", "chatbox", "TeamChat") 
            bindKey(player, key, "down", nothing) 
        end 
    end 
end) 
  
addEventHandler("onPlayerSpawn", root, 
function() 
    local team = getPlayerTeam(source) 
    if team and getTeamName(team) == teamName then 
        if not isKeyBound(source, key, "down", nothing) then 
            bindKey(source, key, "down", "chatbox", "TeamChat") 
            bindKey(source, key, "down", nothing) 
        end 
    else 
        if isKeyBound(source, key, "down", nothing) then 
            unbindKey(source, key, "down", "chatbox", "TeamChat") 
            unbindKey(source, key, "down", nothing) 
        end 
    end 
end) 
  
function nothing() 
end 

Link to comment
تأكد انك حاطه سيرفر سايد

و وريني تعديلك على الكود

Server Side : !!!

local teamName = "Gan"  
local key = "m"  
  
addCommandHandler("TeamChat", 
function (player, _, ...) 
    local msg = table.concat({...}, " ") 
    local pName = getPlayerName(player) 
    local team = getPlayerTeam(player) 
    if team and getTeamName(team) == teamName then 
        local r, g, b = getTeamColor(team) 
        for _, p in ipairs (getPlayersInTeam(team)) do 
            outputChatBox("("..teamName..") "..pName..": #FFFFFF"..msg, p, r, g, b, true) 
        end 
    else 
        if isKeyBound(player, key, "down", nothing) then 
            unbindKey(player, key, "down", "chatbox", "TeamChat") 
            unbindKey(player, key, "down", nothing) 
        end 
    end 
end) 
  
addEventHandler("onResourceStart", resourceRoot, 
function() 
    for i, player in ipairs (getElementsByType("player")) do 
        local team = getPlayerTeam(player) 
        if team and getTeamName(team) == teamName then 
            bindKey(player, key, "down", "chatbox", "TeamChat") 
            bindKey(player, key, "down", nothing) 
        end 
    end 
end) 
  
addEventHandler("onPlayerSpawn", root, 
function() 
    local team = getPlayerTeam(source) 
    if team and getTeamName(team) == teamName then 
        if not isKeyBound(source, key, "down", nothing) then 
            bindKey(source, key, "down", "chatbox", "TeamChat") 
            bindKey(source, key, "down", nothing) 
        end 
    else 
        if isKeyBound(source, key, "down", nothing) then 
            unbindKey(source, key, "down", "chatbox", "TeamChat") 
            unbindKey(source, key, "down", nothing) 
        end 
    end 
end) 
  
function nothing() 
end 

Link to comment
تأكد انك حاطه سيرفر سايد

و وريني تعديلك على الكود

Server Side : !!!

local teamName = "Gan"  
local key = "m"  
  
addCommandHandler("TeamChat", 
function (player, _, ...) 
    local msg = table.concat({...}, " ") 
    local pName = getPlayerName(player) 
    local team = getPlayerTeam(player) 
    if team and getTeamName(team) == teamName then 
        local r, g, b = getTeamColor(team) 
        for _, p in ipairs (getPlayersInTeam(team)) do 
            outputChatBox("("..teamName..") "..pName..": #FFFFFF"..msg, p, r, g, b, true) 
        end 
    else 
        if isKeyBound(player, key, "down", nothing) then 
            unbindKey(player, key, "down", "chatbox", "TeamChat") 
            unbindKey(player, key, "down", nothing) 
        end 
    end 
end) 
  
addEventHandler("onResourceStart", resourceRoot, 
function() 
    for i, player in ipairs (getElementsByType("player")) do 
        local team = getPlayerTeam(player) 
        if team and getTeamName(team) == teamName then 
            bindKey(player, key, "down", "chatbox", "TeamChat") 
            bindKey(player, key, "down", nothing) 
        end 
    end 
end) 
  
addEventHandler("onPlayerSpawn", root, 
function() 
    local team = getPlayerTeam(source) 
    if team and getTeamName(team) == teamName then 
        if not isKeyBound(source, key, "down", nothing) then 
            bindKey(source, key, "down", "chatbox", "TeamChat") 
            bindKey(source, key, "down", nothing) 
        end 
    else 
        if isKeyBound(source, key, "down", nothing) then 
            unbindKey(source, key, "down", "chatbox", "TeamChat") 
            unbindKey(source, key, "down", nothing) 
        end 
    end 
end) 
  
function nothing() 
end 

Link to comment

onPlayerSpawn تشوف الكود الي داخل افنت

استبدل الأفنت بالي تحسه مناسب لك مع تعديل ما يلزم بالكود بحسب الأفنت او التايمر ان كنت بتستخدم تايمر

Link to comment
onPlayerSpawn تشوف الكود الي داخل افنت

استبدل الأفنت بالي تحسه مناسب لك مع تعديل ما يلزم بالكود بحسب الأفنت او التايمر ان كنت بتستخدم تايمر

لقيت كل هذا : اعرفهم كلهم # لاكن ابي واحد منهم يجيب الامر على طوول يعني مب لازم اموت او اسجل دخولي عشان يشتغل

onPlayerBan 
onPlayerChat 
onPlayerPrivateMessage 
onPlayerConnect 
onPlayerChangeNick 
onPlayerLogin 
onPlayerLogout 
onPlayerDamage 
onPlayerJoin 
onPlayerQuit 
onPlayerSpawn 
onPlayerWasted 
onPlayerTarget 
onPlayerVehicleEnter 
onPlayerVehicleExit 
onPlayerWeaponSwitch 
onPlayerMarkerHit 
onPlayerMarkerLeave 
onPlayerPickupHit 
onPlayerPickupUse 
onPlayerClick 
onPlayerContact 
onPlayerStealthKill 
onPlayerMute 
onPlayerUnmute 
onPlayerCommand 
onPlayerModInfo 
onPlayerVoiceStart 
onPlayerVoiceStop 
onPlayerScreenShot 

Link to comment
سوي تايمر و جيب كل الاعبين و اذا كان في التيم يسوي بند و اذا ما كان يشيل البند
  
setTimer (  
function() 
            local team = getPlayerTeam(source) 
    if team and getTeamName(team) == teamName then 
        if not isKeyBound(source, key, "down", nothing) then 
            bindKey(source, key, "down", "chatbox", "Chat") 
            bindKey(source, key, "down", nothing) 
    end, 5000, 1 ) 
    else 
        if isKeyBound(source, key, "down", nothing) then 
            unbindKey(source, key, "down", "chatbox", "Chat") 
            unbindKey(source, key, "down", nothing) 
        end 
    end 
end) 
  
function nothing() 
end 

Edited by Guest
Link to comment
setTimer( 
function() 
    for k,v in ipairs(getElementsByType ( "player" )) do 
        local team = getPlayerTeam(v) 
        if team and getTeamName(team) == teamName then 
            if not isKeyBound(v, key, "down", nothing) then 
                bindKey(v, key, "down", "chatbox", "TeamChat") 
                bindKey(v, key, "down", nothing) 
            end 
        else 
            if isKeyBound(v, key, "down", nothing) then 
                unbindKey(v, key, "down", "chatbox", "TeamChat") 
                unbindKey(v, key, "down", nothing) 
            end 
        end 
    end 
end,100,0) 

Link to comment
setTimer( 
function() 
    for k,v in ipairs(getElementsByType ( "player" )) do 
        local team = getPlayerTeam(v) 
        if team and getTeamName(team) == teamName then 
            if not isKeyBound(v, key, "down", nothing) then 
                bindKey(v, key, "down", "chatbox", "TeamChat") 
                bindKey(v, key, "down", nothing) 
            end 
        else 
            if isKeyBound(v, key, "down", nothing) then 
                unbindKey(v, key, "down", "chatbox", "TeamChat") 
                unbindKey(v, key, "down", nothing) 
            end 
        end 
    end 
end,100,0) 

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