Jump to content
  • 0

@gametime & @playtime command..


Meister

Question


  • Group:  Members
  • Topic Count:  280
  • Topics Per Day:  0.06
  • Content Count:  841
  • Reputation:   17
  • Joined:  04/16/12
  • Last Seen:  

Anyone can share or make a src code in which..

1. when using @gametime - command it will show how many minutes your account has played the game..

2. when using @playtime - it will show how many minutes you have played from its first login..

example..

@gametime --

dispbottom > You have played 136 total.

like the example above..

any question..

With this script or src modification. Do I need to add tables? like login minute? Thanks!

Edited by emong
Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  12
  • Reputation:   1
  • Joined:  12/23/11
  • Last Seen:  

Hi!

Sorry, I'm misunderstood your request :P

Could you please try this then? GameTime will be saved once the command is called or players have log-out from the game.

-    script    atcmd_gamestat    -1,{
OnInit:
   bindatcmd("gametime","atcmd_gamestat::OnGameTime");
   bindatcmd("playtime","atcmd_gamestat::OnPlayTime");
   end;
OnPlayTime:
   set .@time,(gettimetick(2) - @gs_playtime);
   set .@h,.@time / 3600;
   set .@m,.@time / 60 % 60;
   set .@s,.@time % 60;
   dispbottom "You have played "+.@h+"h "+.@m+"m and "+.@s+"s.";

   end;
OnGameTime:        
   set gs_gametime,@gs_gametime_t+(gettimetick(2) - @gs_playtime); //Save GameTime total
   set .@time,gs_gametime;
   set .@d,.@time / 86400 % 7;
   set .@h,.@time / 3600 % 24;
   set .@m,.@time / 60 % 60;
   set .@s,.@time % 60;
   dispbottom "You have played "+.@d+"d "+.@h+"h "+.@m+"m and "+.@s+"s total.";
   end;
OnPCLoginEvent:
   set @gs_playtime,gettimetick(2);
   set @gs_gametime_t,gs_gametime;
   end;
OnPCLogoutEvent:
   set gs_gametime,@gs_gametime_t+(gettimetick(2) - @gs_playtime); //Save GameTime total
   end;
}

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Forum Manager
  • Topic Count:  282
  • Topics Per Day:  0.06
  • Content Count:  3122
  • Reputation:   1614
  • Joined:  03/26/12
  • Last Seen:  

Do you mean since the player logged in, or since the char was created? If it's since last login you could do it with either a timer or an sql query o.O

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  280
  • Topics Per Day:  0.06
  • Content Count:  841
  • Reputation:   17
  • Joined:  04/16/12
  • Last Seen:  

ayy. wait edited hehe. Sorry for the misunderstanding. and yeah..

its like this..

@gametime - is for the whole time the account has played..

@playtime - the time of the player from its first login..

Thanks!

Do you mean since the player logged in, or since the char was created? If it's since last login you could do it with either a timer or an sql query o.O

I have a question with the timer.. cause if I use timer. How will I use the @playtime command?

Edited by emong
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  280
  • Topics Per Day:  0.06
  • Content Count:  841
  • Reputation:   17
  • Joined:  04/16/12
  • Last Seen:  

i don't see nothing wrong with a little bump and grind - *Bump hehe.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  12
  • Reputation:   1
  • Joined:  12/23/11
  • Last Seen:  

Try this...

