AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Zombie Plague Mod (https://forums.alliedmods.net/forumdisplay.php?f=126)
-   -   API Scripting Help [TUT][ZP 5.0] Creating a plugin that will affects player speed (https://forums.alliedmods.net/showthread.php?t=173743)

Excalibur.007 12-09-2011 22:26

[TUT][ZP 5.0] Creating a plugin that will affects player speed
 
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

JoKeR LauGh 12-10-2011 09:38

Re: [TUT][ZP 5.0] Creating a plugin that will affects player speed
 
after set the player max speed , we need to reset it back manually on next round or it will do it it self ?

Excalibur.007 12-11-2011 04:43

Re: [TUT][ZP 5.0] Creating a plugin that will affects player speed
 
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.

Snaker beatter 12-11-2011 10:59

Re: [TUT][ZP 5.0] Creating a plugin that will affects player speed
 
You mean this tutorial allows you to set maxspeed without registering/using custom function (like PreThink)?

If yes this is use full :mrgreen:

JoKeR LauGh 12-11-2011 12:49

Re: [TUT][ZP 5.0] Creating a plugin that will affects player speed
 
Code:
set_user_maxspeed( index , Float:speed)

from the fun module is bugged?

Excalibur.007 12-11-2011 20:31

Re: [TUT][ZP 5.0] Creating a plugin that will affects player speed
 
Quote:

Originally Posted by JoKeR LauGh (Post 1611431)
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.


All times are GMT -4. The time now is 16:38.

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