Raised This Month: $12 Target: $400
 3% 

Resource Consumption, TraceLine and dmgtime


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 10-05-2008 , 13:52   Resource Consumption, TraceLine and dmgtime
Reply With Quote #1

3 questions:

1) I'm currently making a plugin that uses about 4 Forwards, and I know that doing that consumes lots of resources, so I just wondered - How can I make it use less CPU? Maybe unregistering it somewhere?
And what if I don't do much in the forward function. Will it still consume alot of resources?
For example:
Code:
// will this consume more resources
public client_prethink(id)
{
      set_pev(id, pev_maxspeed, 500.0);
      set_pev(id, pev_rendermode, kRenderNormal);
      set_pev(id, pev_health, 250.0);
      new origin[3];
      get_user_origin(id, origin);
      origin[2] += 100.0;
      set_pev(id, pev_origin, origin);

      return FMRES_HANDLED;
}


// than this?
public client_prethink(id)
{
      set_pev(id, pev_health, 250.0);

      return FMRES_HANDLED;
}
2) If I hook TraceLine, and I want to do something to the player that is at the end of the trace before he gets hit, must I use set_tr2(trace, TR_pHit, hit) after I've done what I wanted? Or just do what I want and return the function normally and it would hit the player automatically?


3) If I set pev_dmgtime to the value returned by get_gametime() (or less), will it make the grenade explode?

Thanks for all helpers, +karma will be granted.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
powwoww
BANNED
Join Date: Oct 2008
Old 10-05-2008 , 14:12   Re: Resource Consumption, TraceLine and dmgtime
Reply With Quote #2

Most effects will last until sth happened
like maxspeed,health,godmode,noclip , and so on
the value will not be reset until next round or spawn..
so u cn do them in above functions...

I'm sorry but i'm not using fm...just up...

Last edited by powwoww; 10-05-2008 at 14:18.
powwoww is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 10-05-2008 , 14:57   Re: Resource Consumption, TraceLine and dmgtime
Reply With Quote #3

Ok, thanks.
Now wait for answers for the two other questions...

+karma.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 10-05-2008 , 20:57   Re: Resource Consumption, TraceLine and dmgtime
Reply With Quote #4

Quote:
Originally Posted by dor123
I'm currently making a plugin that uses about 4 Forwards, and I know that doing that consumes lots of resources, so I just wondered - How can I make it use less CPU?
It depends mostly on how often the forwards get called and what you do inside of them. For instance, doing a lot of stuff on a round start event won't usually hurt, but if instead you do it on a player prethink event you'll notice it takes up more CPU as it gets executed a lot.

Quote:
Originally Posted by dor123
If I hook TraceLine, and I want to do something to the player that is at the end of the trace before he gets hit, must I use set_tr2(trace, TR_pHit, hit) after I've done what I wanted? Or just do what I want and return the function normally and it would hit the player automatically?
If you're doing a "Post" hook the result of the traceline won't be affected unless you change it manually. If you use "Pre" hook it might get affected if you e.g. change the player's origin. But it won't be altered for the sole fact of hooking the forward.

Quote:
Originally Posted by dor123
If I set pev_dmgtime to the value returned by get_gametime() (or less), will it make the grenade explode?
Yeah. It will explode as soon as it "thinks" again.
__________________
MeRcyLeZZ is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 10-06-2008 , 00:56   Re: Resource Consumption, TraceLine and dmgtime
Reply With Quote #5

1) I use both (FM_PlayerPreThink, "blabla") and (FM_PlayerPreThink, "post", 1). Also I use TraceLine and SetModel.
Is it that bad? :/
I don't do much at the TraceLine and at the SetModel. Only pretty minor changes...

2) Thanks, I will test it to be 100% sure.

3) Thanks alot!

+karma.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 10-06-2008 , 23:46   Re: Resource Consumption, TraceLine and dmgtime
Reply With Quote #6

Quote:
Originally Posted by dor123
1) I use both (FM_PlayerPreThink, "blabla") and (FM_PlayerPreThink, "post", 1). Also I use TraceLine and SetModel.
Is it that bad? :/
I don't do much at the TraceLine and at the SetModel. Only pretty minor changes...
It shouldn't be too bad, unless your coding is real terrible or something...
If you still wanna make sure your getting the best performance out of it, post your code and we'll check it out.
__________________
MeRcyLeZZ is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 10-07-2008 , 00:57   Re: Resource Consumption, TraceLine and dmgtime
Reply With Quote #7

Ok, you're right, it's not bad at all.
Runs smooth. Thanks.

But... now I have coding problems.. plugin doesn't work 100% well D:
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores 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 13:13.


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