Raised This Month: $ Target: $400
 0% 

"set_user_time" for bots


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-27-2010 , 21:27   Re: "set_user_time" for bots
Reply With Quote #1

Quote:
and I want to be the uptime since the bot was created..
Well...
You have to start timer, when player joins. That's all I think...
Define get_gametime, when player joins and then check time played by defined gametime - current gametime.

Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new Float: gametime[33]

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_clcmd("say /time", "cmd_timer");
}

public player_connect(id)
{
gametime[id] =  get_gametime ( )
}

public cmd_timer(id)
{
new Float: szSec[33]
szSec[id] = (get_gametime ( ) - gametime[id])
client_print(id,print_chat, "You're playing already for %s seconds", szSec[id])
}

public player_disconnect(id)
{
gametime[id] =  0.00
}
I haven't test it, but it compiles.

Last edited by Gadzislaw007; 07-27-2010 at 21:57.
Gadzislaw007 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-27-2010 , 23:52   Re: "set_user_time" for bots
Reply With Quote #2

Just made a few corrections. Untested
PHP Code:
#include <amxmodx>

new Floatg_fGameTime33 ];

public 
plugin_init()
{
    
register_clcmd("say /time""cmd_timer");
}

public 
client_connectid )
{
    
g_fGameTimeid ] = get_gametime();
}

public 
client_disconnectid )
{
    
g_fGameTimeid ] = 0.0;
}

public 
cmd_timerid )
{
    new 
FloatfSec = ( get_gametime() - g_fGameTimeid ] );
    
client_printid print_chat "You're playing already for %f seconds" fSec );

__________________

Last edited by Bugsy; 07-28-2010 at 00:03.
Bugsy is offline
portocala
Member
Join Date: Jun 2010
Old 07-28-2010 , 02:55   Re: "set_user_time" for bots
Reply With Quote #3

It is "set_user_time" (with quotes, because the function doesn't exist) because this is what I want to do... a function like this!

The uptime must be 'native'. So if I call get_user_time(bot), the result must be the real uptime since the bot was created.

Recap:
I suppose that there are 2 ways to do it:

1. Find a way to create the bot with native uptime, using real time since he was created and not the server uptime;

or

2. Find a way to set bot uptime (something similar with "set_user_time", rewriting the original uptime), so when I call get_user_time(bot), the result will be the number in seconds since the bot was created.

I hope you understand, I want the uptime to be native (when you type "status" and others).

Thank you again... and thanks for that code, but this is not what I want.
portocala is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:10.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode