Jump to content

[HELP]Proplem In Play Time


MrKAREEM

Recommended Posts

Hi Guis I was making a small script and it was firs writer

so i have problem when a player win

system give times put the times frozen in scoreboard

it doesnt move

i see the debug and i find that

server.lua:206: attempt to index global 'A' (a nill value) [DUP x5]

server.lua:206: attempt to index global 'A' (a nill value)

 

So Its The server side Codes and any one help me pls !!

captchaNums = 5 -- captcha letters length
wordTimeInSec = 25 --- the time before the word disappear in seconds [ default 11 seconds ]
--prizefrom,prizeto = 500,800 -- the prize random num
timerfrom,timerto = 1.5,5.5 -- the random timer that shows the word [ default from 3 to 15 minutes ]
---- unChangeable
wordOn = false
--theWord = nil
--thePrize = nil
wordTime = wordTimeInSec * 1000

Error = { "هلا",
"هلا",
"انا",
"ضض",
"تنورا",
"حياكم",
"سيرفر" }

g_root = getRootElement()
addEvent("send_M",true)
addEventHandler("send_M",root,
function( Q, K, K1, A)
	if tonumber(A) then
	createCode(Q,A)
	coans = K
	coans1 = K1
	Amont = A
  end
  end
)

function createCode(Q,A)
	for k,v in ipairs( getElementsByType("player") ) do
		exports.easytext:displayMessageForPlayer(v,1, "=========", wordTime, 0.07, 0.5, 0, 255, 0, 255, 1.6)
		exports.easytext:displayMessageForPlayer(v,2, "Word : "..Q.."", wordTime, 0.07, 0.533, 255, 255, 0, 255, 1.6)
		exports.easytext:displayMessageForPlayer(v,3, "Prize : "..A.." Hours ", wordTime, 0.07, 0.563, 255, 255, 0, 255, 1.6)
		exports.easytext:displayMessageForPlayer(v,4, "=========", wordTime, 0.07, 0.593, 0, 255, 0, 255, 1.6)
	end
startCodeTimer()
wordOn = true
end	

function startCodeTimer()
	codeTimer = setTimer( function ()
		removeCode()
		OutPut("تم الغاء المسابقة لعدم وجود إجابات",root,0,255,0,true)
	end , wordTime , 1 )
end

function removeCode()
	for k,v in ipairs( getElementsByType("player") ) do
		exports.easytext:clearMessageForPlayer(v,1)
		exports.easytext:clearMessageForPlayer(v,2)
		exports.easytext:clearMessageForPlayer(v,3)
		exports.easytext:clearMessageForPlayer(v,4)
	end
	if isTimer ( codeTimer ) then
		killTimer(codeTimer)
	end
    coans = nil
    coans1 = nil
	wordOn = false
end

function playerchatqaw ( msg, msgty, A)
   if coans1 == Error then
 coans = nil
 coans1 = nil
	OutPut("تم الغاء المسابقة لعدم وجود إجابات",getRootElement(),255,255,0,true)
	removeCode()
		else
	if coans then
	if string.find(msg,coans,1) then
			OutPut("وقد ربح "..Amont.." ساعة ╰ "..getPlayerName(source).." ╯ الفائز  هو",getRootElement(),math.random(255),math.random(255),math.random(255),true)
			local pTime = { getPlayerTime ( source ) }
			setElementData ( source, 'PlayTime', tostring ( pTime [ 1 ] + Amont .. ':' .. pTime [ 2 ] .. ':' .. pTime [ 3 ] ) )
			--givePlayerMoney(source,Amont)
			removeCode()
			coans = nil
          	coans1 = nil
		end
end
	end
	end
	addEventHandler ("onPlayerChat",g_root,playerchatqaw)


function playerchatqaw1 ( msg, msgty, A)
   if coans1 ==  Error then
 coans = nil
 coans1 = nil
	OutPut("!! تم الغاء السؤوال لنفاذ الوقت",getRootElement(),255,255,0,true)
	removeCode()
	
		else

   if coans1 then
	if string.find(msg,coans1,1) then
			OutPut("وقد ربح "..Amont.." ساعة ╰ "..getPlayerName(source).." ╯ الفائز هو",getRootElement(),math.random(255),math.random(255),math.random(255),true)
			givePlayerMoney(source,Amont)
			removeCode()
			coans = nil
          	coans1 = nil
			end
						end
								end
											end
		addEventHandler ("onPlayerChat",g_root,playerchatqaw1)

----------------------------------------------------------------------------------------------		
		
function getPlayerTime ( Player )
    local TimeData = getElementData(Player,'PlayTime') or '0:0:0';
    if ( TimeData ) then
        return tonumber(split(TimeData,':')[1]) , tonumber(split(TimeData,':')[2]), tonumber(split(TimeData,':')[3]);
    end 
end		

exports.scoreboard:addScoreboardColumn('PlayTime')
addEvent("addTime",true)
addEvent("removeTime",true)
addEvent("ToServer",true)
local t = { }
local w = {}
addEventHandler("ToServer",root,
function (word,get,time)
 if word and tonumber(get) and tonumber(time) then
table.insert(w,{word,get})
setTimer(function ()
 for _,v in ipairs(w) do
  if v[1] == word and v[2] == get then
   table.remove(w,i)
   end
 end
end,time*60*60*1000,1)
end
end
)
addEventHandler("onConsole",root,
function (msg)
 for _,v in ipairs(w) do
  if msg == v[1] then
    local playeraccount = getPlayerAccount ( source )
    if ( playeraccount ) and not isGuestAccount ( playeraccount ) then
	 if not getAccountData ( playeraccount, "time-"..msg) then
	  addPlayerTime(source,v[2])
	  setAccountData( playeraccount, "time-"..msg,true)
    end
   end
  end
 end
end
)
addEventHandler("addTime",root,
function (to,time)
 if to == "all" then
  for _,v in ipairs(getElementsByType("player")) do
   addPlayerTime(v,time)
  end
  else
   plr = getPlayerFromName(to)
    if plr then
	addPlayerTime(plr,time)
	end
 end
end
)
addEventHandler("removeTime",root,
function (to,time)
 if to == "all" then
  for _,v in ipairs(getElementsByType("player")) do
   removePlayerTime(v,time)
  end
  else
   plr = getPlayerFromName(to)
    if plr then
	removePlayerTime(plr,time)
	end
 end
end
)
 function addPlayerTime(plr,time)
 time = math.floor(time)
 A[plr]['hour'] = tonumber(A[plr]['hour'] or 0) + time
 end
  function removePlayerTime(plr,time)
  time = math.floor(time)
 A[plr]['hour'] = tonumber(A[plr]['hour'] or 0) - time
 end
