Raised This Month: $ Target: $400
 0% 

Get_pcvar_float help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
S34Qu4K3
Veteran Member
Join Date: Jan 2010
Location: Galicia
Old 05-26-2010 , 10:04   Get_pcvar_float help
Reply With Quote #1

I have this code:

PHP Code:
/*

    This plugin sets each 30 seconds  a rondom hitzone
    ##CVARS##
    amx_random_hitzones 1//0   (defaut 1)
    amx_random_hitzones_time 30.0


*/
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fun>


new toggle
new hold_time

public plugin_init() 
{
    
register_plugin("Random HitZones""1.1""S34Qu4K3")
    
    
toggle register_cvar("amx_random_hitzones""1")
    
hold_time   register_cvar("amx_random_hitzones_time""10.0")
    
    
RegisterHam(Ham_Spawn"player""Main"1);
    
    
register_dictionary("randomhitzones.txt")
}
public 
Main(id)
{
    if(
get_pcvar_num(toggle))
    {
    new 
rand random_num(0,7)
    switch(
rand)
    {
        case 
0:
        {
            
set_user_hitzones(,0255)
            
client_print(idprint_chat"%L"LANG_PLAYER"GENERIC")
        }
        case 
1:
        {
            
set_user_hitzones(,02)
            
client_print(idprint_chat"%L"LANG_PLAYER"HEAD_ONLY")
        }
        case 
2:
        {
            
set_user_hitzones(,04)
            
client_print(idprint_chat"%L"LANG_PLAYER"CHEST_ONLY")
        }
        case 
3:
        {
            
set_user_hitzones(,08)
            
client_print(idprint_chat"%L"LANG_PLAYER"STOMACH_ONLY")
        }
        case 
4:
        {
            
set_user_hitzones(,016)
            
client_print(idprint_chat"%L"LANG_PLAYER"LEFTARM_ONLY")
        }
        case 
5:
        {
            
set_user_hitzones(,032)
            
client_print(idprint_chat,  "%L"LANG_PLAYER,"RIGHTARM_ONLY")
        }
        case 
6:
        {
            
set_user_hitzones(,064)
            
client_print(idprint_chat,  "%L"LANG_PLAYER"LEFTLEG_ONLY")
        }
        case 
7:
        {
            
set_user_hitzones(,0128)
            
client_print(idprint_chat,  "%L"LANG_PLAYER,"RIGHTLEG_ONLY")
        }
    }
    
set_task(get_cvar_float("hold_time"),"Main")

    }
    else
    {
        
client_print(idprint_chat"%L"LANG_PLAYER"OFF")
    }

BUt I think that this part is bad:

PHP Code:
set_task(get_cvar_float("hold_time"),"Main"
Someone can help me?
__________________

- ASM2SMA: Experimental AMXX Assembly encoder

- Defuse Bar Fix

Quote:
Originally Posted by Arkshine
I DON'T WANT TO SEE NOOOOOOOOOOOOOOO AHHHHH. MY EYES ARE ALREADY HURT.
S34Qu4K3 is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 05-26-2010 , 10:30   Re: Get_pcvar_float help
Reply With Quote #2

Code:
set_task(get_pcvar_float(hold_time),"Main")
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
S34Qu4K3
Veteran Member
Join Date: Jan 2010
Location: Galicia
Old 05-26-2010 , 10:32   Re: Get_pcvar_float help
Reply With Quote #3

Yes, solved, now, can you check the code for other errors?

PHP Code:
/*

    This plugin sets each 30 seconds  a rondom hitzone
    ##CVARS##
    amx_random_hitzones 1//0   (defaut 1)
    amx_random_hitzones_time 30.0


*/
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fun>


new toggle
new hold_time

public plugin_init() 
{
    
register_plugin("Random HitZones""1.1""S34Qu4K3")
    
    
toggle register_cvar("amx_random_hitzones""1")
    
hold_time   register_cvar("amx_random_hitzones_time""10.0")
    
    
RegisterHam(Ham_Spawn"player""Main"1);
    
    
register_dictionary("randomhitzones.txt")
}
public 
Main(id)
{
    if(
get_pcvar_num(toggle))
    {
    new 
rand random_num(0,7)
    new 
name[32]
    
get_user_name(idname31)
    switch(
rand)
    {
        case 
0:
        {
            
set_user_hitzones(,0255)
            
client_print(idprint_chat"%L "LANG_PLAYER"GENERIC"name[id])
        }
        case 
1:
        {
            
set_user_hitzones(,02)
            
client_print(idprint_chat"%L"LANG_PLAYER"HEAD_ONLY"name[id])
        }
        case 
2:
        {
            
set_user_hitzones(,04)
            
client_print(idprint_chat"%L"LANG_PLAYER"CHEST_ONLY"name[id])
        }
        case 
3:
        {
            
set_user_hitzones(,08)
            
client_print(idprint_chat"%L"LANG_PLAYER"STOMACH_ONLY"name[id])
        }
        case 
4:
        {
            
set_user_hitzones(,016)
            
client_print(idprint_chat"%L"LANG_PLAYER"LEFTARM_ONLY"name[id])
        }
        case 
5:
        {
            
set_user_hitzones(,032)
            
client_print(idprint_chat,  "%L"LANG_PLAYER,"RIGHTARM_ONLY"name[id])
        }
        case 
6:
        {
            
set_user_hitzones(,064)
            
client_print(idprint_chat,  "%L"LANG_PLAYER"LEFTLEG_ONLY"name[id])
        }
        case 
7:
        {
            
set_user_hitzones(,0128)
            
client_print(idprint_chat,  "%L"LANG_PLAYER,"RIGHTLEG_ONLY"name[id])
        }
    }
    
    
set_task(get_pcvar_float(hold_time),"Main")

    }
    else
    {
        
client_print(idprint_center"%L"LANG_PLAYER"OFF")
    }

__________________

- ASM2SMA: Experimental AMXX Assembly encoder

- Defuse Bar Fix

Quote:
Originally Posted by Arkshine
I DON'T WANT TO SEE NOOOOOOOOOOOOOOO AHHHHH. MY EYES ARE ALREADY HURT.
S34Qu4K3 is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 05-26-2010 , 10:43   Re: Get_pcvar_float help
Reply With Quote #4

  • amxmisc isn't used, however, it doesn't matter that it's included.
  • You're printing the text to the player that is spawning - why bother printing their name?
  • You use LANG_PLAYER and since you're printing to id, use id instead of LANG_PLAYER.
  • A thinking entity would be more suitable for this kind of action, as it takes less cpu and memory than a set_task. That is of course if you plan changing them every ten seconds. If you still want the set_task way I'd suggest you to make a task that loops instead of having 32 tasks. 1 task with 32 players > 32 tasks with 32 players

You should check it yourself next time, and if you encounter any difficulties, just ask someone on the forums.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
S34Qu4K3
Veteran Member
Join Date: Jan 2010
Location: Galicia
Old 05-26-2010 , 11:01   Re: Get_pcvar_float help
Reply With Quote #5

Quote:
Originally Posted by Xellath View Post
  • amxmisc isn't used, however, it doesn't matter that it's included.
  • You're printing the text to the player that is spawning - why bother printing their name?
  • You use LANG_PLAYER and since you're printing to id, use id instead of LANG_PLAYER.
  • A thinking entity would be more suitable for this kind of action, as it takes less cpu and memory than a set_task. That is of course if you plan changing them every ten seconds. If you still want the set_task way I'd suggest you to make a task that loops instead of having 32 tasks. 1 task with 32 players > 32 tasks with 32 players

You should check it yourself next time, and if you encounter any difficulties, just ask someone on the forums.
1. ;)
2.Beacause the plugin sets a different hitzone for each player (i donīt know how to set the same hitzone for all the players)
3.Thanks
4.I didnīt know hot to do this, iīll be glad if you teach me


I will try
__________________

- ASM2SMA: Experimental AMXX Assembly encoder

- Defuse Bar Fix

Quote:
Originally Posted by Arkshine
I DON'T WANT TO SEE NOOOOOOOOOOOOOOO AHHHHH. MY EYES ARE ALREADY HURT.
S34Qu4K3 is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 05-26-2010 , 15:51   Re: Get_pcvar_float help
Reply With Quote #6

Thinking entity:

Code:
#include < amxmodx > #include < hamsandwich > #include < engine > const Float:INTERVAL = 10.0; new const g_szThinkingEntityClassname[ ] = "hitzone_think"; new g_iThinkingEntity; public plugin_init( ) {     g_iThinkingEntity = create_entity( "info_target" );     entity_set_string( g_iThinkingEntity, EV_SZ_classname, g_szThinkingEntityClassname );     entity_set_float( g_iThinkingEntity, EV_FL_nextthink, INTERVAL );         RegisterHam( Ham_Think, g_szThinkingEntityClassname, "Forward_EntityThink" ); } public Forward_EntityThink( iEntity ) {     static szPlayers[ 32 ], iPlayerCount, iNum, iPlayer;     if( iEntity == g_iThinkingEntity )     {         get_players( szPlayers, iPlayerCount, "a" );         for( iNum = 0; iNum < iPlayerCount; iNum++ )         {             iPlayer = szPlayers[ iNum ];                         // iPlayer = index of a player             // do whatever to set their hitzone here         }     }         entity_set_float( g_iThinkingEntity, EV_FL_nextthink, INTERVAL ); }

Set task:

Code:
#include < amxmodx > const Float:INTERVAL = 10.0; public plugin_init( ) {     set_task( INTERVAL, "HitzoneTask", _, _, _, "b" ); } public HitzoneTask( ) {     static szPlayers[ 32 ], iPlayerCount, iNum, iPlayer;     get_players( szPlayers, iPlayerCount, "a" );     for( iNum = 0; iNum < iPlayerCount; iNum++ )     {         iPlayer = szPlayers[ iNum ];                 // iPlayer = index of a player         // do whatever to set their hitzone here     } }
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath 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 05:20.


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