AlliedModders

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

One 03-02-2010 19:09

set_user_maxspeed
 
hi,

i tried to define 2 teams.
team catcher & team fleer.
every round willbe start a countdown and the catchers are while the countdown freeze.( should be freeze )
the problem : users can change the weapon to run.i tried to set the maxspeed @ curweapon but happend nothing.

here the full code. i hope anyone can say me why it's so

PHP Code:

public plugin_init() 
{
    
register_plugin"Hide 'n' Seek""0.0.1""One" );
    
register_logevent("startround",2,"0=World triggered","1=Round_Start")
    
g_MaxPlayers get_maxplayers()
    
register_event("CurWeapon""ev_CheckWeapon""be""1=1")
}

        for(
id 1id <= g_MaxPlayersid++)
        {
            if(
is_user_connected(id) && cs_get_user_team(id) & CS_TEAM_T)
            {
                
g_Player_is_catcher[id] = false
                set_user_rendering
(id)
            }
            if(
is_user_connected(id) && cs_get_user_team(id) & CS_TEAM_CT)
            {
                
g_Player_is_catcher[id] = true
                set_user_rendering
(id,kRenderFxGlowShell,255,0,0,kRenderNormal,40)
            }
        }
            
    }
   
}
public 
do_fade(id)
{
    
set_task(1.0,"counter",id""0"b")
}
public 
counter(id)
{
    if(
g_counter <= 30)
    {
        
g_counter++
        
client_print(0,print_chat,"%d counter",g_counter)
        for(
id 1id <= g_MaxPlayersid++)
        {
            if(
g_Player_is_catcher[id] && is_user_alive(id))
            {
                
set_user_maxspeed(id,0.1)
                
set_user_gravity(id,10.0)
            }
            else if(!
g_Player_is_catcher[id] && is_user_alive(id))
            {
                
set_user_gravity(id,0.5)
                
set_user_maxspeed(id,400.0)
            }
        }
    }
    else
    {
        
remove_task(id)
        
g_counter 0
        
for(id 1id <= g_MaxPlayersid++)
        {
            if(
g_Player_is_catcher[id] && is_user_alive(id))
            {
                
set_user_gravity(id,0.5)
                
set_user_maxspeed(id,400.0)
            }
            else if(!
g_Player_is_catcher[id] && is_user_alive(id))
            {
                
set_user_maxspeed(id,0.1)
                
set_user_gravity(id,10.0)
            }
        }
        
    }
}
public 
ev_CheckWeapon(id)
{
    if(
g_Player_is_catcher[id] && is_user_alive(id))
    {
        
set_user_maxspeed(id,400.0)
    }
    else if(!
g_Player_is_catcher[id] && is_user_alive(id))
    {
        
set_user_maxspeed(id,0.1)
    }



wrecked_ 03-02-2010 19:19

Re: set_user_maxspeed
 
PHP Code:

set_pevindexpev_maxspeed, -1.0 

?

Off-Topic: Shouldn't it be
PHP Code:

if( cs_get_user_teamid ) == CS_TEAM_CT )

// instead of

if( cs_get_user_teamid ) & CS_TEAM_CT 

or is it the same thing?

One 03-02-2010 19:22

Re: set_user_maxspeed
 
Fixed :D

both are the same ( the same function )

added new bool.

for other ppl. who maybe will search for the same problem :D

PHP Code:

new bool:g_Player_is_freeze[33]

for(
id 1id <= g_MaxPlayersid++)
        {
            if(
g_Player_is_catcher[id] && is_user_alive(id))
            {
                
set_user_maxspeed(id,0.1)
                
g_Player_is_freeze[id] = true
                set_user_gravity
(id,10.0)
            }
            else if(!
g_Player_is_catcher[id] && is_user_alive(id))
            {
                
set_user_gravity(id,0.5)
                
g_Player_is_freeze[id] = false
                set_user_maxspeed
(id,400.0)
            }



public 
ev_CheckWeapon(id)
{
    if(!
g_Player_is_freeze[id] && is_user_alive(id))
    {
        
set_user_maxspeed(id,400.0)
    }
    else if(
g_Player_is_freeze[id] && is_user_alive(id))
    {
        
set_user_maxspeed(id,0.1)
    }



Exolent[jNr] 03-02-2010 20:12

Re: set_user_maxspeed
 
cs_get_user_team(id) & CS_TEAM_T
is not the same as
cs_get_user_team(id) == CS_TEAM_T

It may provide the same result you need since 1/2 (T/CT) are individual bits and a team cannot be a bitsum.
But it will not work properly if you try & CS_TEAM_SPECTATOR.

One 03-02-2010 20:30

Re: set_user_maxspeed
 
oh :P i tough both are the same :D

do i need to change it to == ?

wrecked_ 03-02-2010 22:00

Re: set_user_maxspeed
 
I don't see any reason not to, if it has the possibility to cause confusion.

Exolent[jNr] 03-02-2010 22:29

Re: set_user_maxspeed
 
Quote:

Originally Posted by One (Post 1105991)
do i need to change it to == ?

Yes.

ConnorMcLeod 03-03-2010 00:57

Re: set_user_maxspeed
 
Use HAM instead of CurWeapon for more efficienty

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

public plugin_init()
{
    const 
Ham:Ham_Player_ResetMaxSpeed Ham_Item_PreFrame
    RegisterHam
(Ham_Player_ResetMaxSpeed"player""Player_ResetMaxSpeed_Post"1)
}

public 
Player_ResetMaxSpeed_Postid )
{
    if( 
is_user_alive(id) )
    {
        new 
Float:flMaxSpeed
        pev
(idpev_maxspeedflMaxSpeed)
        if( 
flMaxSpeed == 1.0 // this is freezetime
        
{
            
//
        
}
        else
        {
            if( 
g_Player_is_freeze[id] )
            {
                
set_pev(idpev_maxspeed1.0)
            }
            else
            {
                
set_pev(idpev_maxspeed400.0)
            }
        }
    }
    else 
// user is dead/spectator
    
{
        
// set_pev(id, pev_maxspeed, 1000.0)
    
}



One 03-03-2010 07:28

Re: set_user_maxspeed
 
yay. done & ty
i have a new question but i will open a new thread for this :D


All times are GMT -4. The time now is 08:40.

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