function checkValues( source,arg1,arg2)
    if (arg2 >= 60) then
        A[ source ][ 'min' ] = tonumber( A[ source ][ 'min' ] or 0 ) + 1
        A[ source ][ 'sec' ] = 0
    end
    if (arg1 >= 60) then
        A[ source ][ 'min' ] = 0
        A[ source ][ 'hour' ] = tonumber( A[ source ][ 'hour' ] or 0 ) + 1
    end
    return arg1, arg2
end

setTimer(
    function( )
        for _, v in pairs( getElementsByType( "player" ) ) do
            if (not A[ v ]) then
                A[ v ] = {
                            ["hour"] = 0,
                             ["min"] = 0,
                             ["sec"] = 0
                            }
            end

            A[ v ][ 'sec' ] = tonumber( A[ v ][ 'sec' ] or 0 ) + 1
            local min,sec = checkValues (
                    v,
                    A[ v ][ 'min' ] or 0,
                    A[ v ][ 'sec' ] or 0
						)
	local hour = tonumber( A[ v ][ 'hour' ] or 0 )

            setElementData(
                v,
                "PlayTime",
                tostring( hour )..':'..tostring( min )..':'..tostring( sec )
            )
        end
    end,
    1000, 0
)

function onPlayerQuit ( )
    local playeraccount = getPlayerAccount ( source )
    if ( playeraccount ) and not isGuestAccount ( playeraccount ) then
        local sValue = getElementData( source,'PlayTime' )
	local hour = tonumber( A[ source ][ 'hour' ] or 0 )
	local min = tonumber( A[ source ][ 'min' ] or 0 )
	local sec = tonumber( A[ source ][ 'sec' ] or 0 )
        setAccountData ( playeraccount, "PlayTime-hour", tostring(hour) )
        setAccountData ( playeraccount, "PlayTime-min", tostring(min) )
        setAccountData ( playeraccount, "PlayTime-sec", tostring(sec) )
        setAccountData ( playeraccount, "PlayTime", tostring(sValue) )

    end
    A[ source ] = nil
end

function onPlayerLogin (_, playeraccount )
    if ( playeraccount ) then
        local time = getAccountData ( playeraccount, "PlayTime" )
	local hou = getAccountData ( playeraccount, "PlayTime-hour")
	local min = getAccountData ( playeraccount, "PlayTime-min")
	local sec = getAccountData ( playeraccount, "PlayTime-sec")
        if ( time ) then
            setElementData ( source, "PlayTime", time )

                             A[ source ]["hour"] = tonumber(hou)
                             A[ source ]["min"] = tonumber(min)
                             A[ source ]["sec"] = tonumber(sec)
                else
            setElementData ( source, "PlayTime",0 )
            setAccountData ( playeraccount, "PlayTime",0 )
        end
    end
end
addEventHandler ( "onPlayerQuit", root, onPlayerQuit )
addEventHandler ( "onPlayerLogin", root, onPlayerLogin )



 

Any Help pls :|

Link to comment
captchaNums = 5 -- captcha letters length
wordTimeInSec = 25 --- the time before the word disappear in seconds [ default 11 seconds ]
--prizefrom,prizeto = 500,800 -- the prize random num
timerfrom,timerto = 1.5,5.5 -- the random timer that shows the word [ default from 3 to 15 minutes ]
---- unChangeable
wordOn = false
--theWord = nil
--thePrize = nil
wordTime = wordTimeInSec * 1000

Error = { "هلا",
"هلا",
"انا",
"ضض",
"تنورا",
"حياكم",
"سيرفر" }
A = { }
g_root = getRootElement()
addEvent("send_M",true)
addEventHandler("send_M",root,
function( Q, K, K1, A)
if tonumber(A) then
createCode(Q,A)
coans = K
coans1 = K1
Amont = A
  end
  end
)

function createCode(Q,A)
    for k,v in ipairs( getElementsByType("player") ) do
        exports.easytext:displayMessageForPlayer(v,1, "=========", wordTime, 0.07, 0.5, 0, 255, 0, 255, 1.6)
        exports.easytext:displayMessageForPlayer(v,2, "Word : "..Q.."", wordTime, 0.07, 0.533, 255, 255, 0, 255, 1.6)
        exports.easytext:displayMessageForPlayer(v,3, "Prize : "..A.." Hours ", wordTime, 0.07, 0.563, 255, 255, 0, 255, 1.6)
        exports.easytext:displayMessageForPlayer(v,4, "=========", wordTime, 0.07, 0.593, 0, 255, 0, 255, 1.6)
    end
startCodeTimer()
wordOn = true
end    

function startCodeTimer()
    codeTimer = setTimer( function ()
        removeCode()
        OutPut("تم الغاء المسابقة لعدم وجود إجابات",root,0,255,0,true)
    end , wordTime , 1 )
end

function removeCode()
    for k,v in ipairs( getElementsByType("player") ) do
        exports.easytext:clearMessageForPlayer(v,1)
        exports.easytext:clearMessageForPlayer(v,2)
        exports.easytext:clearMessageForPlayer(v,3)
        exports.easytext:clearMessageForPlayer(v,4)
    end
    if isTimer ( codeTimer ) then
        killTimer(codeTimer)
    end
    coans = nil
    coans1 = nil
    wordOn = false
end

function playerchatqaw ( msg, msgty, A)
   if coans1 == Error then
 coans = nil
 coans1 = nil
    OutPut("تم الغاء المسابقة لعدم وجود إجابات",getRootElement(),255,255,0,true)
    removeCode()
        else
    if coans then
    if string.find(msg,coans,1) then
            OutPut("وقد ربح "..Amont.." ساعة ? "..getPlayerName(source).." ? الفائز  هو",getRootElement(),math.random(255),math.random(255),math.random(255),true)
            local pTime = { getPlayerTime ( source ) }
            setElementData ( source, 'PlayTime', tostring ( pTime [ 1 ] + Amont .. ':' .. pTime [ 2 ] .. ':' .. pTime [ 3 ] ) )
            --givePlayerMoney(source,Amont)
            removeCode()
            coans = nil
              coans1 = nil
        end
