PDA

View Full Version : Setting speed


HexD
04-10-2008, 01:33
I have read just about every post that contained the word "maxspeed" in and I can't find anything that helps me. What I want to do is set_user_maxspeed for different classes at different levels, I've done this and I'm pretty sure the code is correct.
My problem is the speeds don't take effect on spawn with the other settings like health and armor the speed settings seem to kick in when a player connects to my server :S also it stops when you switch weapon. I read in other threads that is a common problem for setting speed, not to work until a player switches weapon and to counter that, set the speeds in CurWeapon. My problem with this is all my classes have different speeds at different levels and I'm stumped at how to get the speed to work from spawn and to stay active the whole round.

Please! Someone end my misery and tell me how to do it. Thanks

P.s Please don't shout at me about my code :D I know its bad, I've probably got some screwy ways of doing things that can be done alot simpler, but I'm learning and that's all this script is, one big personal tutor. Feel free to suggest easier ways if you think something is really bad.

MeRcyLeZZ
04-10-2008, 16:36
Yeah, maxspeed is changed every time you switch weapons, and also when CS's freezetime is over.

I suggest making a set_user_speed_according_to_class() function. Put all the speed stuff in there, then call it on those events.

Merko
04-10-2008, 18:00
Im not sure if this is a good way or not, but the way I do it is CurWeapon.

Example:
in plugin_init

register_event("CurWeapon", "event_CurWeapon", "be", "1=1")

and

public event_CurWeapon(id)
{
if (PlayerClass[id] == CLASS_NONE)
{
set_pev(id, pev_maxspeed, 250.0);
}
}


maybe not the best way but it works so far as id should.

HexD
04-10-2008, 19:15
Thanks for the reply, let me just clear this up in case anyone has the same problem and reads this. I set the speed for classes/players in CurWeapon?

*Edit*

Hey Merko, thanks for the reply. That's the way that makes most sense to me so its the one I'll use :)

P.s How's your project coming along?

Merko
04-11-2008, 12:27
Hehe, im not AMX scripting SO much, so it takes time. I'm really busy with alot of diffrent things really, but yeah, im getting there! :p

v3x
04-11-2008, 13:36
You could also add speed to the current speed:

new Float:curspeed = get_user_maxspeed(id);
set_user_maxspeed(id, curspeed + 25.0);

Although, I don't recommend it, as it may produce glitches/exploits. When I was using it like that, my speed would noticeably increase beyond the limit that I set it to.

I don't know why I posted this. Maybe for other people to learn off of :P