Raised This Month: $51 Target: $400
 12% 

Questions About :Bool


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Merc3y
Member
Join Date: Dec 2009
Old 01-23-2010 , 22:19   Questions About :Bool
Reply With Quote #1

Target:

I was trying to make every round call a function that randomly pick randomly number of clients to become humans and change their team to "CT", the rest shall become zombies which it's team is "T". A human classes menu will appear only for humans.

Problem:

1. I not sure weither the function that randomly pick randomly number of clients is called or the human classes menu were called, because the human classes didn't show.

2. Should i use hook the speed or using playerthink will do ?

3. I can't figure how to change the remaining clients after the "CT" were pick to become "T".

4. How to use bool ?

5. Game hangs when using this plugin-in.

Codes:

PHP Code:
/*================================================================================ 
  
    -----------------------------------
    -*- Dead World -*-
    -----------------------------------
    
    ~~~~~~~~~~~~~~~
    - Description -
    ~~~~~~~~~~~~~~~
    
    Currently none.
 
    
================================================================================*/

/*================================================================================
 [ Include Customization ]
=================================================================================*/

#include < amxmodx >
#include < fakemeta >
#include < amxmisc >
#include < fun >
#include < cstrike >

/*================================================================================
 [ Game Variable Customization ]
=================================================================================*/

new g_iMsgSayTextg_iMaxPlayersg_iDelayg_iHumanClasses33 ]
new 
bool:g_iZombie33 ]

/*================================================================================
 [ Plugin ini Customization ]
=================================================================================*/

public plugin_init( )
{
    
register_plugin"Dead World" "1.0""Merc3y" )
    
register_forwardFM_PlayerPreThink"fw_PlayerPreThink" )
    
register_logevent"logevent_round_start"2"1=Round_Start" 
    
register_concmd"amx_deadworld""Toggle"ADMIN_LEVEL_D" < 1 = on | 0 = off >" )
    
register_cvar"deadworld_toggle""0" )
    
g_iDelay register_cvar"deadworld_delay""10.0" )
    
g_iMsgSayText get_user_msgid"SayText" )
    
g_iMaxPlayers get_maxplayers( )
}

/*================================================================================
 [ Game Customization ]
=================================================================================*/

public Game_Startid )
{
    
#define NUMS 4
    
new iNumplayers32 ]
    new 
randomnumsNUMS ]
    
get_playersplayersiNum"a" )
    
    for ( new 
i=0i<= sizeofrandomnums ); i++ )
    {
        
randomnums] = random_num1iNum )
        if ( 
!= )
        {
            for( new 
j=0j<ij++ )
            {
                if ( 
randomnums] == randomnums] )
                {
                    
i--
                    break
                }
            }
        }
    }
    
    for ( new 
a=0a<=iNuma++ )
    {
        for ( new 
b=0b<=NUMSb++ )
        {
            if ( 
players] == playersrandomnums] ] )
            {
                
cs_set_user_teamplayersrandomnums] ], CS_TEAM_CT )
                
g_iZombieid ] = false
            
}
            
            else
            {
                
cs_set_user_teamplayersrandomnums] ], CS_TEAM_T )
                
g_iZombieid ] = true
            
}
        }
    }

    if ( 
is_user_aliveid ) && !g_iZombieid ] )
    { 
        
set_task1.0"Human_Class_Menu"id )
        
g_iZombieid ] = false
    


    else if ( 
is_user_aliveid ) && g_iZombieid ] )
    {
        
g_iZombieid ] = true
        remove_task
id )
    }      
}  

/*================================================================================
 [ Human Class Customization ]
=================================================================================*/

public Human_Class_Menuid )
{
    new 
menu menu_create"Human Class Menu""Human_Class_Menu_Handler" )
    
menu_additemmenu"Sniper""1")
    
menu_additemmenu"Combat""2")
    
menu_setpropmenuMPROP_EXITMEXIT_ALL )
    
menu_displayidmenu)
}

public 
Human_Class_Menu_Handleridmenuitem )
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroymenu )
        return 
PLUGIN_HANDLED
    
}
    
    new 