end
    end
    end
    addEventHandler ("onPlayerChat",g_root,playerchatqaw)


function playerchatqaw1 ( msg, msgty, A)
   if coans1 ==  Error then
 coans = nil
 coans1 = nil
    OutPut("!! تم الغاء السؤوال لنفاذ الوقت",getRootElement(),255,255,0,true)
    removeCode()
    
        else

   if coans1 then
    if string.find(msg,coans1,1) then
            OutPut("وقد ربح "..Amont.." ساعة ? "..getPlayerName(source).." ? الفائز هو",getRootElement(),math.random(255),math.random(255),math.random(255),true)
            givePlayerMoney(source,Amont)
            removeCode()
            coans = nil
              coans1 = nil
            end
                        end
                                end
                                            end
        addEventHandler ("onPlayerChat",g_root,playerchatqaw1)

----------------------------------------------------------------------------------------------        
        
function getPlayerTime ( Player )
    local TimeData = getElementData(Player,'PlayTime') or '0:0:0';
    if ( TimeData ) then
        return tonumber(split(TimeData,':')[1]) , tonumber(split(TimeData,':')[2]), tonumber(split(TimeData,':')[3]);
    end 
end        

exports.scoreboard:addScoreboardColumn('PlayTime')
addEvent("addTime",true)
addEvent("removeTime",true)
addEvent("ToServer",true)
local t = { }
local w = {}
addEventHandler("ToServer",root,
function (word,get,time)
 if word and tonumber(get) and tonumber(time) then
table.insert(w,{word,get})
setTimer(function ()
 for _,v in ipairs(w) do
  if v[1] == word and v[2] == get then
   table.remove(w,i)
   end
 end
end,time*60*60*1000,1)
end
end
)
addEventHandler("onConsole",root,
function (msg)
 for _,v in ipairs(w) do
  if msg == v[1] then
    local playeraccount = getPlayerAccount ( source )
    if ( playeraccount ) and not isGuestAccount ( playeraccount ) then
     if not getAccountData ( playeraccount, "time-"..msg) then
      addPlayerTime(source,v[2])
      setAccountData( playeraccount, "time-"..msg,true)
    end
   end
  end
 end
end
)
addEventHandler("addTime",root,
function (to,time)
 if to == "all" then
  for _,v in ipairs(getElementsByType("player")) do
   addPlayerTime(v,time)
  end
  else
   plr = getPlayerFromName(to)
    if plr then
    addPlayerTime(plr,time)
    end
 end
end
)
addEventHandler("removeTime",root,
function (to,time)
 if to == "all" then
  for _,v in ipairs(getElementsByType("player")) do
   removePlayerTime(v,time)
  end
  else
   plr = getPlayerFromName(to)
    if plr then
    removePlayerTime(plr,time)
    end
 end
end
)
 function addPlayerTime(plr,time)
 time = math.floor(time)
 A[plr]['hour'] = tonumber(A[plr]['hour'] or 0) + time
 end
  function removePlayerTime(plr,time)
  time = math.floor(time)
 A[plr]['hour'] = tonumber(A[plr]['hour'] or 0) - time
 end
function checkValues( source,arg1,arg2)
    if (arg2 >= 60) then
        A[ source ][ 'min' ] = tonumber( A[ source ][ 'min' ] or 0 ) + 1
        A[ source ][ 'sec' ] = 0
    end
    if (arg1 >= 60) then
        A[ source ][ 'min' ] = 0
        A[ source ][ 'hour' ] = tonumber( A[ source ][ 'hour' ] or 0 ) + 1
    end
    return arg1, arg2
end

setTimer(
    function(A)
local A = { }
        for _, v in pairs( getElementsByType( "player" ) ) do
            if (not A[ v ]) then
                A[ v ] = {
                            ["hour"] = 0,
                             ["min"] = 0,
                             ["sec"] = 0
                            }
            end

            A[ v ][ 'sec' ] = tonumber( A[ v ][ 'sec' ] or 0 ) + 1
            local min,sec = checkValues (
                    v,
                    A[ v ][ 'min' ] or 0,
                    A[ v ][ 'sec' ] or 0
                        )
    local hour = tonumber( A[ v ][ 'hour' ] or 0 )

            setElementData(
                v,
                "PlayTime",
                tostring( hour )..':'..tostring( min )..':'..tostring( sec )
            )
        end
    end,
    1000, 0
)

function onPlayerQuit ( )
    local playeraccount = getPlayerAccount ( source )
    if ( playeraccount ) and not isGuestAccount ( playeraccount ) then
        local sValue = getElementData( source,'PlayTime' )
    local hour = tonumber( A[ source ][ 'hour' ] or 0 )
    local min = tonumber( A[ source ][ 'min' ] or 0 )
    local sec = tonumber( A[ source ][ 'sec' ] or 0 )
        setAccountData ( playeraccount, "PlayTime-hour", tostring(hour) )
        setAccountData ( playeraccount, "PlayTime-min", tostring(min) )
        setAccountData ( playeraccount, "PlayTime-sec", tostring(sec) )
        setAccountData ( playeraccount, "PlayTime", tostring(sValue) )

    end
    A[ source ] = nil
end

function onPlayerLogin (_, playeraccount )
    if ( playeraccount ) then
        local time = getAccountData ( playeraccount, "PlayTime" )
    local hou = getAccountData ( playeraccount, "PlayTime-hour")
    local min = getAccountData ( playeraccount, "PlayTime-min")
    local sec = getAccountData ( playeraccount, "PlayTime-sec")
        if ( time ) then
            setElementData ( source, "PlayTime", time )

                             A[ source ]["hour"] = tonumber(hou)
                             A[ source ]["min"] = tonumber(min)
                             A[ source ]["sec"] = tonumber(sec)
                else
            setElementData ( source, "PlayTime",0 )
            setAccountData ( playeraccount, "PlayTime",0 )
        end
    end
end
addEventHandler ( "onPlayerQuit", root, onPlayerQuit )
addEventHandler ( "onPlayerLogin", root, onPlayerLogin )

;)

Link to comment
5 minutes ago, #\_oskar_/# said:

