AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Freezing Problem (https://forums.alliedmods.net/showthread.php?t=188532)

Napoleon_be 06-27-2012 12:18

Freezing Problem
 
Hi everyone,

I'm trying to freeze all cts and reset the freeze after the countdown is over... But it doesn't freeze the players when the countdown is running. It only freezes them when the countdown stops...

PHP Code:

public Cmdround(id)
{
    if (
task_exists(TASKID))
        
remove_task(TASKID)
    
    
set_hudmessage(25500, -1.00.000.114.00.11.01)
    
show_hudmessage(0"[HideNseeK]")
    
    
Timer 10
    set_task
(1.0"Cmdcountdown"TASKID__"a"Timer)
    
    new 
players[32], count
    get_players
(playerscount"ae""CT")
    
    for(new 
icounti++) {
        
set_user_maxspeed(players[i], 0.1)
        
set_task(11.0"RemoveFreeze"players[i])
    }
    
set_task(2.0"StripWeapons"players[0])


PHP Code:

public RemoveFreeze(id) {
    if(
is_user_alive(id)) {
        
set_user_maxspeed(id, -1.0)
    }



Neeeeeeeeeel.- 06-27-2012 12:27

Re: Freezing Problem
 
You should set a var true if player is freezed and put set_user_maxspeed on 'Ham_Player_ResetMaxSpeed' because, for example in weapon change max speed changes to weapon's max speed so you should set max speed to -1.0 on every max speed change.

Napoleon_be 06-27-2012 12:30

Re: Freezing Problem
 
Quote:

Originally Posted by Neeeeeeeeeel.- (Post 1737312)
You should set a var true if player is freezed and put set_user_maxspeed on 'Ham_Player_ResetMaxSpeed' because, for example in weapon change max speed changes to weapon's max speed so you should set max speed to -1.0 on every max speed change.

Ham_Player_ResetMaxSpeed doesn't even exist at hamsandwich... I've checked it but couldn't find it.

Backstabnoob 06-27-2012 12:31

Re: Freezing Problem
 
To reset one's speed you use 0.0 instead of -1.0 on them, at least that's what funcwiki says.


Ham_Player_ResetMaxSpeed is not implemented. Use Ham_Item_PreFrame instead. What everyone uses is
Code:
const Ham: Ham_Player_ResetMaxSpeed = Ham_Item_PreFrame

Neeeeeeeeeel.- 06-27-2012 12:32

Re: Freezing Problem
 
Oh i'm forget that part :P
PHP Code:

// Hack to be able to use Ham_Player_ResetMaxSpeed (by joaquimandrade)
new Ham:Ham_Player_ResetMaxSpeed Ham_Item_PreFrame 

Quote:

Originally Posted by Backstabnoob (Post 1737315)
To reset one's speed you use 0.0 instead of -1.0 on them, at least that's what funcwiki says.

He'll have the same problem...

Napoleon_be 06-27-2012 12:32

Re: Freezing Problem
 
Quote:

Originally Posted by Backstabnoob (Post 1737315)
To reset one's speed you use 0.0 instead of -1.0 on them, at least that's what funcwiki says.

That couldn't be the problem.... I'm freezing at the end of countdown.. And i'm able to move while it's countdown, it should be the other way.

Backstabnoob 06-27-2012 12:37

Re: Freezing Problem
 
Because you are setting the speed only once. You need to hook Ham_Item_PreFrame and set it there as well, because for example, if you strip weapons (like you do in your code for the first player found), it resets his speed as well so he can move freely.

Also you should set the task only once and loop in it again instead of setting a different task for each player.

ConnorMcLeod 06-27-2012 13:13

Re: Freezing Problem
 
Also set maxspeed to 1.0 and not 0.1 when you want to block.

Napoleon_be 06-27-2012 14:10

Re: Freezing Problem
 
Quote:

Originally Posted by ConnorMcLeod (Post 1737353)
Also set maxspeed to 1.0 and not 0.1 when you want to block.

http://www.amxmodx.org/funcwiki.php?go=func&id=123

Code:

If you set a user's maxspeed to 0.0 they will be able to run normal  speed. Set it to 0.1 if you wish to stop them from moving completely.

Napoleon_be 06-27-2012 14:18

Re: Freezing Problem
 
Can someone fix this for me? Cause i've never worked with Ham_Item_Preframe

Full code:
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <fun>
#include <cstrike>
#include <colorchat>

#define PLUGIN "HideNseeK"
#define VERSION "1.0.0"
#define AUTHOR "NapoleoN#"

#define TASKID 1996

new Timer
new Rounds
new maxplayers
new pArmor

new bool:plrSolid[33]
new 
bool:plrRestore[33]
new 
plrTeam[33]


new const 
WEAPONS[] = {
    
CSW_HEGRENADE,
    
CSW_FLASHBANG,
    
CSW_SMOKEGRENADE
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// ham
    
    // events
    
register_logevent("Cmdround"2"1=Round_Start")
    
register_logevent("CtWinEvent"6"3=CTs_Win""3=All_Hostages_Rescued")
    
register_logevent("TsWinEvent" 6"3=Terrorists_Win""3=Target_Bombed")
    
    
// fakemeta
    
register_forward(FM_CmdStart"CmdStart")
    
register_forward(FM_PlayerPreThink"preThink")
    
register_forward(FM_PlayerPostThink"postThink")
    
register_forward(FM_AddToFullPack"addToFullPack"1)
    
    
// pcvars
    
pArmor register_cvar("hns_armor""100")
    
    
maxplayers get_maxplayers()
}

public 
CtWinEvent(id) {
    
Rounds 0
    
new players[32], count
    get_players
(playerscount"e""CT")
    
    for(new 
icounti++) {
        
cs_set_user_team(players[i], CS_TEAM_T)
        
ColorChat(players[i], GREEN"[HNS]^1 Changing teams...")
    }
}

public 
TsWinEvent(id) {
    if(
Rounds == 3) {
        
ColorChat(0GREEN"[HNS]^1 The ct's can now use nubslash because of loosing 3 rounds...")
        } else {
        
Rounds++
    }
}

public 
plugin_cfg() {
    
set_cvar_num("sv_freezetime"0)
}

public 
Cmdround(id)
{
    if (
task_exists(TASKID))
        
remove_task(TASKID)
    
    
set_hudmessage(25500, -1.00.000.114.00.11.01)
    
show_hudmessage(0"[HideNseeK]")
    
    
Timer 10
    set_task
(1.0"Cmdcountdown"TASKID__"a"Timer)
    
    new 
players[32], count
    get_players
(playerscount"ae""CT")
    
    for(new 
icounti++) {
        
set_user_maxspeed(players[i], -1.0)
        
set_task(11.0"RemoveFreeze"players[i])
    }
    
    
get_players(playerscount"ae""TERRORIST")
    
    for(new 
icounti++) {
        
strip_user_weapons(players[i])
    }
}

public 
Cmdcountdown(id)
{
    
Timer--
    
    if (
Timer 0)
    {
        
set_hudmessage(255255255, -1.00.0300.11.00.10.12)
        
show_hudmessage(0"%i"Timer)
    }
    else
    {
        
set_hudmessage(255255255, -1.00.0300.13.00.11.03)
        
show_hudmessage(0"Ready or not, here we come!")
        new 
players[32], count
        get_players
(playerscount"ae""CT")
        
        for(new 
icounti++) {
            
set_task(2.0"StripWeapons"players[i])
        }
    }
}

public 
RemoveFreeze(id) {
    if(
is_user_alive(id)) {
        
set_user_maxspeed(id0.1)
    }
}

public 
StripWeapons(id) {
    if(
is_user_alive(id)) {
        
strip_user_weapons(id)
        
give_item(id"weapon_knife")
        
set_user_armor(idget_pcvar_num(pArmor))    
        
        if(
cs_get_user_team(id) == CS_TEAM_T) {
            if(
random(100) > 90) {
                
give_item(id"weapon_hegrenade")
                
ColorChat(idGREEN"[HNS]^1 You receive a^3 HE Grenade^4 (10 percent chance)")
            }
            if(
random(100) > 75) {
                
give_item(id"weapon_smokegrenade")
                
ColorChat(idGREEN"[HNS]^1 You receive a^3 Smoke Grenade^4 (25 percent chance)")
            }
            if(
random(100) > 50) {
                
give_item(id"weapon_flashbang")
                
ColorChat(idGREEN"[HNS]^1 You receive a^3 FlashBang^4 (50 percent chance)")
            }
        }
    }
}

public 
CmdStart(idHandle)
{
    static 
button
    button 
get_uc(HandleUC_Buttons)
    
    if (
button IN_ATTACK && cs_get_user_team(id) == CS_TEAM_CT && Rounds 3) {
        
button &= ~IN_ATTACK
    
}
    
    for(new 
isizeof(WEAPONS); i++) {
        if(
button IN_ATTACK && cs_get_user_team(id) == CS_TEAM_CT && get_user_weapon(id) != WEAPONS[i]) {
            
button &= ~IN_ATTACK
        
}
    }
    
set_uc(HandleUC_Buttonsbutton)
}

public 
addToFullPack(eseenthosthostflagsplayerpSet)
{
    if(
player)
    {
        if(
plrSolid[host] && plrSolid[ent] && plrTeam[host] == plrTeam[ent])
        {
            
set_es(esES_SolidSOLID_NOT)
            
set_es(esES_RenderModekRenderTransAlpha)
            
set_es(esES_RenderAmt255)
        }
    }
}

FirstThink()
{
    for(new 
1<= maxplayersi++)
    {
        if(!
is_user_alive(i))
        {
            
plrSolid[i] = false
            
continue
        }
        
plrTeam[i] = get_user_team(i)
        
plrSolid[i] = pev(ipev_solid) == SOLID_SLIDEBOX true false
    
}
}

public 
preThink(id)
{
    static 
iLastThink

    
if(LastThink id)
    {
        
FirstThink()
    }
    
LastThink id


    
if(!plrSolid[id]) { 
        return
    }

    for(
1<= maxplayersi++)
    {
        if(!
plrSolid[i] || id == i) {
            continue
        }
    
        if(
plrTeam[i] == plrTeam[id])
        {
            
set_pev(ipev_solidSOLID_NOT)
            
plrRestore[i] = true
        
}
    }
}

public 
postThink(id)
{
    static 
i

    
for(1<= maxplayersi++)
    {
        if(
plrRestore[i])
        {
            
set_pev(ipev_solidSOLID_SLIDEBOX)
            
plrRestore[i] = false
        
}
    }


I've been fucking around with the code now for a bit to get it fixed, but nothing worked.


All times are GMT -4. The time now is 06:07.

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