Raised This Month: $ Target: $400
 0% 

[SOLVED]Variable for every player [Help]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-03-2010 , 14:23   Re: [SOLVED]Variable for every player [Help]
Reply With Quote #1

Quote:
Originally Posted by drekes View Post
Cool, I got one more question.
I've found this kind of loop in some blockmaker code.
PHP Code:
for(new 1<= g_iMaxPlayers; ++i
Does that make any difference with this one :
PHP Code:
for(new 1<= g_iMaxPlayersi++) 
No difference because the i is not being used there. Only incremented.
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-03-2010 , 16:50   Re: [SOLVED]Variable for every player [Help]
Reply With Quote #2

Callesson, if you are doing multiple actions based on various different values then a switch is usually best, it all depends on the exact condition/situation. If you need to do one action based on a particular condition and a different action on all other conditions then an if-else is usually best. Each instance/need is unique for what is best to use.
__________________
Bugsy is offline
Callesson
Member
Join Date: Jan 2010
Old 12-03-2010 , 17:01   Re: [SOLVED]Variable for every player [Help]
Reply With Quote #3

Oh I see
Gonna change it, thx
__________________
Callesson is offline
Callesson
Member
Join Date: Jan 2010
Old 12-03-2010 , 17:22   Re: [SOLVED]Variable for every player [Help]
Reply With Quote #4

Double post again..
Well there is a problem with the switch, if think?
I would like the warningamount to be changed with a
Code:
register_cvar("nbw_warnings", "3");
so I created new floats
Code:
new Float:warningAmount = get_cvar_float("nbw_warnings");
new Float:warningAmountMinusOne = get_cvar_float("nbw_warnings") - 1;
How can i now use them in the switch?
Like Instead of
Code:
  
    case 4:
        {
    new name[18]
    get_user_name(id, name, 17)
    client_cmd(id,"echo Kicked from server!")
    client_cmd(id,"disconnect")
    client_print( 0 , print_chat , "Player %s got kicked for using bad langauge!",name );
        }
This
Code:
     case <the warning amount>:
        {
    new name[18]
    get_user_name(id, name, 17)
    client_cmd(id,"echo Kicked from server!")
    client_cmd(id,"disconnect")
    client_print( 0 , print_chat , "Player %s got kicked for using bad langauge!",name );
        }
Whole code for kick(id)
Code:
public kick( id )
{
    switch( warning[ id ] )
    {
    case 0:
        {
    warning[ id ]++;
         client_print( id , print_chat , "[Watch your lang] Warning %i/2" , warning[ id ] );
    warning[ id ]++;
        }
    case 3:
        {
         client_print( id , print_chat , "[Watch your lang] Next time kick!" );
    warning[ id ]++;
        }
        case 4:
        {
    new name[18]
    get_user_name(id, name, 17)
    client_cmd(id,"echo Kicked from server!")
    client_cmd(id,"disconnect")
    client_print( 0 , print_chat , "Player %s got kicked for using bad langauge!",name );
        }
        default:
        {
    client_print( id , print_chat , "[Watch your lang] %i/2" , warning[ id ] );
         warning[ id ]++;
        }
    }


    return PLUGIN_HANDLED;
}
__________________
Callesson is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-03-2010 , 17:37   Re: [SOLVED]Variable for every player [Help]
Reply With Quote #5

Then you have to use something like this:

PHP Code:
    new iMaxWarnings get_cvar_num("nbw_warnings")

    
warning[id]++

    if( 
warning[id] == iMaxWarnings )
    {
        
client_printid print_chat "[Watch your lang] Next time kick!" )
    }
    else if( 
warning[id] == iMaxWarnings )
    {
        
server_cmd("kick #%d ^"Kicked from server!^""get_user_userid(id))
        
client_printprint_chat "Player %s got kicked for using bad langauge!",name )
    }
    else
    {
        
client_printid print_chat "[Watch your lang] Warning %i/%d" warningid ], iMaxWarnings)
    } 
__________________
fysiks is offline
Callesson
Member
Join Date: Jan 2010
Old 12-03-2010 , 18:13   Re: [SOLVED]Variable for every player [Help]
Reply With Quote #6

Okey awesome thanks!

Can you explain the difference between
%i
%s
%d
And all those ?
__________________
Callesson is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-03-2010 , 19:55   Re: [SOLVED]Variable for every player [Help]
Reply With Quote #7

%i is used for integer value's
%s for strings
%d not sure, never used it.

%.*f Float, * represents the amount of numbers behind . like
PHP Code:
new Floatfloat 3.1542;
client_print(idprint_chat"%.2f"float);
// will print 3.15 
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Callesson
Member
Join Date: Jan 2010
Old 12-03-2010 , 19:58   Re: [SOLVED]Variable for every player [Help]
Reply With Quote #8

Quote:
Originally Posted by drekes View Post
%i is used for integer value's
%s for strings
%d not sure, never used it.

%.*f Float, * represents the amount of numbers behind . like
PHP Code:
new Floatfloat 3.1542;
client_print(idprint_chat"%.2f"float);
// will print 3.15 
Oh, okey Now I get it, thx!
__________________
Callesson is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-03-2010 , 20:09   Re: [SOLVED]Variable for every player [Help]
Reply With Quote #9

http://www.amxmodx.org/funcwiki.php?go=func&id=49
http://www.cplusplus.com/reference/c...cstdio/printf/
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Callesson
Member
Join Date: Jan 2010
Old 12-04-2010 , 05:52   Re: [SOLVED]Variable for every player [Help]
Reply With Quote #10

(Y)
__________________
Callesson 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:23.


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