data], iName64 ]
    new 
accesscallback
    menu_item_getinfo
menuitemaccessdata5iName63callback )
    new 
key str_to_numdata )
    
    switch( 
key )
    {
        case 
1:
        {
            
g_iHumanClasses id ] = 
    
            strip_user_weapons
id )
  
            
set_user_healthid100 )
            
set_user_armorid50 )
            
cs_set_user_nvgid)
            
give_itemid"weapon_awp" )
            
give_itemid"weapon_deagle" )
            
cs_set_user_bpammoidCSW_AWP30 )
            
cs_set_user_bpammoidCSW_DEAGLE56 )
            
client_printcolorid"/gYou have chosen sniper." )
        }

        case 
2:
        {
            
g_iHumanClassesid ] = 1

            strip_user_weapons
id )
            
set_user_healthid150 )
            
set_user_armorid35 )
            
give_itemid"weapon_m4a1" )
            
give_itemid"weapon_ak47" )
            
give_itemid"weapon_deagle" )
            
cs_set_user_bpammoidCSW_M4A190 )
            
cs_set_user_bpammoidCSW_AK4790 )
            
cs_set_user_bpammoidCSW_DEAGLE56 )
            
client_printcolorid"/gYou have chosen combat." )
        }
    }
    
menu_destroymenu )
    return 
PLUGIN_HANDLED
}

/*================================================================================
 [ Human Speed Customization ]
=================================================================================*/

public fw_PlayerPreThinkid )
{
    if ( 
g_iHumanClassesid ] == )
    {
        
set_user_maxspeedid250.0 )
    }

    if ( 
g_iHumanClassesid ] == )
    {
        
set_user_maxspeedid230.0 )
    }
}

/*================================================================================
 [ Toggle Customization ]
=================================================================================*/

public Toggleidlevelcid )
{
    if ( !
cmd_accessidlevelcid) )
    {
        return 
PLUGIN_HANDLED
    
}
    new 
arg132 ]
    
read_argv1arg131 )
    if ( 
str_to_numarg1 ) )
    {
        
set_cvar_num"deadworld_toggle")
        
server_cmd"sv_restartround 10" )
    } 
    else
    {
        
set_cvar_num"deadworld_toggle")
        
server_cmd"sv_restartround 10" )
    }       
    return 
PLUGIN_HANDLED
}

/*================================================================================
 [ Event Customization ]
=================================================================================*/

public logevent_round_start( )
{
    if ( 
get_cvar_num"deadworld_toggle" ) == )
    {
        for ( new 
1<= g_iMaxPlayersi++ )
        {
            
set_taskget_pcvar_floatg_iDelay ), "Game_Start" )
        }
    }
}

/*================================================================================
 [ Stock Customization ]
=================================================================================*/
stock client_printcolor( const id, const input[ ], any:... )
{
 new 
iCount 1iPlayers32 ]
 
 static 
szMsg191 ]
 
vformatszMsgcharsmaxszMsg ), input)
 
 
replace_allszMsg190"/g""^4" 
 
replace_allszMsg190"/y""^1" 
 
replace_allszMsg190"/ctr""^3" 
 
replace_allszMsg190"/w""^0" 
 
 if ( 
id iPlayers] = id
 
else get_playersiPlayersiCount"ch" )
 
 for ( new 
0iCounti++ )
 {
  if ( 
is_user_connectediPlayers] ) )
  {
   
message_beginMSG_ONE_UNRELIABLEg_iMsgSayText_iPlayers] )
   
write_byteiPlayers] )
   
write_stringszMsg )
   
message_end( )
  }
 }

__________________
How I Wish That I Can Host Without Any Problem.
Merc3y is offline
Mxnn
Veteran Member
Join Date: Aug 2009
Location: AT MY HOME
Old 01-24-2010 , 00:53   Re: Questions About :Bool
Reply With Quote #2

You have the same stuff that zombieplague, why?
Mxnn is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 01-24-2010 , 01:06   Re: Questions About :Bool
Reply With Quote #3

