AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Questions About :Bool (https://forums.alliedmods.net/showthread.php?t=116539)

Merc3y 01-23-2010 22:19

Questions About :Bool
 
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( )
  }
 }



Mxnn 01-24-2010 00:53

Re: Questions About :Bool
 
You have the same stuff that zombieplague, why?

wrecked_ 01-24-2010 01:06

Re: Questions About :Bool
 
Quote:

Originally Posted by Mxnn (Post 1065314)
You have the same stuff that zombieplague, why?

Because he's editing the zombieplague mod?

Merc3y 01-24-2010 01:42

Re: Questions About :Bool
 
Quote:

Originally Posted by Mxnn (Post 1065314)
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.

joropito 01-24-2010 09:00

Re: Questions About :Bool
 
Quote:

Originally Posted by Merc3y (Post 1065178)
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)

Dygear 01-25-2010 04:44

Re: Questions About :Bool
 
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.


Merc3y 01-28-2010 03:19

Re: Questions About :Bool
 
Quote:

Originally Posted by Dygear (Post 1066753)
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 ?

Doc-Holiday 01-28-2010 03:44

Re: Questions About :Bool
 
Quote:

Originally Posted by Merc3y (Post 1070358)
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}


Merc3y 01-28-2010 03:59

Re: Questions About :Bool
 
Quote:

Originally Posted by NcB_Sav (Post 1070363)
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 ?

Doc-Holiday 01-28-2010 04:57

Re: Questions About :Bool
 
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
    
}




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

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