Jump to content

Why not working aclGroupAddObject?


Turbe$Z

Recommended Posts

function dependent(player)
local accountName = getAccountName ( getPlayerAccount ( player ) )
local hour = getAccountData ( playeraccount, "Játszott idő-hours")
	if hour = 30 then
		aclGroupAddObject (aclGetGroup("Dependent"), "user."..accountName)
	end
end

i got this error:

[22:44:11] ERROR: Loading script failed: jatszottido\ji.lua:86: 'then' expected near '='

how to fix this? :S 

Link to comment
  1. function dependent(player)
    local accountName = getAccountName ( getPlayerAccount ( player ) )
    local hour = getAccountData (accountName, "Játszott idő-hours")
    if hour == 30 then
    aclGroupAddObject (aclGetGroup("Dependent"), "user."..accountName)
    end
    end 

     

Edited by TheMOG
Link to comment
6 hours ago, Turbo777 said:

function dependent(player)
local accountName = getAccountName ( getPlayerAccount ( player ) )
local hour = getAccountData ( playeraccount, "Játszott idő-hours")
	if hour = 30 then
		aclGroupAddObject (aclGetGroup("Dependent"), "user."..accountName)
	end
end

i got this error:

[22:44:11] ERROR: Loading script failed: jatszottido\ji.lua:86: 'then' expected near '='

how to fix this? :S 

this might fix it

exports.scoreboard:addScoreboardColumn("playtime")

local ptimer = {}

function playtime()
for i,player in ipairs(getElementsByType("player")) do
if ptimer[player] then 
ptimer[player] = ptimer[player] + 1
setElementData(player,"playtime",math.floor(ptimer[player]/3600).." hr")
end
end
end
setTimer(playtime,1000,0)

function dependent(player)
local accountName = getAccountName ( getPlayerAccount ( player ) )
local hour = (tonumber(getAccountData (  getPlayerAccount ( player ), "hour")) or 0)/3600
if hour >= 30 then
if aclGroupAddObject (aclGetGroup("SuperModerator"), "user."..accountName) == true then
redirectPlayer(player,"",0)
else
outputChatBox("You are now in group SuperModerator",player)
end
end
end


addEventHandler("onPlayerLogin", root,
function()
dependent(source)
ptimer[source] = (tonumber(getAccountData (  getPlayerAccount ( source ), "hour")) or 0)
end)

addEventHandler("onPlayerLogout", root,function(account)
if ptimer[source] then
setAccountData( account , "hour" , math.floor(ptimer[source]) )
ptimer[source] = nil
end
end)

well my script is a whole package of of what you want just remove other timer resource and use this but make sure this code needs acl right to perform tasks and also remove

if aclGroupAddObject (aclGetGroup("SuperModerator"), "user."..accountName) == true then
  
with
  
if aclGroupAddObject (aclGetGroup("Dependent"), "user."..accountName) == true then

 

 :) enjoy and good luck 

Edited by Ayush Rathore
Link to comment
4 hours ago, Ayush Rathore said:

this might fix it


exports.scoreboard:addScoreboardColumn("playtime")

local ptimer = {}

function playtime()
for i,player in ipairs(getElementsByType("player")) do
if ptimer[player] then 
ptimer[player] = ptimer[player] + 1
setElementData(player,"playtime",math.floor(ptimer[player]/3600).." hr")
end
end
end
setTimer(playtime,1000,0)

function dependent(player)
local accountName = getAccountName ( getPlayerAccount ( player ) )
local hour = (tonumber(getAccountData (  getPlayerAccount ( player ), "hour")) or 0)/3600
if hour >= 30 then
if aclGroupAddObject (aclGetGroup("SuperModerator"), "user."..accountName) == true then
redirectPlayer(player,"",0)
else
outputChatBox("You are now in group SuperModerator",player)
end
end
end


