AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   maxspeed reset? (https://forums.alliedmods.net/showthread.php?t=206474)

n0br41ner 01-22-2013 19:13

maxspeed reset?
 
I am trying to freeze the whole ct team for 5 seconds. I wrote this:

PHP Code:

#include < amxmodx >
#include < cstrike >
#include < fun >

new bool:g_bFreeze;
new 
g_msgShakeScreen;

public 
plugin_init( ) {
    
register_event"CurWeapon" ,     "Event_WeaponSwitch" ,     "be" ,     "1=1" );
    
    
register_clcmd"say /test""Freeze" );
    
    
g_msgShakeScreen get_user_msgid"ScreenShake" );
}

// called when player switch weapons (because maxspeed changes with every gun
public Event_WeaponSwitchiPlayerID ) {
    new 
CsTeams:iTeam cs_get_user_teamiPlayerID );
    
    if( 
g_bFreeze && iTeam == CS_TEAM_CT ) {
        
set_user_maxspeediPlayerID0.1 );
        
        return 
PLUGIN_HANDLED;
    }
        
    return 
PLUGIN_CONTINUE;
}

public 
Freeze( ) {
    static 
iPlayers32 ], iNumiTempid;
    
get_playersiPlayersiNum"ae""CT" );
    
    
g_bFreeze true;
    
    for( new 
iLoop 0iLoop iNumiLoop++ ) {
        
iTempid iPlayersiLoop ];
        
        
// shake screen when become frozen
        
message_beginMSG_ONEg_msgShakeScreen, { 00}, iTempid );
        
write_short255 << 14 );
        
write_short10 << 14 );
        
write_short255 << 14 );
        
message_end( );
        
        
set_user_maxspeediTempid0.1 );
    }
    
    
// unfreeze after 5 seconds
    
set_task5.0"Unfreeze" );
}

public 
Unfreeze( ) {
    static 
iPlayers32 ], iNum;
    
get_playersiPlayersiNum"ae""CT" );
    
    for( new 
iLoop 0iLoop iNumiLoop++ ) {
        
g_bFreeze false;
        
ResetUserMaxSpeediPlayersiLoop ] );
    }
}

ResetUserMaxSpeediPlayerID ) {
    
// credits to connor?
    
new Float:fMaxSpeed;
    
    switch( 
get_user_weaponiPlayerID ) )
    {
        case 
CSW_SG550CSW_AWPCSW_G3SG1 :                 fMaxSpeed 210.0;
        case 
CSW_M249 :                                     fMaxSpeed 220.0;
        case 
CSW_AK47 :                                     fMaxSpeed 221.0;
        case 
CSW_M3CSW_M4A1 :                             fMaxSpeed 230.0;
        case 
CSW_SG552 :                                     fMaxSpeed 235.0;
        case 
CSW_XM1014CSW_AUGCSW_GALILCSW_FAMAS :     fMaxSpeed 240.0;
        case 
CSW_P90 :                                         fMaxSpeed 245.0;
        case 
CSW_SCOUT :                                     fMaxSpeed 260.0;
        default :                                             
fMaxSpeed 250.0;
    }
    
    
set_user_maxspeediPlayerIDfMaxSpeed );


I tested it and it works great.

BUT, when i implement the same idea into my mod (a big plugin), it doesn't seem to work. So what i am asking is when will the user speed be reset (or changed)? Maybe something is interfering with it.

Posting the whole code won't help, cause its 4000+ lines.

fysiks 01-22-2013 20:48

Re: maxspeed reset?
 
To freeze people, you should not use speed to do it. You should use pev_flags:

PHP Code:

set_pev(id,pev_flags,pev(id,pev_flags) | FL_FROZEN); // Freeze
set_pev(player,pev_flags,pev(player,pev_flags) & ~FL_FROZEN); // Unfreeze 


Quote:

Originally Posted by n0br41ner (Post 1878366)
Posting the whole code won't help, cause its 4000+ lines.

Why do people post these kinds of lies!?!?!?!

n0br41ner 01-22-2013 21:28

Re: maxspeed reset?
 
1 Attachment(s)
if i use set_pev then the player won't be able to fire and inflict damage. That's why i went with maxspeed.

Here you go, and i don't lie (look at the picture)

wickedd 01-23-2013 00:26

Re: maxspeed reset?
 
Quote:

Originally Posted by n0br41ner (Post 1878366)
Posting the whole code won't help

Quote:

Originally Posted by fysiks (Post 1878406)
Why do people post these kinds of lies!?!?!?!

@n0br41ner
I don't think fysiks was talking about how many lines your plugin is. I think he was talking about you saying " posting the whole code wouldn't help".

n0br41ner 01-23-2013 00:54

Re: maxspeed reset?
 
Oh okay.

Is thereany other way of freezing a player ad that he can still shoot and inflict damage?

ConnorMcLeod 01-23-2013 01:14

Re: maxspeed reset?
 