Quote:
Originally Posted by Mxnn View Post
You have the same stuff that zombieplague, why?
Because he's editing the zombieplague mod?
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Merc3y
Member
Join Date: Dec 2009
Old 01-24-2010 , 01:42   Re: Questions About :Bool
Reply With Quote #4

Quote:
Originally Posted by Mxnn View Post
You have the same stuff that zombieplague, why?
He say he would help me with this. He asked me to gave him the plugin.

But i guess he is trying to scam me.
__________________
How I Wish That I Can Host Without Any Problem.

Last edited by Merc3y; 01-24-2010 at 03:06.
Merc3y is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 01-24-2010 , 09:00   Re: Questions About :Bool
Reply With Quote #5

Quote:
Originally Posted by Merc3y View Post
4. How to use bool ?
Just like any other variable but with values of

true (1)
false (0)

http://en.wikipedia.org/wiki/Boolean_algebra_(logic)
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 01-25-2010 , 04:44   Re: Questions About :Bool
Reply With Quote #6

Any variable that is tagged as bool: (notice the lack of a capital letter) can be true an alias for 1, or false an alias for 0.

Quote:
Originally Posted by The PAWN Language Guide, Pg. 104 # Tag Names
false 0 (this constant is tagged as bool:).
true 1 (this constant is tagged as bool:).
bool: For "true/false" flags. The predefined constants true and false have this tag.
__________________
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear
Merc3y
Member
Join Date: Dec 2009
Old 01-28-2010 , 03:19   Re: Questions About :Bool
Reply With Quote #7

Quote:
Originally Posted by Dygear View Post
Any variable that is tagged as bool: (notice the lack of a capital letter) can be true an alias for 1, or false an alias for 0.
I don't really understand.

So what i was doing is correct ?
__________________
How I Wish That I Can Host Without Any Problem.
Merc3y is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 01-28-2010 , 03:44   Re: Questions About :Bool
Reply With Quote #8

Quote:
Originally Posted by Merc3y View Post
I don't really understand.

So what i was doing is correct ?
PHP Code:
new bool:Is_Assault[33];

....

Public 
PlayerSpawn(id)
{
    if(
Is_Assault[id]) //Uses the bool to return a True or False answer.
    
{
          
give_item(id"weapon_ak47"); //If true give ak37
     
}
    else
    {
          
strip_user_weapons(id); //else strip him
     
}

Code:
String = {My First String}
Float = {0.0, 0.1, 1.5, 6.7}
Bool = {False, True}
Integer = {0,1,2,3,4,5,6}

Last edited by Doc-Holiday; 01-28-2010 at 03:46.
Doc-Holiday is offline
Merc3y
Member
Join Date: Dec 2009
Old 01-28-2010 , 03:59   Re: Questions About :Bool
Reply With Quote #9

Quote:
Originally Posted by NcB_Sav View Post
PHP Code:
new bool:Is_Assault[33];
 
....
 
Public 
PlayerSpawn(id)
{
    if(
Is_Assault[id]) //Uses the bool to return a True or False answer.
    
{
          
give_item(id"weapon_ak47"); //If true give ak37
     
}
    else
    {
          
strip_user_weapons(id); //else strip him
     
}

Code:
String = {My First String}
Float = {0.0, 0.1, 1.5, 6.7}
Bool = {False, True}
Integer = {0,1,2,3,4,5,6}

Thanks.

How to do this ?

Every round pick random number of random client to become CT ?
__________________
How I Wish That I Can Host Without Any Problem.
Merc3y is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 01-28-2010 , 04:57   Re: Questions About :Bool
Reply With Quote #10

Dont member where i got this from but here ya go

PHP Code:
new iPlayers32 ], iNum;
get_playersiPlayersiNum );

if( 
iNum <= ) {
    return;
}

new 
iRandomIndex randomiNum );

for( new 
0iNumi++ ) 
{
    if( 
== iRandomIndex 
    {
        
cs_set_user_teamiPlayers], CS_TEAM_T ); //Sets a random client to T
        
    

    else 
    {
        
cs_set_user_teamiPlayers], CS_TEAM_CT ); //Sets the rest to CT
    
}

Doc-Holiday 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 11:39.


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