Raised This Month: $23 Target: $400
 5% 

Setting maxspeed to certain ents.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
colby
Senior Member
Join Date: Jun 2005
Location: NC
Old 08-04-2006 , 17:21   Setting maxspeed to certain ents.
Reply With Quote #1

No errors, but any reason why this doesn't work in game?

Code:
public something(id) {     new origin[3],ent     get_user_origin(id,origin)         while((ent = find_ent_by_class(-1,"Player")) != 0) {                 new ent_origin[3]         get_user_origin(ent,ent_origin)                 if(get_distance(origin,ent_origin) <= 200) {             set_user_maxspeed(ent,0.5)         }                 else {             set_user_maxspeed(ent,-1.0)         }     }     }
colby is offline
Send a message via AIM to colby
VEN
Veteran Member
Join Date: Jan 2005
Old 08-04-2006 , 17:53   Re: Setting maxspeed to certain ents.
Reply With Quote #2

maxspeed is in units. For example 250.0 is a default value for players. Set maxspeed to 1.0 to stop a player. maxspeed is reset on weapon change for players. Also it should be find_ent_by_class(ent,"player"))

Last edited by VEN; 08-04-2006 at 17:55.
VEN is offline
colby
Senior Member
Join Date: Jun 2005
Location: NC
Old 08-04-2006 , 17:59   Re: Setting maxspeed to certain ents.
Reply With Quote #3

1. I've tried 100.0, 200.0, 180.0, none of them work.
2. I believe the default is 320.0.
3. I have this particular function loop every 0.1 seconds.
4. Having a lower-case "p" in "player" will cause the server to crash as soon as the function is called.
colby is offline
Send a message via AIM to colby
VEN
Veteran Member
Join Date: Jan 2005
Old 08-04-2006 , 18:08   Re: Setting maxspeed to certain ents.
Reply With Quote #4

Quote:
I've tried 100.0, 200.0, 180.0, none of them work
Your problem isn't maxspeed related.

Quote:
I believe the default is 320.0
That's incorrect. Very many people think it's 320.0, but you should understand that entity max speed have nothing to do with the sv_maxspeed CVAR.

Quote:
Having a lower-case "p" in "player" will cause the server to crash as soon as the function is called
Because you have infinite loop. Notice the text which i marked with the red color for you.

find_ent_by_class(ent,"player"))
VEN is offline
colby
Senior Member
Join Date: Jun 2005
Location: NC
Old 08-04-2006 , 19:33   Re: Setting maxspeed to certain ents.
Reply With Quote #5

The server doesn't crash anymore, but it still doesn't work. I don't know if the default runspeed varies for different mods, but for TS, it is most certainly 320.

Here is what I have:
Code:
public something(id) {     new origin[3],ent     get_user_origin(id,origin)     set_user_maxspeed(id,200.0)         while((ent = find_ent_by_class(ent,"player")) != 0 && ent != id) {                 new ent_origin[3]         get_user_origin(ent,ent_origin)                 if(get_distance(origin,ent_origin) <= 200) {             set_user_maxspeed(ent,180.0)         }                 else {             set_user_maxspeed(ent,320.0)         }     } }
colby is offline
Send a message via AIM to colby
VEN
Veteran Member
Join Date: Jan 2005
Old 08-05-2006 , 02:37   Re: Setting maxspeed to certain ents.
Reply With Quote #6

You should say that it's for TS. Use ts_set_speed then.
VEN is offline
colby
Senior Member
Join Date: Jun 2005
Location: NC
Old 08-05-2006 , 03:11   Re: Setting maxspeed to certain ents.
Reply With Quote #7

I've tried ts_set_speed. It works, but it is very buggy, giving players other than the one it was set on extremely fast runspeed.

I've realized that ts_set_fakeslowmo works perfect when the player has a Slow Mo powerup. Since I can't create a TS entity, I'll just run through all ts_powerup's until I find one with EV_INT_body == 5 (Slow Mo submodel). Failing that, I'll just run through all ents until I find one that's model is powerup.mdl.

Thanks for the help.
colby is offline
Send a message via AIM to colby
Reply


Thread Tools
Display Modes

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 16:56.


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