captchaNums = 5 -- captcha letters lengthwordTimeInSec = 25 --- the time before the word disappear in seconds [ default 11 seconds ]--prizefrom,prizeto = 500,800 -- the prize random numtimerfrom,timerto = 1.5,5.5 -- the random timer that shows the word [ default from 3 to 15 minutes ]---- unChangeablewordOn = false--theWord = nil--thePrize = nilwordTime = wordTimeInSec * 1000Error = { "هلا","هلا","انا","ضض","تنورا","حياكم","سيرفر" }A = { }g_root = getRootElement()addEvent("send_M",true)addEventHandler("send_M",root,function( Q, K, K1, A)if tonumber(A) thencreateCode(Q,A)coans = Kcoans1 = K1Amont = A  end  end)function createCode(Q,A)    for k,v in ipairs( getElementsByType("player") ) do        exports.easytext:displayMessageForPlayer(v,1, "=========", wordTime, 0.07, 0.5, 0, 255, 0, 255, 1.6)        exports.easytext:displayMessageForPlayer(v,2, "Word : "..Q.."", wordTime, 0.07, 0.533, 255, 255, 0, 255, 1.6)        exports.easytext:displayMessageForPlayer(v,3, "Prize : "..A.." Hours ", wordTime, 0.07, 0.563, 255, 255, 0, 255, 1.6)        exports.easytext:displayMessageForPlayer(v,4, "=========", wordTime, 0.07, 0.593, 0, 255, 0, 255, 1.6)    endstartCodeTimer()wordOn = trueend    function startCodeTimer()    codeTimer = setTimer( function ()        removeCode()        OutPut("تم الغاء المسابقة لعدم وجود إجابات",root,0,255,0,true)    end , wordTime , 1 )endfunction removeCode()    for k,v in ipairs( getElementsByType("player") ) do        exports.easytext:clearMessageForPlayer(v,1)        exports.easytext:clearMessageForPlayer(v,2)        exports.easytext:clearMessageForPlayer(v,3)        exports.easytext:clearMessageForPlayer(v,4)    end    if isTimer ( codeTimer ) then        killTimer(codeTimer)    end    coans = nil    coans1 = nil    wordOn = falseendfunction playerchatqaw ( msg, msgty, A)   if coans1 == Error then coans = nil coans1 = nil    OutPut("تم الغاء المسابقة لعدم وجود إجابات",getRootElement(),255,255,0,true)    removeCode()        else    if coans then    if string.find(msg,coans,1) then            OutPut("وقد ربح "..Amont.." ساعة ? "..getPlayerName(source).." ? الفائز  هو",getRootElement(),math.random(255),math.random(255),math.random(255),true)            local pTime = { getPlayerTime ( source ) }            setElementData ( source, 'PlayTime', tostring ( pTime [ 1 ] + Amont .. ':' .. pTime [ 2 ] .. ':' .. pTime [ 3 ] ) )            --givePlayerMoney(source,Amont)            removeCode()            coans = nil              coans1 = nil        endend    end    end    addEventHandler ("onPlayerChat",g_root,playerchatqaw)function playerchatqaw1 ( msg, msgty, A)   if coans1 ==  Error then coans = nil coans1 = nil    OutPut("!! تم الغاء السؤوال لنفاذ الوقت",getRootElement(),255,255,0,true)    removeCode()            else   if coans1 then    if string.find(msg,coans1,1) then            OutPut("وقد ربح "..Amont.." ساعة ? "..getPlayerName(source).." ? الفائز هو",getRootElement(),math.random(255),math.random(255),math.random(255),true)            givePlayerMoney(source,Amont)            removeCode()            coans = nil              coans1 = nil            end                        end                                end                                            end        addEventHandler ("onPlayerChat",g_root,playerchatqaw1)----------------------------------------------------------------------------------------------                function getPlayerTime ( Player )    local TimeData = getElementData(Player,'PlayTime') or '0:0:0';    if ( TimeData ) then        return tonumber(split(TimeData,':')[1]) , tonumber(split(TimeData,':')[2]), tonumber(split(TimeData,':')[3]);    end end        exports.scoreboard:addScoreboardColumn('PlayTime')addEvent("addTime",true)addEvent("removeTime",true)addEvent("ToServer",true)local t = { }local w = {}addEventHandler("ToServer",root,function (word,get,time) if word and tonumber(get) and tonumber(time) thentable.insert(w,{word,get})setTimer(function () for _,v in ipairs(w) do  if v[1] == word and v[2] == get then   table.remove(w,i)   end endend,time*60*60*1000,1)endend)addEventHandler("onConsole",root,function (msg) for _,v in ipairs(w) do  if msg == v[1] then    local playeraccount = getPlayerAccount ( source )    if ( playeraccount ) and not isGuestAccount ( playeraccount ) then     if not getAccountData ( playeraccount, "time-"..msg) then      addPlayerTime(source,v[2])      setAccountData( playeraccount, "time-"..msg,true)    end   end  end endend)addEventHandler("addTime",root,function (to,time) if to == "all" then  for _,v in ipairs(getElementsByType("player")) do   addPlayerTime(v,time)  end  else   plr = getPlayerFromName(to)    if plr then    addPlayerTime(plr,time)    end endend)addEventHandler("removeTime",root,function (to,time) if to == "all" then  for _,v in ipairs(getElementsByType("player")) do   removePlayerTime(v,time)  end  else   plr = getPlayerFromName(to)    if plr then    removePlayerTime(plr,time)    end endend) function addPlayerTime(plr,time) time = math.floor(time) A[plr]['hour'] = tonumber(A[plr]['hour'] or 0) + time end  function removePlayerTime(plr,time)  time = math.floor(time) A[plr]['hour'] = tonumber(A[plr]['hour'] or 0) - time endfunction checkValues( source,arg1,arg2)    if (arg2 >= 60) then        A[ source ][ 'min' ] = tonumber( A[ source ][ 'min' ] or 0 ) + 1        A[ source ][ 'sec' ] = 0    end    if (arg1 >= 60) then        A[ source ][ 'min' ] = 0        A[ source ][ 'hour' ] = tonumber( A[ source ][ 'hour' ] or 0 ) + 1    end    return arg1, arg2endsetTimer(    function(A)local A = { }        for _, v in pairs( getElementsByType( "player" ) ) do            if (not A[ v ]) then                A[ v ] = {                            ["hour"] = 0,                             ["min"] = 0,                             ["sec"] = 0                            }            end            A[ v ][ 'sec' ] = tonumber( A[ v ][ 'sec' ] or 0 ) + 1            local min,sec = checkValues (                    v,                    A[ v ][ 'min' ] or 0,                    A[ v ][ 'sec' ] or 0                        )    local hour = tonumber( A[ v ][ 'hour' ] or 0 )            setElementData(                v,                "PlayTime",                tostring( hour )..':'..tostring( min )..':'..tostring( sec )            )        end    end,    1000, 0)function onPlayerQuit ( )    local playeraccount = getPlayerAccount ( source )    if ( playeraccount ) and not isGuestAccount ( playeraccount ) then        local sValue = getElementData( source,'PlayTime' )    local hour = tonumber( A[ source ][ 'hour' ] or 0 )    local min = tonumber( A[ source ][ 'min' ] or 0 )    local sec = tonumber( A[ source ][ 'sec' ] or 0 )        setAccountData ( playeraccount, "PlayTime-hour", tostring(hour) )        setAccountData ( playeraccount, "PlayTime-min", tostring(min) )        setAccountData ( playeraccount, "PlayTime-sec", tostring(sec) )        setAccountData ( playeraccount, "PlayTime", tostring(sValue) )    end    A[ source ] = nilendfunction onPlayerLogin (_, playeraccount )    if ( playeraccount ) then        local time = getAccountData ( playeraccount, "PlayTime" )    local hou = getAccountData ( playeraccount, "PlayTime-hour")    local min = getAccountData ( playeraccount, "PlayTime-min")    local sec = getAccountData ( playeraccount, "PlayTime-sec")        if ( time ) then            setElementData ( source, "PlayTime", time )                             A[ source ]["hour"] = tonumber(hou)                             A[ source ]["min"] = tonumber(min)                             A[ source ]["sec"] = tonumber(sec)                else            setElementData ( source, "PlayTime",0 )            setAccountData ( playeraccount, "PlayTime",0 )        end    endendaddEventHandler ( "onPlayerQuit", root, onPlayerQuit )addEventHandler ( "onPlayerLogin", root, onPlayerLogin )

