AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Setting a player's speed..is a nightmare. (https://forums.alliedmods.net/showthread.php?t=246121)

PreDominance 08-12-2014 05:55

Setting a player's speed..is a nightmare.
 
Greetings,

I'm having an insanely difficult time with setting my speed. Yes I've read the forums and I've gone through about 20 threads, trying different crap and I can't find what I'm doing wrong.

Relevant code:

nwc.sma
PHP Code:

    RegisterHam(Ham_CS_Player_ResetMaxSpeed"player""event_resetMaxSpeed"true

events.inl
PHP Code:

public event_resetMaxSpeed(id
{
    if(
is_user_alive(id) && P_ATTRIB[id][P_ATTRIB_SPEED] != 0)
    {
        new 
float:maxSpeed get_user_maxspeed(id);
        if (
maxSpeed != 1.0
        {
            
client_print_color(00"Max speed of %f."maxSpeed);
            
set_pev(idpev_maxspeedmaxSpeed*4.0);
            
//have tried set_user_maxspeed, using constants, using...everything
        
}
    } 


^ yes, the debug chat prints.

race_undead_scourge.inl
PHP Code:

public race_0_spawn(id)
{
    new 
speedLevel P_DATA[id][P_SKILL_LEVEL_B] - 1;
    new 
gravLevel P_DATA[id][P_SKILL_LEVEL_C] - 1;
    if (
speedLevel 0) {
        new 
float:fSpeed RACE_SKILL_VALUE[RACE_UNDEAD_SCOURGE][1][speedLevel];
        
P_ATTRIB[id][P_ATTRIB_SPEED] = fSpeed;
        
set_user_maxspeed(idfSpeed);
        
client_print_color(idid"^x03[^x04%s^x03]^x01 Your speed has been set."RACE_SKILL_NAMES[RACE_UNDEAD_SCOURGE][1]);
    }
    if (
gravLevel 0) {
        new 
float:fGrav RACE_SKILL_VALUE[RACE_UNDEAD_SCOURGE][2][gravLevel];
        
P_ATTRIB[id][P_ATTRIB_GRAVITY] = fGrav;
        
set_user_gravity(idfGrav);
        
client_print_color(idid"^x03[^x04%s^x03]^x01 Your gravity has been set."RACE_SKILL_NAMES[RACE_UNDEAD_SCOURGE][2]);
    }


^
gravity works just fine.

events.inl
PHP Code:

    if (PB_DATA[id][PB_HAS_SPAWN]) {
        new 
spawnFunc[25];
        
format(spawnFunccharsmax(spawnFunc), "race_%i_spawn"P_DATA[id][P_RACE]);
        if (
callfunc_begin(spawnFunc"") == 1)
        {
            
callfunc_push_int(id);
            
callfunc_end();
        } else {
            
nwc_log(LOGTYPE_ERROR"ERROR: COULD NOT EXECUTE SPAWN FUNCTION");
        }
    } 

Have tried both pre and post-hook variants. Have tried hooking curweapon. Please, someone save me..

Flick3rR 08-12-2014 06:10

Re: Setting a player's speed..is a nightmare.
 
What are you actually trying to do? To set some different maxspeed to yourself? If so, Ham_CS_Player_ResetMaxSpeed should work fine, but in new versions of Amxmodx. So the working (but not the best) way for me is hooking CurWeapon using set_user_maxspeed() from fun.inc. Will work, but there are better ways which I can't explain in details.

PreDominance 08-12-2014 06:14

Re: Setting a player's speed..is a nightmare.
 
I literally have the absolute newest dev version of AMXMod. Hooking curweapon does not solve the problem.

*Edit
Aaaaaand Cs1.6 is stupid. Nowhere does anyone say anything about sv_maxspeed >:C

[/thread]

Nextra 08-12-2014 08:48

Re: Setting a player's speed..is a nightmare.
 
The issue is not just sv_maxspeed by the way. The client will not attempt to go over a certain speed aswell unless the appropriate cvars are set, those are cl_forwardspeed, cl_sidespeed and cl_backspeed.

PreDominance 08-12-2014 14:21

Re: Setting a player's speed..is a nightmare.
 
Yeah I'm figuring this all out as I go.

So how am I supposed to do this? If I don't set sv_maxspeed higher than 400, nothing will work.
If I set sv_maxspeed higher than 400, but do not set cl_*speed, nothing will work.
If I set cl_*speed, apparently that's slowhacking?!?
I can't hook cl_*speed because they're client-side commands.

What's the correct way to do this?

GuskiS 08-12-2014 14:46

Re: Setting a player's speed..is a nightmare.
 
I believe you can query that cvar, and then inform player to set it higher :)
query_client_cvar.

PreDominance 08-12-2014 14:51

Re: Setting a player's speed..is a nightmare.
 
But when do I call this? I don't want to inform them to set it higher, this would be for a warcraft-style server that needs to have some players running at SPEED_X, some at SPEED_Y, and the rest at SPEED_Z.

I can do a set_task that loops through all players and repeats indefinitely every 3 seconds, I can hook client_think (I really don't want to..)...where's the event for the check?

bibu 08-12-2014 15:23

Re: Setting a player's speed..is a nightmare.
 
If you do use amx super, disable it or use the nonspeed version of it.

PreDominance 08-12-2014 15:25

Re: Setting a player's speed..is a nightmare.
 
I'm not using amx super, I'm making a new warcraft mod from scratch. The only plugins running on my server are the base plugins, logevents, and my warcraft.

Nextra 08-12-2014 20:19

Re: Setting a player's speed..is a nightmare.
 
You can't circumvent it. Make sure that the players can't get that fast.


All times are GMT -4. The time now is 12:56.

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