isa_Khamdan Posted February 4, 2014 Share Posted February 4, 2014 Hello, I want to make a command that's add a user into a group named X and after X days the user will be removed from the group so for example let's say the command is X Player 7 then the player will be added to the group and get removed from it after 7 days. Ok so I know how to get real time but how can I make it remove the user after X days? I know how to set account data but I don't know what exactly I should set as account data. So can anyone help me to solve this problem? Link to comment
Saml1er Posted February 4, 2014 Share Posted February 4, 2014 (edited) I'm on mobile so can't help you with code but anyways you can use. -- I might type wrong name but search for those functions in wiki gn = "" Timer9 = "" Timer87 = "" addCommandHandler("add", DaysNname ) function DaysNname ( thePlayer, command, pname, groupname, Days ) local Days = tonumber ( Days ) if pname and groupname and Days then local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then aclGroupAddObject ( "user."..pname, aclGetGroup ( groupname ) ) -- Now use getTickCount() so you can manage 7 days for example startTick = getTickCount() local endTick = getTickCount() local tick = endTick - startTick local hours = ( ( endTick / 1000 ) / 60 ) / 60 gn = groupname Timer9 = Days * 24 Timer87 = hours end end end addEventHandler ("onPlayerJoin", getRootElement(), function ( ) if ppname == getPlayerName ( source ) then if Timer87 >= Timer9 then aclGroupRemoveObject (aclGetGroup ( gn ), "user."..getPlayerName ( source ) ) end end end ) Note : This is just an example, you should use SQL or xml for saving Player name, days and time., Edited February 5, 2014 by Guest Link to comment
TAPL Posted February 4, 2014 Share Posted February 4, 2014 I'm on mobile so can't help you with code but anyways you can use.-- I might type wrong name but search for those functions in wiki gn = "" Timer9 = "" Timer87 = "" addCommandHandler("add", DaysNname ) function DaysNname ( thePlayer, command, pname, groupname, Days ) local Days = tonumber ( Days ) if pname and groupname and Days then local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup (aclGetGroup ( "Admin" ), "user."..accName ) then aclGroupAddObject ( aclGetGroup ( groupname ), "user."..pname ) -- Now use getTickCount() so you can manage 7 days for example startTick = getTickCount() local endTick = getTickCount() local tick = endTick - startTick local hours = ( ( endTick / 1000 ) / 60 ) / 60 gn = groupname Timer9 = Days * 24 Timer87 = hours end end end addEventHandler ("onPlayerJoin", getRootElement(), function ( ) if ppname == getPlayerName ( source ) then if Timer87 >= Timer9 then aclGroupRemoveObject (aclGetGroup ( gn ), "user."..getPlayerName ( source ) ) end end end ) You wasted your time then because it wrong and even if it was correct, if you restart the script everything will lost. Link to comment
Saml1er Posted February 4, 2014 Share Posted February 4, 2014 I'm on mobile so can't help you with code but anyways you can use.-- I might type wrong name but search for those functions in wiki gn = "" Timer9 = "" Timer87 = "" addCommandHandler("add", DaysNname ) function DaysNname ( thePlayer, command, pname, groupname, Days ) local Days = tonumber ( Days ) if pname and groupname and Days then local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup (aclGetGroup ( "Admin" ), "user."..accName ) then aclGroupAddObject ( aclGetGroup ( groupname ), "user."..pname ) -- Now use getTickCount() so you can manage 7 days for example startTick = getTickCount() local endTick = getTickCount() local tick = endTick - startTick local hours = ( ( endTick / 1000 ) / 60 ) / 60 gn = groupname Timer9 = Days * 24 Timer87 = hours end end end addEventHandler ("onPlayerJoin", getRootElement(), function ( ) if ppname == getPlayerName ( source ) then if Timer87 >= Timer9 then aclGroupRemoveObject (aclGetGroup ( gn ), "user."..getPlayerName ( source ) ) end end end ) You wasted your time then because it wrong and even if it was correct, if you restart the script everything will lost. Yeah, I saw your post after I submitted. ;/ Link to comment
isa_Khamdan Posted February 4, 2014 Author Share Posted February 4, 2014 Use timestamp. Can you give me example please? Link to comment
Saml1er Posted February 4, 2014 Share Posted February 4, 2014 Well I really want to help you but I don't have access to my pc but anyways you can also use SQL or setElementData to save the real time ( hour, minute ), year, month, day and you can remove the player from acl group by subtracting the new time by old time onPlayerJoin or by setTimer (getRealTime(), 300000, 0 )and thus you'll get the result. Its pretty easy if you try to do it in this way. 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