;)

بجربه واقولك :D

8 minutes ago, #\_oskar_/# said:

captchaNums = 5 -- captcha letters lengthwordTimeInSec = 25 --- the time before the word disappear in seconds [ default 11 seconds ]--prizefrom,prizeto = 500,800 -- the prize random numtimerfrom,timerto = 1.5,5.5 -- the random timer that shows the word [ default from 3 to 15 minutes ]---- unChangeablewordOn = false--theWord = nil--thePrize = nilwordTime = wordTimeInSec * 1000Error = { "هلا","هلا","انا","ضض","تنورا","حياكم","سيرفر" }A = { }g_root = getRootElement()addEvent("send_M",true)addEventHandler("send_M",root,function( Q, K, K1, A)if tonumber(A) thencreateCode(Q,A)coans = Kcoans1 = K1Amont = A  end  end)function createCode(Q,A)    for k,v in ipairs( getElementsByType("player") ) do        exports.easytext:displayMessageForPlayer(v,1, "=========", wordTime, 0.07, 0.5, 0, 255, 0, 255, 1.6)        exports.easytext:displayMessageForPlayer(v,2, "Word : "..Q.."", wordTime, 0.07, 0.533, 255, 255, 0, 255, 1.6)        exports.easytext:displayMessageForPlayer(v,3, "Prize : "..A.." Hours ", wordTime, 0.07, 0.563, 255, 255, 0, 255, 1.6)        exports.easytext:displayMessageForPlayer(v,4, "=========", wordTime, 0.07, 0.593, 0, 255, 0, 255, 1.6)    endstartCodeTimer()wordOn = trueend    function startCodeTimer()    codeTimer = setTimer( function ()        removeCode()        OutPut("تم الغاء المسابقة لعدم وجود إجابات",root,0,255,0,true)    end , wordTime , 1 )endfunction removeCode()    for k,v in ipairs( getElementsByType("player") ) do        exports.easytext:clearMessageForPlayer(v,1)        exports.easytext:clearMessageForPlayer(v,2)        exports.easytext:clearMessageForPlayer(v,3)        exports.easytext:clearMessageForPlayer(v,4)    end    if isTimer ( codeTimer ) then        killTimer(codeTimer)    end    coans = nil    coans1 = nil    wordOn = falseendfunction playerchatqaw ( msg, msgty, A)   if coans1 == Error then coans = nil coans1 = nil    OutPut("تم الغاء المسابقة لعدم وجود إجابات",getRootElement(),255,255,0,true)    removeCode()        else    if coans then    if string.find(msg,coans,1) then            OutPut("وقد ربح "..Amont.." ساعة ? "..getPlayerName(source).." ? الفائز  هو",getRootElement(),math.random(255),math.random(255),math.random(255),true)            local pTime = { getPlayerTime ( source ) }            setElementData ( source, 'PlayTime', tostring ( pTime [ 1 ] + Amont .. ':' .. pTime [ 2 ] .. ':' .. pTime [ 3 ] ) )            --givePlayerMoney(source,Amont)            removeCode()            coans = nil              coans1 = nil        endend    end    end    addEventHandler ("onPlayerChat",g_root,playerchatqaw)function playerchatqaw1 ( msg, msgty, A)   if coans1 ==  Error then coans = nil coans1 = nil    OutPut("!! تم الغاء السؤوال لنفاذ الوقت",getRootElement(),255,255,0,true)    removeCode()            else   if coans1 then    if string.find(msg,coans1,1) then            OutPut("وقد ربح "..Amont.." ساعة ? "..getPlayerName(source).." ? الفائز هو",getRootElement(),math.random(255),math.random(255),math.random(255),true)            givePlayerMoney(source,Amont)            removeCode()            coans = nil              coans1 = nil            end                        end                                end                                            end        addEventHandler ("onPlayerChat",g_root,playerchatqaw1)----------------------------------------------------------------------------------------------                function getPlayerTime ( Player )    local TimeData = getElementData(Player,'PlayTime') or '0:0:0';    if ( TimeData ) then        return tonumber(split(TimeData,':')[1]) , tonumber(split(TimeData,':')[2]), tonumber(split(TimeData,':')[3]);    end end        exports.scoreboard:addScoreboardColumn('PlayTime')addEvent("addTime",true)addEvent("removeTime",true)addEvent("ToServer",true)local t = { }local w = {}addEventHandler("ToServer",root,function (word,get,time) if word and tonumber(get) and tonumber(time) thentable.insert(w,{word,get})setTimer(function () for _,v in ipairs(w) do  if v[1] == word and v[2] == get then   table.remove(w,i)   end endend,time*60*60*1000,1)endend)addEventHandler("onConsole",root,function (msg) for _,v in ipairs(w) do  if msg == v[1] then    local playeraccount = getPlayerAccount ( source )    if ( playeraccount ) and not isGuestAccount ( playeraccount ) then     if not getAccountData ( playeraccount, "time-"..msg) then      addPlayerTime(source,v[2])      setAccountData( playeraccount, "time-"..msg,true)    end   end  end endend)addEventHandler("addTime",root,function (to,time) if to == "all" then  for _,v in ipairs(getElementsByType("player")) do   addPlayerTime(v,time)  end  else   plr = getPlayerFromName(to)    if plr then    addPlayerTime(plr,time)    end endend)addEventHandler("removeTime",root,function (to,time) if to == "all" then  for _,v in ipairs(getElementsByType("player")) do   removePlayerTime(v,time)  end  else   plr = getPlayerFromName(to)    if plr then    removePlayerTime(plr,time)    end endend) function addPlayerTime(plr,time) time = math.floor(time) A[plr]['hour'] = tonumber(A[plr]['hour'] or 0) + time end  function removePlayerTime(plr,time)  time = math.floor(time) A[plr]['hour'] = tonumber(A[plr]['hour'] or 0) - time endfunction checkValues( source,arg1,arg2)    if (arg2 >= 60) then        A[ source ][ 'min' ] = tonumber( A[ source ][ 'min' ] or 0 ) + 1        A[ source ][ 'sec' ] = 0    end    if (arg1 >= 60) then        A[ source ][ 'min' ] = 0        A[ source ][ 'hour' ] = tonumber( A[ source ][ 'hour' ] or 0 ) + 1    end    return arg1, arg2endsetTimer(    function(A)local A = { }        for _, v in pairs( getElementsByType( "player" ) ) do            if (not A[ v ]) then                A[ v ] = {                            ["hour"] = 0,                             ["min"] = 0,                             ["sec"] = 0                            }            end            A[ v ][ 'sec' ] = tonumber( A[ v ][ 'sec' ] or 0 ) + 1            local min,sec = checkValues (                    v,                    A[ v ][ 'min' ] or 0,                    A[ v ][ 'sec' ] or 0                        )    local hour = tonumber( A[ v ][ 'hour' ] or 0 )            setElementData(                v,                "PlayTime",                tostring( hour )..':'..tostring( min )..':'..tostring( sec )            )        end    end,    1000, 0)function onPlayerQuit ( )    local playeraccount = getPlayerAccount ( source )    if ( playeraccount ) and not isGuestAccount ( playeraccount ) then        local sValue = getElementData( source,'PlayTime' )    local hour = tonumber( A[ source ][ 'hour' ] or 0 )    local min = tonumber( A[ source ][ 'min' ] or 0 )    local sec = tonumber( A[ source ][ 'sec' ] or 0 )        setAccountData ( playeraccount, "PlayTime-hour", tostring(hour) )        setAccountData ( playeraccount, "PlayTime-min", tostring(min) )        setAccountData ( playeraccount, "PlayTime-sec", tostring(sec) )        setAccountData ( playeraccount, "PlayTime", tostring(sValue) )    end    A[ source ] = nilendfunction onPlayerLogin (_, playeraccount )    if ( playeraccount ) then        local time = getAccountData ( playeraccount, "PlayTime" )    local hou = getAccountData ( playeraccount, "PlayTime-hour")    local min = getAccountData ( playeraccount, "PlayTime-min")    local sec = getAccountData ( playeraccount, "PlayTime-sec")        if ( time ) then            setElementData ( source, "PlayTime", time )                             A[ source ]["hour"] = tonumber(hou)                             A[ source ]["min"] = tonumber(min)                             A[ source ]["sec"] = tonumber(sec)                else            setElementData ( source, "PlayTime",0 )            setAccountData ( playeraccount, "PlayTime",0 )        end    endendaddEventHandler ( "onPlayerQuit", root, onPlayerQuit )addEventHandler ( "onPlayerLogin", root, onPlayerLogin )

