Jump to content

settimer


Recommended Posts

  • Replies 68
  • Created
  • Last Reply

Top Posters In This Topic

اشتغل بس كودك صار غير مفهوم وش غيرت وليه

ماغيرت شئ فيه بس ضفت تحقق وقتل الوقت لو اللاعب ضغط اكثر من مره على الزر مايكرر التايمر

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

Link to comment
    addEvent ("armor", true) 
    addEventHandler ("armor", root, 
    function () 
    l = source 
    ti =  setTimer ( function () 
    if getElementHealth ( 1 ) == 100 then killTimer ( ti ) 
          setPedArmor ( l, getPedArmor ( l) + 1 ) 
    setElementHealth( l, getElementHealth  ( l ) + 1.6) 
    end,1000, 0) 
    end 
    end 
    ) 

طيب انا بنهي الوقت لما يصير الدم فل يقولي غلط سطر 9 فيه شي؟

Link to comment
addEvent ("armor", true) 
    addEventHandler ("armor", root, 
    function () 
    l = source 
    ti =  setTimer ( function () 
    if getElementHealth ( 1 ) == 100 then killTimer ( ti ) 
          setPedArmor ( l, getPedArmor ( l) + 1 ) 
    setElementHealth( l, getElementHealth  ( l ) + 1.6) 
    end,1000, 1) 
    end 
    end 
    ) 

Link to comment

ti = {} 
function getPedMaxHealth(ped) 
    assert(isElement(ped) and (getElementType(ped) == "ped" or getElementType(ped) == "player"), "Bad argument @ 'getPedMaxHealth' [Expected ped/player at argument 1, got " .. tostring(ped) .. "]") 
    local stat = getPedStat(ped, 24) 
    local maxhealth = 100 + (stat - 569) / 4.31 
    return math.max(1, maxhealth) 
end 
   addEvent ("armor", true) 
    addEventHandler ("armor", root, 
    function () 
    l = source 
    ti[source] =  setTimer ( function () 
    if getElementHealth ( l ) == getPedMaxHealth(l) then return killTimer ( ti[l] ) end 
          setPedArmor ( l, getPedArmor ( l) + 1.6 ) 
    setElementHealth( l, getElementHealth  ( l ) + 1.6) 
    end,1000, 0) 
    end 
    ) 
Edited by Guest
Link to comment
ti = {} 
function getPedMaxHealth(ped) 
    assert(isElement(ped) and (getElementType(ped) == "ped" or getElementType(ped) == "player"), "Bad argument @ 'getPedMaxHealth' [Expected ped/player at argument 1, got " .. tostring(ped) .. "]") 
    local stat = getPedStat(ped, 24) 
    local maxhealth = 100 + (stat - 569) / 4.31 
    return math.max(1, maxhealth) 
end 
   addEvent ("armor", true) 
    addEventHandler ("armor", root, 
    function () 
    l = source 
    ti[source] =  setTimer ( function () 
    if getElementHealth ( l ) == getPedMaxHealth(l) then return killTimer ( ti[source] ) end 
          setPedArmor ( l, getPedArmor ( l) + 1 ) 
    setElementHealth( l, getElementHealth  ( l ) + 1.6) 
    end,1000, 0) 
    end 
    ) 

ليه م تتحق ان الدم 100؟

بدل اليوسفل فنكشم

Link to comment
ti = {} 
function getPedMaxHealth(ped) 
    assert(isElement(ped) and (getElementType(ped) == "ped" or getElementType(ped) == "player"), "Bad argument @ 'getPedMaxHealth' [Expected ped/player at argument 1, got " .. tostring(ped) .. "]") 
    local stat = getPedStat(ped, 24) 
    local maxhealth = 100 + (stat - 569) / 4.31 
    return math.max(1, maxhealth) 
end 
   addEvent ("armor", true) 
    addEventHandler ("armor", root, 
    function () 
    l = source 
    ti[source] =  setTimer ( function () 
    if getElementHealth ( l ) == getPedMaxHealth(l) then return killTimer ( ti[source] ) end 
          setPedArmor ( l, getPedArmor ( l) + 1 ) 
    setElementHealth( l, getElementHealth  ( l ) + 1.6) 
    end,1000, 0) 
    end 
    ) 

ليه م تتحق ان الدم 100؟

بدل اليوسفل فنكشم

طيب لو دمك الكامل اعلي من 100 ؟

هو دة المفيد في الفنكشن دة

Link to comment

يوقف الوقت بعد التعبئه

ملاحظه : انا حاطت كلام يظهر بالشات كتوضيح فقط اذا كنت تبي تشيله براحتك

بس عندي احساس راح تقول كودك صعب ومدرى ايش بس يلا اذا ماكنت راح تستخدمه يمكن يفيد غيرك

healthTimer = {} 
addEvent ("armor", true) 
addEventHandler ("armor", root,function () 
if healthTimer[source]  and isTimer(healthTimer[source]) then killTimer(healthTimer[source]) end 
healthTimer[source] = setTimer ( function (source) 
Health = getElementHealth (source) 
Armor = getPlayerArmor (source)  
if Health < 100 or Armor < 100  then  
if isElement(source) then  
setPlayerArmor (source ,Armor+1) 
setElementHealth (source,Health+1.5) 
outputChatBox ("Your Heath ["..math.ceil(Health)..'] Your Armor ['..math.ceil(Armor).. ']',source,255,0,0,true) 
end 
elseif isElement(source) then  
killTimer(healthTimer[source]) healthTimer[source]  = nil outputChatBox ('تمت التعبئه',source,255,0,0,true) 
end 
end,1000,0,source) 
end) 
Link to comment
لو تبحث بالمنتدي والويكي وتفهم انقلش

ماراح تحتاج لنا لكن مب كل ساعه موضوع

معلش مو كل موضوع تيجي تقولي اجمع ومدري بالله تبيني اتنبىء لك بكل طلباتي المستقبلية؟؟

+اوسكار كودك ما هو صعب :D

بس فيه شي اثنين ما فهمته من كودك

healthTimer = {}

القوسين ذول وش بالضبط وظيفتهم؟؟

isTimer ذا وش يسوي

+isElement ذا

ومشكورين ما قصرتوا

Link to comment
لو تبحث بالمنتدي والويكي وتفهم انقلش

ماراح تحتاج لنا لكن مب كل ساعه موضوع

معلش مو كل موضوع تيجي تقولي اجمع ومدري بالله تبيني اتنبىء لك بكل طلباتي المستقبلية؟؟

+اوسكار كودك ما هو صعب :D

بس فيه شي اثنين ما فهمته من كودك

healthTimer = {}

القوسين ذول وش بالضبط وظيفتهم؟؟

isTimer ذا وش يسوي

+isElement ذا

ومشكورين ما قصرتوا

1 - هذا عشان يسوي التيبل " جدول " ء

2 - هذا يتحقق من وجود التايمر

3 - وهذا يتحقق من وجود الالمنت

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