addEventHandler("onPlayerLogin", root,
function()
dependent(source)
ptimer[source] = (tonumber(getAccountData (  getPlayerAccount ( source ), "hour")) or 0)
end)

addEventHandler("onPlayerLogout", root,function(account)
if ptimer[source] then
setAccountData( account , "hour" , math.floor(ptimer[source]) )
ptimer[source] = nil
end
end)

well my script is a whole package of of what you want just remove other timer resource and use this but make sure this code needs acl right to perform tasks and also remove


if aclGroupAddObject (aclGetGroup("SuperModerator"), "user."..accountName) == true then
  
with
  
if aclGroupAddObject (aclGetGroup("Dependent"), "user."..accountName) == true then

 

 :) enjoy and good luck 

exports.scoreboard:addScoreboardColumn('Játszott idő')

local t = { }
 
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 ][ 'hours' ] = tonumber( t[ source ][ 'hours' ] or 0 ) + 1
    end
    return arg1, arg2
end
     
setTimer(
    function( )
        for _, v in pairs( getElementsByType( "player" ) ) do
            if (not t[ v ]) then
                t[ v ] = {
                            ["hours"] = 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 hours = tonumber( t[ v ][ 'hours' ] or 0 )

            setElementData(
                v,
                "Játszott idő",
				tostring( hours )..' óra '..tostring( min )..' perc'
            )
        end
    end,
    1000, 0
)
   
function onPlayerQuit ( )
    local playeraccount = getPlayerAccount ( source )
    if ( playeraccount ) and not isGuestAccount ( playeraccount ) then
        local sValue = getElementData( source,'Játszott idő' )
	local hours = tonumber( t[ source ][ 'hours' ] or 0 )
	local min = tonumber( t[ source ][ 'min' ] or 0 )
	local sec = tonumber( t[ source ][ 'sec' ] or 0 )
        setAccountData ( playeraccount, "Játszott idő-hours", tostring(hours) )
        setAccountData ( playeraccount, "Játszott idő-min", tostring(min) )
        setAccountData ( playeraccount, "Játszott idő-sec", tostring(sec) )
        setAccountData ( playeraccount, "Játszott idő", tostring(sValue) )

    end
    t[ source ] = nil
end
 
function onPlayerLogin (_, playeraccount )
    if ( playeraccount ) then
        local time = getAccountData ( playeraccount, "Játszott idő" )
	local hou = getAccountData ( playeraccount, "Játszott idő-hours")
	local min = getAccountData ( playeraccount, "Játszott idő-min")
	local sec = getAccountData ( playeraccount, "Játszott idő-sec")
        if ( time ) then
            setElementData ( source, "Játszott idő", time )

                             t[ source ]["hours"] = tonumber(hou)
                             t[ source ]["min"] = tonumber(min)
                             t[ source ]["sec"] = tonumber(sec)
                else
            setElementData ( source, "Játszott idő",0 )
            setAccountData ( playeraccount, "Játszott idő",0 )
        end
    end
end
addEventHandler ( "onPlayerQuit", root, onPlayerQuit )
addEventHandler ( "onPlayerLogin", root, onPlayerLogin )


function dependent(player)
local accountName = getAccountName ( getPlayerAccount ( player ) )
local minek = (tonumber(getAccountData (  getPlayerAccount ( player ), min)) or 0)/3600
	if minek >= 1 then
		if aclGroupAddObject (aclGetGroup("SuperModerator"), "user."..accountName) == true then
			outputChatBox("You are now in group SuperModerator",player)
		end
	end
end

This why not working? :S 

Link to comment

Replace your checkValues function

Spoiler

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 ][ 'hours' ] = tonumber( t[ source ][ 'hours' ] or 0 ) + 1
    end
    return arg1, arg2
end

 

with

Spoiler

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 ][ 'hours' ] = tonumber( t[ source ][ 'hours' ] or 0 ) + 1
    	dependent(source)
    end
    return arg1, arg2
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...