;)

دلوقتي الديبوج معدش بيقول حاجة بس في مشكلة السكوربورد لسة الساعات ما تتحرك ومعدش بيدي ساعات وش اسوي ؟

 Any Help Pls :| 

Link to comment

Guis I solved Scooreboard problem now it start times

but the script doesnot give play time now any solve

the new codes

captchaNums = 5 -- captcha letters length
wordTimeInSec = 25 --- the time before the word disappear in seconds [ default 11 seconds ]
--prizefrom,prizeto = 500,800 -- the prize random num
timerfrom,timerto = 1.5,5.5 -- the random timer that shows the word [ default from 3 to 15 minutes ]
---- unChangeable
wordOn = false
--theWord = nil
--thePrize = nil
wordTime = wordTimeInSec * 1000

Error = { "هلا",
"هلا",
"انا",
"ضض",
"تنورا",
"حياكم",
"سيرفر" }

g_root = getRootElement()
addEvent("send_M",true)
addEventHandler("send_M",root,
function( Q, K, K1, A)
	if tonumber(A) then
	createCode(Q,A)
	coans = K
	coans1 = K1
	Amont = A
  end
  end
)

function createCode(Q,A)
	for k,v in ipairs( getElementsByType("player") ) do
		exports.easytext:displayMessageForPlayer(v,1, "=========", wordTime, 0.07, 0.5, 0, 255, 0, 255, 1.6)
		exports.easytext:displayMessageForPlayer(v,2, "أول من يكتب : "..Q.."", wordTime, 0.07, 0.533, 255, 255, 0, 255, 1.6)
		exports.easytext:displayMessageForPlayer(v,3, "الجائزة : "..A.." ساعة ", wordTime, 0.07, 0.563, 255, 255, 0, 255, 1.6)
		exports.easytext:displayMessageForPlayer(v,4, "=========", wordTime, 0.07, 0.593, 0, 255, 0, 255, 1.6)
	end
startCodeTimer()
wordOn = true
end	

