Raised This Month: $ Target: $400
 0% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PreDominance
Member
Join Date: Jul 2014
Old 08-12-2014 , 05:55   Setting a player's speed..is a nightmare.
Reply With Quote #1

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..

Last edited by PreDominance; 08-12-2014 at 05:59.
PreDominance is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 08-12-2014 , 06:10   Re: Setting a player's speed..is a nightmare.
Reply With Quote #2

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.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
PreDominance
Member
Join Date: Jul 2014
Old 08-12-2014 , 06:14   Re: Setting a player's speed..is a nightmare.
Reply With Quote #3

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]

Last edited by PreDominance; 08-12-2014 at 06:25.
PreDominance is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 08-12-2014 , 08:48   Re: Setting a player's speed..is a nightmare.
Reply With Quote #4

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.
__________________
In Flames we trust!
Nextra is offline
PreDominance
Member
Join Date: Jul 2014
Old 08-12-2014 , 14:21   Re: Setting a player's speed..is a nightmare.
Reply With Quote #5

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?
PreDominance is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 08-12-2014 , 14:46   Re: Setting a player's speed..is a nightmare.
Reply With Quote #6

I believe you can query that cvar, and then inform player to set it higher
query_client_cvar.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-13-2014 , 04:13   Re: Setting a player's speed..is a nightmare.
Reply With Quote #7

Quote:
Originally Posted by GuskiS View Post
I believe you can query that cvar, and then inform player to set it higher
query_client_cvar.
I tested some time ago, and query_client_cvar was not working. And yes, I'm using last cs 1.6 version.
__________________

Last edited by HamletEagle; 08-13-2014 at 04:13.
HamletEagle is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 08-13-2014 , 11:15   Re: Setting a player's speed..is a nightmare.
Reply With Quote #8

Quote:
Originally Posted by HamletEagle View Post
I tested some time ago, and query_client_cvar was not working. And yes, I'm using last cs 1.6 version.
With cl_speed cvars or at all?
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 08-13-2014 , 16:11   Re: Setting a player's speed..is a nightmare.
Reply With Quote #9

Quote:
Originally Posted by HamletEagle View Post
I tested some time ago, and query_client_cvar was not working. And yes, I'm using last cs 1.6 version.
Works for me
__________________
Jhob94 is offline
PreDominance
Member
Join Date: Jul 2014
Old 08-12-2014 , 14:51   Re: Setting a player's speed..is a nightmare.
Reply With Quote #10

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?

Last edited by PreDominance; 08-12-2014 at 14:52.
PreDominance 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 12:56.


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