Jump to content

طلب كود [Solved]


Recommended Posts

Posted (edited)

السلام عليكم

شباب عندي كود عندما يضرب الشرطي اللاعب المطارد بالعصا يدخل السجن وشغال تمام ..

سيرفر

local jaja = { 
{5033.3999, -2103.2, 391.60001}, 
{5029.7002, -2102.8999, 391.60001}, 
{5025.6001, -2102.8999, 391.60001}, 
{5021.7998, -2103.1001, 391.60001}, 
{5017.7998, -2103.2, 391.60001}, 
{5013.6001, -2103.1001, 391.60001}, 
{5013, -2080.2, 391.60001}, 
{5017.1001, -2080.5, 391.60001}, 
{5021.2002, -2080.5, 391.60001}, 
{5024.8999, -2080.3999, 391.60001}, 
{5029, -2080.5, 391.60001}, 
{5032.7998, -2080.3999, 391.60001}, 
{5031.8999, -2080.3, 384.70001}, 
{5028.2002, -2080.5, 384.70001}, 
{5024.2998, -2080.3999, 384.70001}, 
{5020.2002, -2080.6001, 384.70001}, 
{5016.2002, -2081.2, 384.70001}, 
{5011.6001, -2080.8999, 384.70001}, 
{5032.1001, -2104.3, 384.70001}, 
{5028.2998, -2104.3999, 384.70001}, 
{5023.8999, -2103.3, 384.70001}, 
{5020.2998, -2103.1001, 384.70001}, 
{5016.5, -2103.5, 384.70001}, 
{5012.2002, -2103.8999, 384.70001}, 
} 
  
Times = { 
    [6] = 360000, 
    [5] = 300000, 
    [4] = 240000, 
    [3] = 180000, 
    [2] = 180000, 
    [1] = 180000, 
} 
  
