Jump to content

طلب فنكشنات


YourMind

Recommended Posts

السلام عليكم

بفكر اعمل بأختصار مهمة فيها سباحة و باركور و سباق من غير مركبات و الخ | و دي اول مرة ليا ان شاء الله

: كل اللي انا عايزه من المحترفين "كفاية" انهم يساعدوني بفنكشنات

المهمة تبدأ بوقت معين و تخلص بوقت معين ( و لو شخص دخل ماركر المهمة يكون في تحقيق بأن المهمة شغالة ولا لأ | و لو شغالة يدخله لو مش شغالة مايدخلوش

كوماند في اف 8 يبين الوقت الباقي من المهمة عشان تشتغل

معرفة عدد الاعبين في المهمة

و الباقي ان شاء الله سهل

و شكراً :fadein:

Link to comment
آسف عالتأخير

طيب دلوقت عملت تايمر

setTimer( function() 
end,500000,0) 

دة مثلاً هايكون بتاع وقت تشغيل المهمة ؟

ازاي استخدمه ؟

كمل وظيفتك كاملة واطرح كودك

التايمر لوحده مينفعش لازم كودك كامل

عشان نقدر نحط التايمر فى المكان المناسب .

Link to comment

دة جزء من اللي انا عملته

 MissionT = setTimer(function() 
 end,1200000,0) 
     
 local MissionM = createMarker ( 268.5104675293,1954.3046875,17, "cylinder", 1.5, 255, 255, 0, 170 ) 
  local MissionR = createMarker (  3784.2062988281,-2352.4965820313,2.2, "cylinder", 1.5, 255, 255, 0, 170 ) 
  local missionReward = 5000000 
  
 function getTimeLeft(Timer) 
if isTimer(MissionT) then 
    ms = getTimerDetails(MissionT) 
end 
    local m = math.floor(ms/60000) 
    local s = math.floor((ms-m*60000)/1000) 
    if m < 10 then m = ""..m end 
    if s < 10 then s = ""..s end 
    return "("..m.." min(s) and "..s.." sec(s))" 
end 
  
 setTimer(function() 
     rr = getTimerDetails(MissionT) 
     if (rr <= 300000) then   
  exports["TopBarChat"]:sendClientMessage ( "RC-Mission is about to start, to join ; go to yellow dragon blip at the main base", root, 255, 170, 127 ) 
    exports["TopBarChat"]:sendClientMessage ( "Money reward : "..missionReward.."$", root, 255, 212, 42 ) 
    end 
    end,50,0) 
   
 addEventHandler ("onPlayerMarkerHit",MissionM, 
 function () 
     remaining = getTimerDetails(MissionT) 
 if ( remaining >= 300000 ) then 
 setElementData(source,"RCMissionPlayer",true) 
 setElementPosition (source,3383.1069335938,-2346.1005859375,1.1000000238419) 
             toggleAllControls ( source, false )  
 exports["TopBarChat"]:sendClientMessage ( "You have been succesfully entered the RC-Mission.", source, 255, 0, 0 ) 
  exports["TopBarChat"]:sendClientMessage ( "You can't move, please wait for 5 mins.", source, 255, 0, 0 ) 
 else 
 exports["TopBarChat"]:sendClientMessage ( "RC-Mission is not about to start yet, time left ; "..getTimeLeft(Timer).." ", source, 255, 0, 0 ) 
 end 
  setTimer(function()  
  toggleAllControls ( source, true ) 
  exports["TopBarChat"]:sendClientMessage ( "RC-Mission is started, nobody can join it anymore", root, 255, 170, 127 ) 
    end,300000,1) 
    end 
    ) 

هو ماركر دخول المهمة MissionM الماركر

لما باجي ادخله مش بيجيب حاجة ولا نتيجة ولا شئ في الديبج

ياريت لو في حاجة غلط تصححوهالي

Link to comment

كمل عليه

playerMission= {   } 
  
local MissionM = createMarker ( 268.5104675293,1954.3046875,17, "cylinder", 1.5, 255, 255, 0, 170 ) 
local missionReward = 5000000 
  
function getTimeLeft(Timer) 
    if isTimer(MissionTimer) then 
        ms = getTimerDetails(MissionTimer) 
    end 
    local m = math.floor(ms/60000) 
    local s = math.floor((ms-m*60000)/1000) 
    if m < 10 then m = ""..m end 
    if s < 10 then s = ""..s end 
    return "("..m.." min(s) and "..s.." sec(s))" 
end 
  
  
function StartMission() 
    MissionTimer = setTimer(function() 
        for i, v in pairs( playerMission ) do 
            toggleAllControls ( i, true ) 
            outputChatBox( "RC-Mission is started, nobody can join it anymore", i, 255, 170, 127 ) 
        end 
    end,305000,1) 
    StartTimer = setTimer(function() 
        local remaining = getTimerDetails(MissionTimer) 
        if (remaining <= 300000) then  
            outputChatBox( "RC-Mission is about to start, to join ; go to yellow dragon blip at the main base", root, 255, 170, 127 ) 
            outputChatBox( "Money reward : "..missionReward.."$", root, 255, 212, 42 ) 
            killTimer( StartTimer ) 
        end 
    end,50,0) 
end 
  
StartMission() 
  
addEventHandler ("onMarkerHit",resourceRoot, 
function ( player ) 
    if getElementType(player) == "player" and not playerMission[ player ] then 
        if source == MissionM then 
            local remaining = getTimerDetails(MissionTimer) 
            if (remaining <= 300000) then  
            --  setElementPosition (player,3383.1069335938,-2346.1005859375,1.1000000238419) 
                toggleAllControls ( player, false ) 
                outputChatBox( "You have been succesfully entered the RC-Mission.", player, 255, 0, 0 ) 
                playerMission[ player ] = true 
            else 
                outputChatBox( "RC-Mission is not about to start yet, time left ; "..getTimeLeft(Timer).." ", player, 255, 0, 0 ) 
            end 
        end 
    end 
end ) 
Edited by Guest
Link to comment
كمل عليه

playerMission= {   } 
  
local MissionM = createMarker ( 268.5104675293,1954.3046875,17, "cylinder", 1.5, 255, 255, 0, 170 ) 
local missionReward = 5000000 
  
function getTimeLeft(Timer) 
    if isTimer(MissionTimer) then 
        ms = getTimerDetails(MissionTimer) 
    end 
    local m = math.floor(ms/60000) 
    local s = math.floor((ms-m*60000)/1000) 
    if m < 10 then m = ""..m end 
    if s < 10 then s = ""..s end 
    return "("..m.." min(s) and "..s.." sec(s))" 
end 
  
  
function StartMission() 
    MissionTimer = setTimer(function() 
        for i, v in pairs( playerMission ) do 
            toggleAllControls ( i, true ) 
            outputChatBox( "RC-Mission is started, nobody can join it anymore", i, 255, 170, 127 ) 
        end 
    end,305000,ذ) 
    StartTimer = setTimer(function() 
        local remaining = getTimerDetails(MissionTimer) 
        if (remaining <= 300000) then  
            outputChatBox( "RC-Mission is about to start, to join ; go to yellow dragon blip at the main base", root, 255, 170, 127 ) 
            outputChatBox( "Money reward : "..missionReward.."$", root, 255, 212, 42 ) 
            killTimer( StartTimer ) 
        end 
    end,50,0) 
end 
  
StartMission() 
  
addEventHandler ("onMarkerHit",resourceRoot, 
function ( player ) 
    if getElementType(player) == "player" and not playerMission[ player ] then 
        if source == MissionM then 
            local remaining = getTimerDetails(MissionTimer) 
            if (remaining <= 300000) then  
            --  setElementPosition (player,3383.1069335938,-2346.1005859375,1.1000000238419) 
                toggleAllControls ( player, false ) 
                outputChatBox( "You have been succesfully entered the RC-Mission.", player, 255, 0, 0 ) 
                playerMission[ player ] = true 
            else 
                outputChatBox( "RC-Mission is not about to start yet, time left ; "..getTimeLeft(Timer).." ", player, 255, 0, 0 ) 
            end 
        end 
    end 
end ) 

سطر 24 من جبت ال ذ ض1

Link to comment

تسلموا :fadein:

بس ليه مش عايز يشتغل ؟

  
     addEventHandler ("onMarkerHit",MissionR, 
 function (player) 
 if getElementType (player) == "player" then 
 if playerMission[ player ] then 
  givePlayerMoney(player,tonumber(missionReward)) 
  exports["TopBarChat"]:sendClientMessage(""..getPlayerName(player).." has won the RC-Mission and "..missionReward.."$ !", player, 255, 170, 0 ) 
        for i,v in ipairs(playerMission) do 
        killPed(v) 
        end 
        end 
        end 
        end 
) 

هو بيدي الاعب فلوس تمام لحد كدة و يطلع الرسالة

لكن مش بيقتل الاعبين اللي في المهمة

اللي دخلوا الجدول

و عايزهم يطلعوا من الجدول عشان يقدروا يخشوا المهمة تاني

مساعدة لو سمحتم

Link to comment

جرب

function isPlayerInMission ( player )  
for _,v in ipairs ( playerMission ) do  
if ( v == player ) then  
return true  
end 
end 
return false 
end 
  
addEventHandler('onMarkerHit',root, function ( element )  
if ( source == MissionR ) then  
if ( getElementType ( element ) == 'player' ) then  
if ( isPlayerInMission ( element ) ) then  
givePlayerMoney ( element , tonumber ( missionReward ) ) 
for i,player in ipairs ( playerMission ) do  
killPed ( player ) 
playerMission [ player ] = nil  
exports["TopBarChat"]:sendClientMessage(""..getPlayerName(element).." has won the RC-Mission and "..missionReward.."$ !", player, 255, 170, 0 ) 
end 
end 
end 
end 
end 
) 
  

Link to comment
جرب

function isPlayerInMission ( player )  
for _,v in ipairs ( playerMission ) do  
if ( v == player ) then  
return true  
end 
end 
return false 
end 
  
  

v == true

لازم تاخذ المتغير الاول

pairs بتصير ipairs و

بصير هيك

for v,k in pairs ( playerMission ) do

تقدر تختصرة ب

if playerMission [ player ] then 
Link to comment
جرب

function isPlayerInMission ( player )  
for _,v in ipairs ( playerMission ) do  
if ( v == player ) then  
return true  
end 
end 
return false 
end 
  
  

v == true

لازم تاخذ المتغير الاول

pairs بتصير ipairs و

بصير هيك

for v,k in pairs ( playerMission ) do

تقدر تختصرة ب

if playerMission [ player ] then 

مش فاهم حاجة

يعني الكود هايكون كدة ؟

فوق

function isPlayerInMission ( player ) 
for _,v in pairs ( playerMission ) do 
if ( v == true ) and ( v == player ) then 
return true 
end 
end 
return false 
end 
  

و الباقي بتاع الماركر

addEventHandler('onMarkerHit',root, 
 function ( element ) 
if ( source == MissionR ) then 
if not getElementData (MissionR,"NoPrize") then 
if ( getElementType ( element ) == 'player' ) then 
if ( isPlayerInMission ( element ) ) then 
givePlayerMoney ( element , tonumber ( missionReward ) ) 
for i,player in ipairs ( playerMission ) do 
killPed ( player ) 
playerMission [ player ] = nil 
setElementData (MissionR,"NoPrize",true) 
exports["TopBarChat"]:sendClientMessage(""..getPlayerName(element).." has won the RC-Mission and "..missionReward.."$ !", player, 255, 170, 0 ) 
end 
end 
end 
end 
end 
end 
) 

Link to comment

كودك هيك بصير

addEventHandler('onMarkerHit',root, 
function ( element ) 
    if ( source == MissionR ) then 
        if ( getElementType ( element ) == 'player' ) then 
            if not getElementData (MissionR,"NoPrize") then 
                if playerMission [ element ] then 
                    givePlayerMoney ( element , tonumber ( missionReward ) ) 
                    for player,_ in pairs ( playerMission ) do 
                        killPed ( player ) 
                        playerMission [ player ] = nil 
                        exports["TopBarChat"]:sendClientMessage(""..getPlayerName(element).." has won the RC-Mission and "..missionReward.."$ !", player, 255, 170, 0 ) 
                    end 
                    setElementData (MissionR,"NoPrize",true) 
                end 
            end 
        end 
    end 
end ) 

isPlayerInMission انساك منه

استبدلته ب

if playerMission [ element ] then

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