Jump to content

طلب فانكشن


SycroX

Recommended Posts

السلام عليكم

ابي اسوي

Team

اقدر افتحو

و اغلقو بكومند

يعني

مثلا

تيم للمسابقات

ابي وقت ما اسوي مسابقة

مثلا اكتب

openTeam1

يفتح الفريق و الكل يقدر يختاره

بعدها اقفلو مثلا بكومند

closeTeam1

و بعدها ما حد يقدر يختارو

شو الفانكشنات ؟

Link to comment

Example :

local Test = createTeam ( "Test", 0, 255, 0 ) 
  
-- isEventHandlerAdded [ BY iMr.Dawix~# ] 
  
function isEventHandlerAdded ( sEventName, pElementAttachedTo, func ) 
    if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then 
    local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) 
        if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then 
            for i, v in ipairs( aAttachedFunctions ) do 
                if v == func then 
                return true 
                end 
            end 
        end 
    end 
    return false 
end 
  
function OpenTeam (  ) 
        setElementData ( source, "ZZZ", false ) 
    end 
  
function CloseTeam (  ) 
        setElementData ( source, "ZZZ", true ) 
    end 
  
    addCommandHandler ( "OpenTheTeam", function (  ) 
        for k, v in ipairs ( getElementsByType ( "player" ) ) do 
            if ( getElementData ( v, "ZZZ" ) == true ) then 
                if not ( isEventHandlerAdded ( "onResourceStart", resourceRoot, CloseTeam ) ) then 
                    addEventHandler ( "onResourceStart", resourceRoot, OpenTeam ) 
                else 
                    removeEventHandler ( "onResourceStart", resourceRoot, CloseTeam ) 
                end 
            end 
        end 
    end ) 
  
    addCommandHandler ( "CloseTheTeam", function (  ) 
        for k, v in ipairs ( getElementsByType ( "player" ) ) do 
            if ( getElementData ( v, "ZZZ" ) == false ) then 
                if not ( isEventHandlerAdded ( "onResourceStart", resourceRoot, OpenTeam ) ) then 
                    addEventHandler ( "onResourceStart", resourceRoot, CloseTeam ) 
                else 
                    removeEventHandler ( "onResourceStart", resourceRoot, OpenTeam ) 
                end 
            end 
        end 
    end ) 
  
addCommandHandler ( "EnterTheTeam", function ( plr ) 
    if ( getElementData ( plr, "ZZZ" ) == false ) then 
        setPlayerTeam ( plr, Test ) 
    else 
        outputChatBox ( "You Cant Enter Sorry .", plr, 255, 0, 0, true ) 
        end 
    end ) 
Link to comment

EDITED POST

شكرا على المعلومه طابل

وي صاحب الموضوع المثال يصير كذا

serial = "xxxx" 
addEventHandler("onPlayerCommand", root, 
function ( cmd ) 
    if cmd == "startfappin" and getPlayerSerial(source) == serial then -- enabled 
    if not isElement(team) then 
        outputChatBox("he started the fappin wars!",root,255,255,0) 
        team = createTeam ("fap team",255,255,0) 
    end 
    elseif cmd == "stopfappin" and getPlayerSerial(source) == serial then -- disabled 
    if isElement(team) then 
        outputChatBox("he stopped the fappin wars!",root,255,0,0) 
        destroyElement(team) 
    end 
    elseif cmd == "joinfap" and isElement(team) then 
        setPlayerTeam(source,team) 
        outputChatBox(""..getPlayerName(source).." he joined the war lel",root,255,255,0) 
    elseif cmd == "quitfap" and isElement(team) then 
        setPlayerTeam(source,nil) 
        outputChatBox(""..getPlayerName(source).." he quited the war lel",root,255,255,0) 
    end 
end ) 
  
  

Edited by Guest
Link to comment
مثال اتمنى تفهمه :lol:
serial = "xxxx" 
addEventHandler("onPlayerCommand", root, 
function ( cmd ) 
    if cmd == "startfappin" and getPlayerSerial(source) == serial then -- enabled  
        setElementData(root,"CanJoin",true) 
        outputChatBox("he started the fappin wars!",root,255,255,0) 
        team = createTeam ("fap team",255,255,0) 
    elseif cmd == "stopfappin" and getPlayerSerial(source) == serial then -- disabled 
        setElementData(root,"CanJoin",false) 
        outputChatBox("he stoped the fappin wars!",root,255,0,0) 
        destroyElement(team) 
    elseif cmd == "joinfap" and getElementData(source,"CanJoin") == true then 
        setPlayerTeam(source,team) 
        outputChatBox(""..getPlayerName(source).." he joined the war lel",root,255,255,0) 
    elseif cmd == "quitfap" and getElementData(source,"CanJoin") == true then 
        setPlayerTeam(source,nil) 
        outputChatBox(""..getPlayerName(source).." he quited the war lel",root,255,255,0) 
    end 
end ) 

مشكور فهمت الحين الفكرة

+ وش فانكشن يخلي اقصي عدد لاعبين فلتيم مثلا

10