addEventHandler('onPlayerDamage',root,function(attacker,weapon) 
 if attacker and attacker ~= source and getElementType(attacker) == 'player' and getPlayerTeam(attacker) and getTeamName(getPlayerTeam(attacker)) == 'Police' then 
   if getPlayerWantedLevel(source) > 0 and getPlayerTeam(source) and getTeamName(getPlayerTeam(source)) ~= 'Police' then 
    if ( weapon == 3 ) then 
                if Times[getPlayerWantedLevel(source)] then 
                    setElementPosition (source, unpack(jaja[math.random( #jaja )])) 
                    timer1 = setTimer ( setElementPosition, Times[getPlayerWantedLevel(source)], 1,source , 1572.9000244141, -1635.4000244141, 13.60000038147) 
                    triggerClientEvent(source, "unJail", source, Times[getPlayerWantedLevel(source)], timer1) 
                    setPlayerWantedLevel(source, 0) 
        end 
      end 
    end 
  end 
end ) 

كلينت

function displayTimer( ) 
    local es = getTickCount( ) - start 
 es = remaining - es 
 local m,s = math.floor(es/60000), math.fmod(math.floor(es/1000), 60) 
    if not ms then ms = m end 
 if not ss then ss = s end 
    if m < 10 then ms = "0"..m end 
    if s < 10 then ss = "0"..s end 
    dxDrawText("Time : "..m.." : "..s, 574, 543, 790, 590, tocolor(0, 255, 0, 255), 1.50, "beckett", "left", "top", false, false, false, false, false) 
    if math.floor(es) <= 0 then 
        removeEventHandler("onClientRender", root, displayTimer) 
    end 
end 
    addEvent("unJail", true) 
    addEventHandler("unJail", root, function(rem) 
        remaining = rem 
        start = getTickCount( ) 
        addEventHandler("onClientRender", root, displayTimer) 
end) 

ولكني أريد حفظ الوقت المتبقي علي خروج اللاعب من السجن عندما يطلع من السيرفر كي أضعه في السجن مرة أخري عندما يدخل السيرفر ويقضي الوقت المتبقي علي خروجه :D

أرجو أنت تكونو قهمتوني وأتمني الأفادة :roll:

Edited by Guest
Posted
شباب لم أستطيع عمل الكود وأرجو المساعدة :/

حاول تسوي شيء بسيط على الأقل رح تحتاج

getAccountData 
setAccountData 

+

getPlayerAccount 
"onPlayerLogin" 

هذي بس للحفظ بالحساب لو حفظتها انت بحساب اللاعب بعدين سو له طريقة لعرض الوقت له

Posted

عملت هيك سيرفر

function SpawnNoTe (SkinID, team) 
    setPlayerTeam(source, getTeamFromName(team)) 
        local Acc = getPlayerAccount(source) 
        rem = getAccountData (Acc,"msjoul") 
        if (team == "NoTeam") then 
            setPlayerNametagColor(source, 255, 0, 0) 
            if (rem) then 
            local xno, yno, zno = unpack(jaja[math.random( #jaja )]) 
            spawnPlayer(source, xno, yno, zno, 0, SkinID, 0, 0) 
            triggerClientEvent(source, "unJail", source, rem) 
            else 
            local xn, yn, zn = unpack(rnd[math.random(1, 6)]) 
            spawnPlayer(source, xn, yn, zn, 0, SkinID, 0, 0) 
            setPlayerWantedLevel (source, 2) 
            end 
            exports["guimessages"]:outputServer(source, "أنت الأن مع NoTeam", 255, 0, 0) 
            triggerClientEvent ( "ReNot", getRootElement()) 
            fadeCamera(source, true) 
            setCameraTarget(source) 
        end 
end 
  
addEventHandler('onPlayerDamage',root,function(attacker,weapon) 
    if attacker and attacker ~= source and getElementType(attacker) == 'player' and getPlayerTeam(attacker) and getTeamName(getPlayerTeam(attacker)) == 'Police' then 
        if getPlayerWantedLevel(source) > 0 and getPlayerTeam(source) and getTeamName(getPlayerTeam(source)) ~= 'Police' then 
            if ( weapon == 3 ) then 
                if Times[getPlayerWantedLevel(source)] then 
                    nosu = getPlayerName (source) 
                    noct = getPlayerName (attacker) 
                    exports["guimessages"]:outputServer(root, " #FFFF00 قام الشرطي #0000FF " ..noct.. " #FFFF00 بسجن اللاعب #FF0000 " ..nosu, 0, 0, 255) 
                    givePlayerMoney ( attacker, 5000 ) 
                    setElementPosition (source, unpack(jaja[math.random( #jaja )])) 
                    setElementInterior ( source, 0 ) 
                    timer2 = setTimer ( setElementPosition, Times[getPlayerWantedLevel(source)], 1,source , 1572.9000244141, -1635.4000244141, 13.60000038147) 
                    triggerClientEvent(source, "unJail", source, Times[getPlayerWantedLevel(source)]) 
                    setPlayerWantedLevel(source, 0) 
                    if isTimer (timer1) then 
                        local Acc = getPlayerAccount(source) 
                        remaining, executesRemaining, totalExecutes = getTimerDetails(timer1) 
                        setAccountData (Acc, "msjoul", remaining) 
                    end 
                end 
            end 
        end 
    end 
end ) 

وهيك كلينت

function displayTimer( ) 
    local es = getTickCount( ) - start 
    es = remaining - es 
    local m,s = math.floor(es/60000), math.fmod(math.floor(es/1000), 60) 
    if not ms then ms = m end 
    if not ss then ss = s end 
    if m < 10 then ms = "0"..m end 
    if s < 10 then ss = "0"..s end 
    dxDrawText("Time : "..m.." : "..s, 574, 543, 790, 590, tocolor(0, 255, 0, 255), 1.50, "beckett", "left", "top", false, false, false, false, false) 
    if math.floor(es) <= 0 then 
        removeEventHandler("onClientRender", root, displayTimer) 
    end 
end 
    addEvent("unJail", true) 
    addEventHandler("unJail", root, function(rem) 
        remaining = rem 
        start = getTickCount( ) 
        addEventHandler("onClientRender", root, displayTimer) 
end) 

وكل شئ تمام لكن عندما يدخل اللاعب المسجون يبدأ الوقت من

2:45

وليس من الوقت المتبقي لديه

يعني أنا لو خرجت وفاضلي دقيقة

عندما أدخل يبدأ من 2:45

ما المشكلة ؟؟

Posted

  
Timer = { } 
local jaja = { 
{5033.3999, -2103.2, 391.60001}, 
{5029.7002, -2102.8999, 391.60001}, 
{5025.6001, -2102.8999, 391.60001}, 
{5021.7998, -2103.1001, 391.60001}, 
{5017.7998, -2103.2, 391.60001}, 
{5013.6001, -2103.1001, 391.60001}, 
{5013, -2080.2, 391.60001}, 
{5017.1001, -2080.5, 391.60001}, 
{5021.2002, -2080.5, 391.60001}, 
{5024.8999, -2080.3999, 391.60001}, 
{5029, -2080.5, 391.60001}, 
{5032.7998, -2080.3999, 391.60001}, 
{5031.8999, -2080.3, 384.70001}, 
{5028.2002, -2080.5, 384.70001}, 
{5024.2998, -2080.3999, 384.70001}, 
{5020.2002, -2080.6001, 384.70001}, 
{5016.2002, -2081.2, 384.70001}, 
{5011.6001, -2080.8999, 384.70001}, 
{5032.1001, -2104.3, 384.70001}, 
{5028.2998, -2104.3999, 384.70001}, 
{5023.8999, -2103.3, 384.70001}, 
{5020.2998, -2103.1001, 384.70001}, 
{5016.5, -2103.5, 384.70001}, 
{5012.2002, -2103.8999, 384.70001}, 
} 
  
Times = { 
    [6] = 360000, 
    [5] = 300000, 
    [4] = 240000, 
    [3] = 180000, 
    [2] = 180000, 
    [1] = 180000, 
} 
  
function jailPlayer(plr, time) 
    if isTimer(Timer[plr]) then killTimer(Timer[plr]) end 
    setElementPosition(plr, unpack(jaja[math.random( #jaja )])) 
    Timer[plr] = setTimer(function(plr) 
        setElementPosition(plr , 1572.9000244141, -1635.4000244141, 13.60000038147) 
    end, time, 1, plr) 
    triggerClientEvent(plr, "unJail", plr, time) 
    setPlayerWantedLevel(plr, 0) 
end 
addEventHandler('onPlayerDamage',root,function(attacker,weapon) 
    if attacker and attacker ~= source and getElementType(attacker) == 'player' and getPlayerTeam(attacker) and getTeamName(getPlayerTeam(attacker)) == 'Police' then 
        if getPlayerWantedLevel(source) > 0 and getPlayerTeam(source) and getTeamName(getPlayerTeam(source)) ~= 'Police' then 
            if ( weapon == 3 ) then 
                if Times[getPlayerWantedLevel(source)] then 
                    jailPlayer(source, Times[getPlayerWantedLevel(source)]) 
                end 
            end 
        end 
    end 
end ) 
  
addEventHandler("onPlayerLogin", root, function(_, account) 
    local jailT = getAccountData(account, "JailTime") 
    if jailT then 
        jailPlayer(source, jailT) 
        setAccountData(account, "JailTime", false) 
    end 
end) 
  
addEventHandler("onPlayerQuit", root, function( ) 
    if isTimer(Timer[source]) then 
        local account = getPlayerAccount(source) 
        if account and not isGuestAccount(account) then 
            local remaining = getTimerDetails(Timer[source]) 
            setAccountData(account, "JailTime", remaining) 
        end 
        killTimer(Timer[source]) 
        Timer[source] = nil 
    end 
end) 
Posted
  
Timer = { } 
local jaja = { 
{5033.3999, -2103.2, 391.60001}, 
{5029.7002, -2102.8999, 391.60001}, 
{5025.6001, -2102.8999, 391.60001}, 
{5021.7998, -2103.1001, 391.60001}, 
{5017.7998, -2103.2, 391.60001}, 
{5013.6001, -2103.1001, 391.60001}, 
{5013, -2080.2, 391.60001}, 
{5017.1001, -2080.5, 391.60001}, 
{5021.2002, -2080.5, 391.60001}, 
{5024.8999, -2080.3999, 391.60001}, 
{5029, -2080.5, 391.60001}, 
{5032.7998, -2080.3999, 391.60001}, 
{5031.8999, -2080.3, 384.70001}, 
{5028.2002, -2080.5, 384.70001}, 
{5024.2998, -2080.3999, 384.70001}, 
{5020.2002, -2080.6001, 384.70001}, 
{5016.2002, -2081.2, 384.70001}, 
{5011.6001, -2080.8999, 384.70001}, 
{5032.1001, -2104.3, 384.70001}, 
{5028.2998, -2104.3999, 384.70001}, 
{5023.8999, -2103.3, 384.70001}, 
{5020.2998, -2103.1001, 384.70001}, 
{5016.5, -2103.5, 384.70001}, 
{5012.2002, -2103.8999, 384.70001}, 
} 
  
Times = { 
    [6] = 360000, 
    [5] = 300000, 
    [4] = 240000, 
    [3] = 180000, 
    [2] = 180000, 
    [1] = 180000, 
} 
  
function jailPlayer(plr, time) 
    if isTimer(Timer[plr]) then killTimer(Timer[plr]) end 
    setElementPosition(plr, unpack(jaja[math.random( #jaja )])) 
    Timer[plr] = setTimer(function(plr) 
        setElementPosition(plr , 1572.9000244141, -1635.4000244141, 13.60000038147) 
    end, time, 1, plr) 
    triggerClientEvent(plr, "unJail", plr, time) 
    setPlayerWantedLevel(plr, 0) 
end 
addEventHandler('onPlayerDamage',root,function(attacker,weapon) 
    if attacker and attacker ~= source and getElementType(attacker) == 'player' and getPlayerTeam(attacker) and getTeamName(getPlayerTeam(attacker)) == 'Police' then 
        if getPlayerWantedLevel(source) > 0 and getPlayerTeam(source) and getTeamName(getPlayerTeam(source)) ~= 'Police' then 
            if ( weapon == 3 ) then 
                if Times[getPlayerWantedLevel(source)] then 
                    jailPlayer(source, Times[getPlayerWantedLevel(source)]) 
                end 
            end 
        end 
    end 
end ) 
  
addEventHandler("onPlayerLogin", root, function(_, account) 
    local jailT = getAccountData(account, "JailTime") 
    if jailT then 
        jailPlayer(source, jailT) 
        setAccountData(account, "JailTime", false) 
    end 
end) 
  
addEventHandler("onPlayerQuit", root, function( ) 
    if isTimer(Timer[source]) then 
        local account = getPlayerAccount(source) 
        if account and not isGuestAccount(account) then 
            local remaining = getTimerDetails(Timer[source]) 
            setAccountData(account, "JailTime", remaining) 
        end 
        killTimer(Timer[source]) 
        Timer[source] = nil 
    end 
end) 

شكراااً جداً الكود يعمل تمام :D

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