Jump to content
  • 0

@gametime & @playtime command..


Question

Posted (edited)

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

10 answers to this question

Recommended Posts

  • 1
Posted

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
Posted

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

Posted (edited)

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
Posted

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;
}

Posted

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!

Posted (edited)

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
Posted

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

Posted

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?

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...