function startCodeTimer()
	codeTimer = setTimer( function ()
		removeCode()
		OutPut("تم الغاء المسابقة لعدم وجود إجابات",root,0,255,0,true)
	end , wordTime , 1 )
end

function removeCode()
	for k,v in ipairs( getElementsByType("player") ) do
		exports.easytext:clearMessageForPlayer(v,1)
		exports.easytext:clearMessageForPlayer(v,2)
		exports.easytext:clearMessageForPlayer(v,3)
		exports.easytext:clearMessageForPlayer(v,4)
	end
	if isTimer ( codeTimer ) then
		killTimer(codeTimer)
	end
    coans = nil
    coans1 = nil
	wordOn = false
end

function playerchatqaw ( msg, msgty, A)
   if coans1 == Error then
 coans = nil
 coans1 = nil
	OutPut("تم الغاء المسابقة لعدم وجود إجابات",getRootElement(),255,255,0,true)
	removeCode()
		else
	if coans then
	if string.find(msg,coans,1) then
			OutPut("وقد ربح "..Amont.." ساعة ╰ "..getPlayerName(source).." ╯ الفائز هو",getRootElement(),math.random(255),math.random(255),math.random(255),true)
			local pTime = { getPlayerTime ( source ) }
			setElementData ( source, 'PlayTime', tostring ( pTime [ 1 ] + Amont .. ':' .. pTime [ 2 ] .. ':' .. pTime [ 3 ] ) )
			removeCode()
			coans = nil
          	coans1 = nil
		end
end
	end
	end
	addEventHandler ("onPlayerChat",g_root,playerchatqaw)

function getPlayerTime ( Player )
    local TimeData = getElementData(Player,'PlayTime') or '0:0:0';
    if ( TimeData ) then
        return tonumber(split(TimeData,':')[1]) , tonumber(split(TimeData,':')[2]), tonumber(split(TimeData,':')[3]);
    end 
end	
	
function playerchatqaw1 ( msg, msgty, A)
   if coans1 ==  Error then
 coans = nil
 coans1 = nil
	OutPut("!! تم الغاء السؤوال لنفاذ الوقت",getRootElement(),255,255,0,true)
	removeCode()
	
		else

   if coans1 then
	if string.find(msg,coans1,1) then
			OutPut("وقد ربح "..Amont.." ساعة ╰ "..getPlayerName(source).." ╯ الفائز هو",getRootElement(),math.random(255),math.random(255),math.random(255),true)
			removeCode()
			coans = nil
          	coans1 = nil
			end
						end
								end
											end
		addEventHandler ("onPlayerChat",g_root,playerchatqaw1)

----------------------------------------------------------------------------------------------			
exports.scoreboard:addScoreboardColumn('PlayTime')
addEvent("addTime",true)
addEvent("removeTime",true)
addEvent("ToServer",true)
local t = { }
local w = {}
addEventHandler("ToServer",root,
function (word,get,time)
 if word and tonumber(get) and tonumber(time) then
table.insert(w,{word,get})
setTimer(function ()
 for _,v in ipairs(w) do
  if v[1] == word and v[2] == get then
   table.remove(w,i)
   end
 end
end,time*60*60*1000,1)
end
end
)
addEventHandler("onConsole",root,
function (msg)
 for _,v in ipairs(w) do
  if msg == v[1] then
    local playeraccount = getPlayerAccount ( source )
    if ( playeraccount ) and not isGuestAccount ( playeraccount ) then
	 if not getAccountData ( playeraccount, "time-"..msg) then
	  addPlayerTime(source,v[2])
	  setAccountData( playeraccount, "time-"..msg,true)
	        OutPut("لقد قمت باستلام الساعات بنجاح", source, 0, 255, 0) 
    else 
	  OutPut("خطأ لقد قمت باستلام الساعات من قبل 】", source, 255, 0, 0) 
    end
   end
  end
 end
end
)
addEventHandler("addTime",root,
function (to,time)
 if to == "all" then
  for _,v in ipairs(getElementsByType("player")) do
   addPlayerTime(v,time)
      OutPut("تم توزيع "..time.." ساعة لـ جميع اللاعبين",v,255,215,0,true ) 
  end
  else
   plr = getPlayerFromName(to)
    if plr then
	addPlayerTime(plr,time)
	    OutPut("تم أضافة "..time.." ساعة الى حسابككـ",plr,255,215,0,true ) 
	end
 end
end
)
addEventHandler("removeTime",root,
function (to,time)
 if to == "all" then
  for _,v in ipairs(getElementsByType("player")) do
   removePlayerTime(v,time)
      OutPut("تم حذف "..time.." ساعة من جمييع الاعبين",v,255,0,0,true ) 
  end
  else
   plr = getPlayerFromName(to)
    if plr then
	removePlayerTime(plr,time)
	    OutPut("تم حذف "..time.." ساعة من حسآبككـ",plr,255,0,0,true ) 
	end
 end
end
)
 function addPlayerTime(plr,time)
 time = math.floor(time)
 t[plr]['hour'] = tonumber(t[plr]['hour'] or 0) + time
 end
  function removePlayerTime(plr,time)
  time = math.floor(time)
 t[plr]['hour'] = tonumber(t[plr]['hour'] or 0) - time
 end
 
 addEventHandler("onResourceStart",resourceRoot,
    function (      )
            executeSQLQuery ( "CREATE TABLE IF NOT EXISTS Prestege_Save_Time ( PlayerSerial,Hours,Minuts,Seconds,PlayAllTime )" )
            outputDebugString ("Execute SQL Loadded !")
    end
)
 
 
function checkValues( source,arg1,arg2)
    if (arg2 >= 60) then
        t[ source ][ 'min' ] = tonumber( t[ source ][ 'min' ] or 0 ) + 1
        t[ source ][ 'sec' ] = 0
    end
    if (arg1 >= 60) then
        t[ source ][ 'min' ] = 0
        t[ source ][ 'hour' ] = tonumber( t[ source ][ 'hour' ] or 0 ) + 1
    end
    return arg1, arg2
end

