Turbe$Z Posted March 18, 2017 Share Posted March 18, 2017 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? Link to comment
NeXuS™ Posted March 18, 2017 Share Posted March 18, 2017 Line nr. 4 if hour = 30 then change to if hour == 30 then Link to comment
Turbe$Z Posted March 18, 2017 Author Share Posted March 18, 2017 13 minutes ago, NeXuS™ said: Line nr. 4 if hour = 30 then change to if hour == 30 then changed, but the script doesn't add me to the aclgroup Link to comment
NeXuS™ Posted March 18, 2017 Share Posted March 18, 2017 Try sending the hour variable to the chat. outputChatBox(hour) Link to comment
itHyperoX Posted March 18, 2017 Share Posted March 18, 2017 (edited) aclGroupAddObject (aclGetGroup(" Dependent "), "user."..accountName) -- Edited March 18, 2017 by TheMOG Link to comment
NeXuS™ Posted March 18, 2017 Share Posted March 18, 2017 Jees @TheMOG, that comment doesn't look very nice . Link to comment
itHyperoX Posted March 18, 2017 Share Posted March 18, 2017 i'll let you fix it maister @NeXuS™ Link to comment
NeXuS™ Posted March 18, 2017 Share Posted March 18, 2017 I'm a Poot-butt, not a maister. Link to comment
Turbe$Z Posted March 18, 2017 Author Share Posted March 18, 2017 6 minutes ago, NeXuS™ said: Try sending the hour variable to the chat. outputChatBox(hour) doesn't work Link to comment
NeXuS™ Posted March 18, 2017 Share Posted March 18, 2017 Use debugscript 3. What error do you get? Link to comment
Turbe$Z Posted March 18, 2017 Author Share Posted March 18, 2017 2 minutes ago, NeXuS™ said: Use debugscript 3. What error do you get? i do not get errors Link to comment
NeXuS™ Posted March 18, 2017 Share Posted March 18, 2017 What calls the dependent function? Does it even get called? Link to comment
itHyperoX Posted March 18, 2017 Share Posted March 18, 2017 Make sure the resource have permission aclAddGroup (ACL) Link to comment
Turbe$Z Posted March 18, 2017 Author Share Posted March 18, 2017 1 minute ago, NeXuS™ said: What calls the dependent function? Does it even get called? no Just now, TheMOG said: Make sure the resource have permission aclAddGroup (ACL) i added 'resource.jatszottido' to admin group Link to comment
NeXuS™ Posted March 18, 2017 Share Posted March 18, 2017 And what should call the dependent function? Link to comment
Turbe$Z Posted March 18, 2017 Author Share Posted March 18, 2017 Just now, NeXuS™ said: And what should call the dependent function? nothing Link to comment
itHyperoX Posted March 18, 2017 Share Posted March 18, 2017 (edited) 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 March 18, 2017 by TheMOG Link to comment
NeXuS™ Posted March 18, 2017 Share Posted March 18, 2017 (edited) Then maybe do a command that can call dependent? Edited March 18, 2017 by NeXuS™ Link to comment
Turbe$Z Posted March 18, 2017 Author Share Posted March 18, 2017 6 minutes ago, NeXuS™ said: Then maybe do a command that can call dependent? no Link to comment
NeXuS™ Posted March 18, 2017 Share Posted March 18, 2017 You are making a script which does nothing? Link to comment
Turbe$Z Posted March 18, 2017 Author Share Posted March 18, 2017 1 minute ago, NeXuS™ said: You are making a script which does nothing? no, i want, when player have xy hour or minute, then add to a aclgroup Link to comment
NeXuS™ Posted March 18, 2017 Share Posted March 18, 2017 Then go to your script which increases the player's played hours, and if he reaches a full hour, call the dependent function with the player at arg 1. Link to comment
Ayush Rathore Posted March 19, 2017 Share Posted March 19, 2017 (edited) 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? 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 March 19, 2017 by Ayush Rathore Link to comment
Turbe$Z Posted March 19, 2017 Author Share Posted March 19, 2017 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? Link to comment
NeXuS™ Posted March 19, 2017 Share Posted March 19, 2017 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now