AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   "set_user_time" for bots (https://forums.alliedmods.net/showthread.php?t=133671)

portocala 07-27-2010 17:45

"set_user_time" for bots
 
Yes, I know that this function doesn't exists, bot how can I set the uptime for bots ? It is currently used the server uptime.

More details:

get_user_time(player) = normal uptime... since the player joined
get_user_time(bot) = server uptime

and I want to be the uptime since the bot was created..

If it is possible.. I saw it is.

Thank you!

Alucard^ 07-27-2010 17:54

Re: "set_user_time" for bots
 
I don't understand why you called "set_user_time" in the title and "get_user_time" in the thread, so i don't understand at all what you want.

If you want to use get_user_time() to bot, you tried like yo do with a player? using the index of the bot to the native?

Gadzislaw007 07-27-2010 21:27

Re: "set_user_time" for bots
 
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.

Bugsy 07-27-2010 23:52

Re: "set_user_time" for bots
 
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 );



portocala 07-28-2010 02:55

Re: "set_user_time" for bots
 
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.

Bugsy 07-28-2010 13:53

Re: "set_user_time" for bots
 
Maybe a macro like this? This will return the calculated time for bots and get_user_time() for real players. This would be used in conjunction with my code above.

PHP Code:

#define get_user_time2(%1) (is_user_bot(%1) ? float_round(get_gametime()-g_fGameTime[%1]):get_user_time(%1)) 


portocala 07-29-2010 15:09

Re: "set_user_time" for bots
 
No.

If I type status, then the bot's uptime is still the server uptime, not the real one.
I don't need to know the uptime, this is simple. I need to show a real or any uptime (different) from bot to bot - when I type status.

Ex:

Original:
Code:

#      name userid uniqueid frag time ping loss adr
# 1 "bot1" 1 BOT  6 07:58    0    0
# 2 "bot2" 2 BOT  25 07:58    0    0
# 3    "bot3" 3 BOT  17 07:58    0    0

07:58 is the bot's uptime and server too - you know, obviously...

I want to transform it in something like this:
Code:

#      name userid uniqueid frag time ping loss adr
# 1 "bot1" 1 BOT  6 02:01    0    0
# 2 "bot2" 2 BOT  25 03:21    0    0
# 3    "bot3" 3 BOT  17 07:21    0    0

Real, random... no matter!

Bugsy 07-29-2010 16:10

Re: "set_user_time" for bots
 
I get it, but why do you want to alter the time internally? Using the above macro will give you exactly how long an individual player or bot has been on the server.

portocala 07-29-2010 16:38

Re: "set_user_time" for bots
 
I don't need the time... It is for appearance.
The uptime appears in many places. If it won't be the same, then other players will think that those are real players (the score is also modified).

It is possible, but I don't know how... no need help with scripting, I'm doing well. I just need a tip.

Anyway, thank you so far!

portocala 08-01-2010 04:36

Re: "set_user_time" for bots
 
Nothing ?


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

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