AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Setting maxspeed to certain ents. (https://forums.alliedmods.net/showthread.php?t=42643)

colby 08-04-2006 17:21

Setting maxspeed to certain ents.
 
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)         }     }     }

VEN 08-04-2006 17:53

Re: Setting maxspeed to certain ents.
 
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"))

colby 08-04-2006 17:59

Re: Setting maxspeed to certain ents.
 
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.

VEN 08-04-2006 18:08

Re: Setting maxspeed to certain ents.
 
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"))

colby 08-04-2006 19:33

Re: Setting maxspeed to certain ents.
 
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)         }     } }

VEN 08-05-2006 02:37

Re: Setting maxspeed to certain ents.
 
You should say that it's for TS. Use ts_set_speed then.

colby 08-05-2006 03:11

Re: Setting maxspeed to certain ents.
 
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.


All times are GMT -4. The time now is 17:13.

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