Raised This Month: $ Target: $400
 0% 

freeze player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 06-19-2017 , 15:55   Re: freeze player
Reply With Quote #1

I made this with .inc file if you want:

1. Main plugin:

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define isFreezed(%1)            (is_user_alive(%1) && g_bIsFrozen[%1])

#if AMXX_VERSION_NUM < 183
#define MAX_PLAYERS 32
#endif

new bool:g_bIsFrozen[MAX_PLAYERS+1], g_iUserOldSpeed[MAX_PLAYERS+1], g_iUserSpeed[MAX_PLAYERS+1], Float:g_fPlayerViewAngles[MAX_PLAYERS+1][3]
const 
Ham:Ham_Player_ResetMaxSpeed =    Ham_Item_PreFrame

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_Player_ResetMaxSpeed"player""ham_Player_ResetMaxSpeed_Post"1)
}

public 
plugin_natives()
{
    
register_library("freeze.inc")
    
    
register_native("set_user_freeze""_set_user_freeze")
    
register_native("get_user_freeze""_get_user_freeze")
}

public 
_set_user_freeze()
{
    new 
id get_param(1)
    new 
bool:bIsForSet bool:get_param(2)
    new 
iType get_param(3)
    new 
iUserPev pev(idpev_flags)
    
    if(
bIsForSet)
    {
        if(!
g_bIsFrozen[id])
        {
            switch(
iType)
            {
                case 
1:
                {
                    
g_iUserOldSpeed[id] = get_cvar_num("sv_maxspeed")
                    
g_iUserSpeed[id] = 0
                
}
                case 
2:
                {
                    
pev(idpev_v_angleg_fPlayerViewAngles[id])
                    
set_pev(idpev_flagsiUserPev FL_FROZEN)
                }
            }
            
g_bIsFrozen[id] = true
        
}
    }
    else
    {
        if(
g_bIsFrozen[id])
        {
            
g_iUserSpeed[id] = g_iUserOldSpeed[id]
            
set_pev(idpev_flagsiUserPev & ~FL_FROZEN)
            
g_bIsFrozen[id] = false
        
}
    }
}

public 
_get_user_freeze()
{
    return 
g_bIsFrozen[get_param(1)]
}

public 
ham_Player_ResetMaxSpeed_Post(id)
{
    if(
isFreezed(id))
    {
        
fm_set_user_speed(idFloat:g_iUserSpeed[id])
    }
}

public 
client_PreThink(id)
{
    if(
isFreezed(id))
    {
        
set_pev(idpev_v_angleg_fPlayerViewAngles[id])
    }
}

fm_set_user_speed(idFloat:MSpeed = -1.0
{
    
engfunc(EngFunc_SetClientMaxspeedidMSpeed)
    
set_pev(idpev_maxspeedMSpeed)
    return 
1

2. Inc file:

Code:
#if defined _freeze_included
    #endinput
#endif

#define _freeze_included

/*
@id			player's index to freeze
@bIsForSet		true if you want to freeze, false if not
@iType			Totally freeze/only speed
*/
native set_user_freeze(id, bool:bIsForSet, iType = 1)

/*
@id			player's index to check freeze
*/
native get_user_freeze(id)
The .inc file must be named as freeze.inc

3. Example usage:

- If you want only to change the player's speed to 0
PHP Code:
set_user_freeze(playertrue1
If you want block everything ( view angle, speed, duck... ( not everything at all ) )

PHP Code:
set_user_freeze(playertrue2
If you want to unfreeze:

PHP Code:
set_user_freeze(playerfalse
I didn't test it yet.


EDIT: Maybe you shoud use the Natsheh's link.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 06-19-2017 at 16:00.
EFFx 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 23:08.


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