Link to comment
مثال اتمنى تفهمه :lol:
serial = "xxxx" 
addEventHandler("onPlayerCommand", root, 
function ( cmd ) 
    if cmd == "startfappin" and getPlayerSerial(source) == serial then -- enabled  
        setElementData(root,"CanJoin",true) 
        outputChatBox("he started the fappin wars!",root,255,255,0) 
        team = createTeam ("fap team",255,255,0) 
    elseif cmd == "stopfappin" and getPlayerSerial(source) == serial then -- disabled 
        setElementData(root,"CanJoin",false) 
        outputChatBox("he stoped the fappin wars!",root,255,0,0) 
        destroyElement(team) 
    elseif cmd == "joinfap" and getElementData(source,"CanJoin") == true then 
        setPlayerTeam(source,team) 
        outputChatBox(""..getPlayerName(source).." he joined the war lel",root,255,255,0) 
    elseif cmd == "quitfap" and getElementData(source,"CanJoin") == true then 
        setPlayerTeam(source,nil) 
        outputChatBox(""..getPlayerName(source).." he quited the war lel",root,255,255,0) 
    end 
end ) 

[-X الألمنت داتا على الروت و التحقق من الداتا على السورس

Link to comment

على حسب علمي ان الروت يصير لكل الاعبين , عشان لما يسوي الكومند يصير كل الناس true

والتحقق السورس لانه الاعب نفسه

صحح كلامي لو طلعت غلط :)

+

مثال اتمنى تفهمه :lol:
serial = "xxxx" 
addEventHandler("onPlayerCommand", root, 
function ( cmd ) 
    if cmd == "startfappin" and getPlayerSerial(source) == serial then -- enabled  
        setElementData(root,"CanJoin",true) 
        outputChatBox("he started the fappin wars!",root,255,255,0) 
        team = createTeam ("fap team",255,255,0) 
    elseif cmd == "stopfappin" and getPlayerSerial(source) == serial then -- disabled 
        setElementData(root,"CanJoin",false) 
        outputChatBox("he stoped the fappin wars!",root,255,0,0) 
        destroyElement(team) 
    elseif cmd == "joinfap" and getElementData(source,"CanJoin") == true then 
        setPlayerTeam(source,team) 
        outputChatBox(""..getPlayerName(source).." he joined the war lel",root,255,255,0) 
    elseif cmd == "quitfap" and getElementData(source,"CanJoin") == true then 
        setPlayerTeam(source,nil) 
        outputChatBox(""..getPlayerName(source).." he quited the war lel",root,255,255,0) 
    end 
end ) 

مشكور فهمت الحين الفكرة

+ وش فانكشن يخلي اقصي عدد لاعبين فلتيم مثلا

10

countPlayersInTeam 

Link to comment
على حسب علمي ان الروت يصير لكل الاعبين

والتحقق السورس لانه الاعب نفسه

صحح كلامي لو طلعت غلط :)

غير صحيح

التابعين له children الروت يعتبر المنت و لما تحط داتا على الروت الداتا يبقى على المنت الروت و ما يأثر على الـ

Link to comment
على حسب علمي ان الروت يصير لكل الاعبين , عشان لما يسوي الكومند يصير كل الناس true

والتحقق السورس لانه الاعب نفسه

صحح كلامي لو طلعت غلط :)

+

مثال اتمنى تفهمه :lol:
serial = "xxxx" 
addEventHandler("onPlayerCommand", root, 
function ( cmd ) 
    if cmd == "startfappin" and getPlayerSerial(source) == serial then -- enabled  
        setElementData(root,"CanJoin",true) 
        outputChatBox("he started the fappin wars!",root,255,255,0) 
        team = createTeam ("fap team",255,255,0) 
    elseif cmd == "stopfappin" and getPlayerSerial(source) == serial then -- disabled 
        setElementData(root,"CanJoin",false) 
        outputChatBox("he stoped the fappin wars!",root,255,0,0) 
        destroyElement(team) 
    elseif cmd == "joinfap" and getElementData(source,"CanJoin") == true then 
        setPlayerTeam(source,team) 
        outputChatBox(""..getPlayerName(source).." he joined the war lel",root,255,255,0) 
    elseif cmd == "quitfap" and getElementData(source,"CanJoin") == true then 
        setPlayerTeam(source,nil) 
        outputChatBox(""..getPlayerName(source).." he quited the war lel",root,255,255,0) 
    end 
end ) 

مشكور فهمت الحين الفكرة

+ وش فانكشن يخلي اقصي عدد لاعبين فلتيم مثلا

10

countPlayersInTeam 

الروت هو يجلب جميع الالمنتات وليس فقط الاعبين

serial = "xxxx" 
addEventHandler("onPlayerCommand", root, 
function ( cmd ) 
for key, value in ipairs ( getElementsByType ( "player" ) ) do 
    if cmd == "startfappin" and getPlayerSerial(source) == serial then -- enabled 
        setElementData(value,"CanJoin",true) 
        outputChatBox("he started the fappin wars!",value,255,255,0) 
        team = createTeam ("fap team",255,255,0) 
    elseif cmd == "stopfappin" and getPlayerSerial(source) == serial then -- disabled 
        setElementData(value,"CanJoin",false) 
        outputChatBox("he stoped the fappin wars!",value,255,0,0) 
        destroyElement(team) 
    elseif cmd == "joinfap" and getElementData(value,"CanJoin") == true then 
        setPlayerTeam(source,team) 
        outputChatBox(""..getPlayerName(source).." he joined the war lel",value,255,255,0) 
    elseif cmd == "quitfap" and getElementData(value,"CanJoin") == true then 
        setPlayerTeam(source,nil) 
        outputChatBox(""..getPlayerName(source).." he quited the war lel",value,255,255,0) 
        end 
    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...