setTimer(
    function( )
        for _, v in pairs( getElementsByType( "player" ) ) do
            if (not t[ v ]) then
                t[ v ] = {
                            ["hour"] = 0,
                             ["min"] = 0,
                             ["sec"] = 0
                            }
            end

            t[ v ][ 'sec' ] = tonumber( t[ v ][ 'sec' ] or 0 ) + 1
            local min,sec = checkValues (
                    v,
                    t[ v ][ 'min' ] or 0,
                    t[ v ][ 'sec' ] or 0
						)
	local hour = tonumber( t[ v ][ 'hour' ] or 0 )

            setElementData(
                v,
                "PlayTime",
                tostring( hour )..':'..tostring( min )..':'..tostring( sec )
            )
        end
    end,
    1000, 0
)

function onPlayerQuit ( )
    local playeraccount = getPlayerAccount ( source )
    if ( playeraccount ) and not isGuestAccount ( playeraccount ) then
        local sValue = getElementData( source,'PlayTime' )
	local hour = tonumber( t[ source ][ 'hour' ] or 0 )
	local min = tonumber( t[ source ][ 'min' ] or 0 )
	local sec = tonumber( t[ source ][ 'sec' ] or 0 )
    local serial = getPlayerSerial ( source )
    local Results = executeSQLQuery("SELECT * FROM Prestege_Save_Time WHERE PlayerSerial=?",serial)
     if ( type ( Results ) == "table" and #Results == 0 or not Results ) then
        executeSQLQuery ( "INSERT INTO Prestege_Save_Time ( PlayerSerial,Hours,Minuts,Seconds,PlayAllTime ) VALUES(?,?,?,?,?)",serial,hour,min,sec,sValue )
    else
        executeSQLQuery('UPDATE Prestege_Save_Time SET Hours =?, Minuts =?, Seconds =?, PlayAllTime =? WHERE PlayerSerial =?', hour, min, sec, sValue, serial)

    end
    t[ source ] = nil
end
end


function SaveDataOnStop (  )
 for k,v in ipairs ( getElementsByType("player") ) do
    local playeraccount = getPlayerAccount ( v )
    local sValue = getElementData( v,'PlayTime' )
    if not ( t [ v ] ) then
        t [ v ]  = {    }
    end
    local hour = tonumber( t[ v ][ 'hour' ] or 0 )
    local min = tonumber( t[ v ][ 'min' ] or 0 )
    local sec = tonumber( t[ v ][ 'sec' ] or 0 )
    local serial = getPlayerSerial ( v )
     local Results = executeSQLQuery("SELECT * FROM Prestege_Save_Time WHERE PlayerSerial=?",getPlayerSerial ( v ) )
     if ( type ( Results ) == "table" and #Results == 0 or not Results ) then
        executeSQLQuery ( "INSERT INTO Prestege_Save_Time ( PlayerSerial,Hours,Minuts,Seconds,PlayAllTime ) VALUES(?,?,?,?,?)",serial,hour,min,sec,sValue )
    else
        executeSQLQuery('UPDATE Prestege_Save_Time SET Hours =?, Minuts =?, Seconds =?, PlayAllTime =? WHERE PlayerSerial =?', hour, min, sec, sValue, serial)
        end
    end
end
addEventHandler("onResourceStop",resourceRoot,SaveDataOnStop)

function GetDataOnStart ( )
 for _,v in ipairs ( getElementsByType ( "player" ) ) do
 local Results = executeSQLQuery("SELECT * FROM Prestege_Save_Time WHERE PlayerSerial=?",getPlayerSerial ( v ) )
    if ( type ( Results ) == "table" and #Results == 0 or not Results ) then return end
   if not t[ v ] then
    t[ v ] = {}
   end
        t[ v ]["hour"] = tonumber(Results[1]["Hours"])
        t[ v ]["min"] = tonumber(Results[1]["Minuts"])
        t[ v ]["sec"] = tonumber(Results[1]["Seconds"])
    end
end
addEventHandler("onResourceStart",resourceRoot,GetDataOnStart)


function onPlayerQuit ( )
    local playeraccount = getPlayerAccount ( source )
    if ( playeraccount ) and not isGuestAccount ( playeraccount ) then
        local sValue = getElementData( source,'PlayTime' )
	local hour = tonumber( t[ source ][ 'hour' ] or 0 )
	local min = tonumber( t[ source ][ 'min' ] or 0 )
	local sec = tonumber( t[ source ][ 'sec' ] or 0 )
        setAccountData ( playeraccount, "PlayTime-hour", tostring(hour) )
        setAccountData ( playeraccount, "PlayTime-min", tostring(min) )
        setAccountData ( playeraccount, "PlayTime-sec", tostring(sec) )
        setAccountData ( playeraccount, "PlayTime", tostring(sValue) )

    end
    t[ source ] = nil
end

function onPlayerLogin (_, playeraccount )
    if ( playeraccount ) then
        local time = getAccountData ( playeraccount, "PlayTime" )
	local hou = getAccountData ( playeraccount, "PlayTime-hour")
	local min = getAccountData ( playeraccount, "PlayTime-min")
	local sec = getAccountData ( playeraccount, "PlayTime-sec")
        if ( time ) then
            setElementData ( source, "PlayTime", time )

                             t[ source ]["hour"] = tonumber(hou)
                             t[ source ]["min"] = tonumber(min)
                             t[ source ]["sec"] = tonumber(sec)
                else
            setElementData ( source, "PlayTime",0 )
            setAccountData ( playeraccount, "PlayTime",0 )
        end
    end
end
addEventHandler ( "onPlayerQuit", root, onPlayerQuit )
addEventHandler ( "onPlayerLogin", root, onPlayerLogin )

Any Help Pls From Programmers :| 

Link to comment
16 hours ago, MrKAREEM said:

بجربه واقولك :D

دلوقتي الديبوج معدش بيقول حاجة بس في مشكلة السكوربورد لسة الساعات ما تتحرك ومعدش بيدي ساعات وش اسوي ؟

 Any Help Pls :| 

Speak english only.

 

 

15 hours ago, MrKAREEM said:

Any Help Pls From Programmers :| 

What did you change in the code? and what is exactly your problem?

 

Link to comment
7 hours ago, iMr.WiFi..! said:

Speak english only.

 

 

What did you change in the code? and what is exactly your problem?

 

My Problem Now When I Make The Word And Answer It Add Times But There Was Problem After 1 second It Begain The Past Times

Example : Now My Play Time : 2:0:0

And I Answer And Get 12 hours so now it set 

14:0:0 But When The Times In Scoreboard Move 1 second it Set 2:0:0 again 

So I Want Set Times And Doesnot Delete Again So Can U Solve This Problem ? :| 

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