-	script	atcmd_gamestat	-1,{
OnInit:
bindatcmd("gametime","atcmd_gamestat::OnGameTime");
bindatcmd("playtime","atcmd_gamestat::OnPlayTime");
end;
OnPlayTime:
set .@min,(gettimetick(2) - gs_playtime) / 60;
set .@sec,(gettimetick(2) - gs_playtime) % 60;
dispbottom "You have played "+.@min+" min and "+.@sec+" sec.";
end;
OnGameTime:
dispbottom "You have played "+gs_gametime+" total";
end;
OnPCLoginEvent:
set gs_gametime,gs_gametime+1;
set gs_playtime,gettimetick(2);
end;
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  280
  • Topics Per Day:  0.06
  • Content Count:  841
  • Reputation:   17
  • Joined:  04/16/12
  • Last Seen:  

Try this...

-	script	atcmd_gamestat	-1,{
OnInit:
bindatcmd("gametime","atcmd_gamestat::OnGameTime");
bindatcmd("playtime","atcmd_gamestat::OnPlayTime");
end;
OnPlayTime:
set .@min,(gettimetick(2) - gs_playtime) / 60;
set .@sec,(gettimetick(2) - gs_playtime) % 60;
dispbottom "You have played "+.@min+" min and "+.@sec+" sec.";
end;
OnGameTime:
dispbottom "You have played "+gs_gametime+" total";
end;
OnPCLoginEvent:
set gs_gametime,gs_gametime+1;
set gs_playtime,gettimetick(2);
end;
}

wow fantastic! but something's wrong with the timer..

e.g.

at first login (just seconds later).. when I used command @playtime: it will display "You have played for 1 min and 15 seconds" - even it didn't pass 1 minute yet..

and for the @gametime.. e.g. it doesn't add up. it is still 1 .. "You have played 1 total" .. how to set it with hr + min + sec? and if possible +days..

Thanks!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  280
  • Topics Per Day:  0.06
  • Content Count:  841
  • Reputation:   17
  • Joined:  04/16/12
  • Last Seen:  

Hi!

Sorry, I'm misunderstood your request :P

Could you please try this then? GameTime will be saved once the command is called or players have log-out from the game.

-	script	atcmd_gamestat	-1,{
OnInit:
bindatcmd("gametime","atcmd_gamestat::OnGameTime");
bindatcmd("playtime","atcmd_gamestat::OnPlayTime");
end;
OnPlayTime:
set .@time,(gettimetick(2) - @gs_playtime);
set .@h,.@time / 3600;
set .@m,.@time / 60 % 60;
set .@s,.@time % 60;
dispbottom "You have played "+.@h+"h "+.@m+"m and "+.@s+"s.";

end;
OnGameTime:		
set gs_gametime,@gs_gametime_t+(gettimetick(2) - @gs_playtime); //Save GameTime total
set .@time,gs_gametime;
set .@d,.@time / 86400 % 7;
set .@h,.@time / 3600 % 24;
set .@m,.@time / 60 % 60;
set .@s,.@time % 60;
dispbottom "You have played "+.@d+"d "+.@h+"h "+.@m+"m and "+.@s+"s total.";
end;
OnPCLoginEvent:
set @gs_playtime,gettimetick(2);
set @gs_gametime_t,gs_gametime;
end;
OnPCLogoutEvent:
set gs_gametime,@gs_gametime_t+(gettimetick(2) - @gs_playtime); //Save GameTime total
end;
}

Papeng! Thanks! Working great! BUT there's a problem for @gametime..

e.g. When the server restart or I run ./athena-start stop and re run it agian. The @gametime also disappears.. How to solve it?

Edited by emong
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  12
  • Reputation:   1
  • Joined:  12/23/11
  • Last Seen:  

@emong,

@gametime only saved data when player called the command or he/she log-out from the game.

I'm not sure whether it would be good to put a timer to save gametime on each online player.

If you do @kickall before close the server, I think it would trigger the OnPCLogoutEvent and save gametime variable.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  280
  • Topics Per Day:  0.06
  • Content Count:  841
  • Reputation:   17
  • Joined:  04/16/12
  • Last Seen:  

thanks for the explanation. So if I randomly close the server the variable isn't save and there is that possibility that the save data for that variable will be lost?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  52
  • Reputation:   0
  • Joined:  04/27/13
  • Last Seen:  

i think its cool script i will try it today

 

 

Thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...