Raised This Month: $51 Target: $400
 12% 

API Scripting Help [TUT][ZP 5.0] Creating a plugin that will affects player speed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Excalibur.007
Veteran Member
Join Date: Sep 2009
Location: Singapore
Old 12-09-2011 , 22:26   [TUT][ZP 5.0] Creating a plugin that will affects player speed
Reply With Quote #1

If you're creating a plugin that will affects a player speed, then never use this method to set's a player speed:
  1. PreThink
  2. CurWeapon
  3. set_task

Instead, you should use
PHP Code:
#include <cs_maxspeed_api> 
that is used by Zombie Plague.

Examples of usage:
PHP Code:
#include <amxmodx>
#include <cs_maxspeed_api>

new bool:IsActivated[33]

public 
plugin_init()
{
    
register_plugin("Test""1.0.0""Nobody")
    
    
register_clcmd("say /speedhack""toggle_speedhack")
}

public 
toggle_speedhack(id)
{
    if(
is_user_alive(id))
    {
        if(
IsActivated[id])
        {
            
cs_reset_player_maxspeed(id)// RESETS PLAYER MAXSPEED
            
            
IsActivated[id] = false
        
}
        else
        {
            
cs_set_player_maxspeed(id5000.0// ADD 5000.0 TO CURRENT SPEED
            // OR
            
cs_set_player_maxspeed(id5000.0true// MULTIPLIY 5000.0 TO CURRENT SPEED
            
            
IsActivated[id] = true
        
}
    }

How hard can that be? Three simple steps.
  1. Include cs_maxspeed_api
  2. Set player's maxspeed
  3. Reset player's maxspeed

Notes
  • This method is using hamsandwich method.

If you need examples, [ZP 5.0] Sprinting

Last edited by Excalibur.007; 12-09-2011 at 22:29.
Excalibur.007 is offline
JoKeR LauGh
Veteran Member
Join Date: May 2011
Location: Malaysia
Old 12-10-2011 , 09:38   Re: [TUT][ZP 5.0] Creating a plugin that will affects player speed
Reply With Quote #2

after set the player max speed , we need to reset it back manually on next round or it will do it it self ?
__________________
Quote:
Originally Posted by addons_zz View Post
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.
JoKeR LauGh is offline
Excalibur.007
Veteran Member
Join Date: Sep 2009
Location: Singapore
Old 12-11-2011 , 04:43   Re: [TUT][ZP 5.0] Creating a plugin that will affects player speed
Reply With Quote #3

As long cs_reset_player_maxspeed(id) gets called. It will reset the speed. Then the speed will go according the human class/zombie class speed.
Excalibur.007 is offline
Snaker beatter
Veteran Member
Join Date: Sep 2011
Location: Manila, Philippines
Old 12-11-2011 , 10:59   Re: [TUT][ZP 5.0] Creating a plugin that will affects player speed
Reply With Quote #4

You mean this tutorial allows you to set maxspeed without registering/using custom function (like PreThink)?

If yes this is use full
__________________
Snaker beatter is offline
JoKeR LauGh
Veteran Member
Join Date: May 2011
Location: Malaysia
Old 12-11-2011 , 12:49   Re: [TUT][ZP 5.0] Creating a plugin that will affects player speed
Reply With Quote #5

Code:
set_user_maxspeed( index , Float:speed)

from the fun module is bugged?
__________________
Quote:
Originally Posted by addons_zz View Post
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.
JoKeR LauGh is offline
Excalibur.007
Veteran Member
Join Date: Sep 2009
Location: Singapore
Old 12-11-2011 , 20:31   Re: [TUT][ZP 5.0] Creating a plugin that will affects player speed
Reply With Quote #6

Quote:
Originally Posted by JoKeR LauGh View Post
Code:
set_user_maxspeed( index , Float:speed)

from the fun module is bugged?
It's not bugged. I just think this is the most simple yet better way to do it. Rather than making the plugin complicated and having problems with resetting speed.

Advantages of this is it reduces lines(which makes the plugin more readable), simple and a better way to do it.

Last edited by Excalibur.007; 12-11-2011 at 20:32.
Excalibur.007 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 08:19.


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