To block players, set speed to 1.0, not 0.1.
Hook Ham_CS_Player_ResetMaxspeed and block it when player is blocked.
To reset speed just set the variable 'block[ player_index ]' to false and call Ham_CS_Player_ResetMaxspeed.

Don't bother with CurWeapon !!

n0br41ner 01-23-2013 01:19

Re: maxspeed reset?
 
Okay great and thanks.
I will try it when i get back home.

n0br41ner 01-23-2013 13:26

Re: maxspeed reset?
 
It's not working i guess, and i am pretty sure i made something wrong.

Here is what i wrote:
PHP Code:

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

new bool:g_bFreeze;
new 
g_msgShakeScreen;

public 
plugin_init( ) {
    
// register_event( "CurWeapon" ,     "Event_WeaponSwitch" ,     "be" ,     "1=1" );
    
RegisterHamHam_CS_Player_ResetMaxSpeed,    "player",    "Reset",    false );
    
    
register_clcmd"say /test""Freeze" );
    
    
g_msgShakeScreen get_user_msgid"ScreenShake" );
}

public 
Resetid ) {
    new 
CsTeams:iTeam cs_get_user_teamid );
    
    if( 
g_bFreeze && iTeam == CS_TEAM_CT ) {
        return 
HAM_SUPERCEDE;
    }
    
    return 
HAM_IGNORED;
}
/*
// called when player switch weapons (because maxspeed changes with every gun
public Event_WeaponSwitch( iPlayerID ) {
    new CsTeams:iTeam = cs_get_user_team( iPlayerID );
    
    if( g_bFreeze && iTeam == CS_TEAM_CT ) {
        set_user_maxspeed( iPlayerID, 0.1 );
        
        return PLUGIN_HANDLED;
    }
        
    return PLUGIN_CONTINUE;
}
*/
public Freeze( ) {
    static 
iPlayers32 ], iNumiTempid;
    
get_playersiPlayersiNum"ae""CT" );
    
    
g_bFreeze true;
    
    for( new 
iLoop 0iLoop iNumiLoop++ ) {
        
iTempid iPlayersiLoop ];
        
        
// shake screen when become frozen
        
message_beginMSG_ONEg_msgShakeScreen, { 00}, iTempid );
        
write_short255 << 14 );
        
write_short10 << 14 );
        
write_short255 << 14 );
        
message_end( );
        
        
set_user_maxspeediTempid1.0 );
    }
    
    
// unfreeze after 5 seconds
    
set_task5.0"Unfreeze" );
}

public 
Unfreeze( ) {
    static 
iPlayers32 ], iNum;
    
get_playersiPlayersiNum"ae""CT" );
    
    
g_bFreeze false;
    
    for( new 
iLoop 0iLoop iNumiLoop++ ) {
        
ExecuteHamBHam_CS_Player_ResetMaxSpeediPlayersiLoop ] );
    }
}
/*
ResetUserMaxSpeed( iPlayerID ) {
    // credits to connor?
    new Float:fMaxSpeed;
    
    switch( get_user_weapon( iPlayerID ) )
    {
        case CSW_SG550, CSW_AWP, CSW_G3SG1 :                 fMaxSpeed = 210.0;
        case CSW_M249 :                                     fMaxSpeed = 220.0;
        case CSW_AK47 :                                     fMaxSpeed = 221.0;
        case CSW_M3, CSW_M4A1 :                             fMaxSpeed = 230.0;
        case CSW_SG552 :                                     fMaxSpeed = 235.0;
        case CSW_XM1014, CSW_AUG, CSW_GALIL, CSW_FAMAS :     fMaxSpeed = 240.0;
        case CSW_P90 :                                         fMaxSpeed = 245.0;
        case CSW_SCOUT :                                     fMaxSpeed = 260.0;
        default :                                             fMaxSpeed = 250.0;
    }
    
    set_user_maxspeed( iPlayerID, fMaxSpeed );
}*/ 

Appreciate any help.

n0br41ner 02-05-2013 17:42

Re: maxspeed reset?
 
bump: please help?

ConnorMcLeod 02-06-2013 00:39

Re: maxspeed reset?
 
PHP Code:

RegisterHamHam_CS_Player_ResetMaxSpeed,  "player""Reset"false ); 

>

PHP Code:

RegisterHam(Ham_CS_Player_ResetMaxSpeed"player""OnCBasePlayerResetMaxSpeed_P"true 



PHP Code:

public Resetid ) {
    new 
CsTeams:iTeam cs_get_user_teamid );
    
    if( 
g_bFreeze && iTeam == CS_TEAM_CT ) {
        return 
HAM_SUPERCEDE;
    }
    
    return 
HAM_IGNORED;


->

PHP Code:

public OnCBasePlayerResetMaxSpeed_Pid )
{
    if( 
g_bFreeze && cs_get_user_teamid ) == CS_TEAM_CT )
    {
        
set_pev(idpev_maxspeed1.0)
    }




All times are GMT -4. The time now is 20:39.

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