Quote:
Originally Posted by HamletEagle
Don't get me wrong, I'm not picking on you, I'm trying to explain some stuff that seems to confuse you.
|
Seems to be lacking some key knowledge on tags, arrays, and globals.
I'm going to close this thread as it will probably lead to more confusion/arguing. For understanding the issues, see other posts or more info below:
- CS_TEAM_* constants are the CsTeams tag, no need to retag.
- Retagging floats is unnecessary.
- Untagged [int] array created, but forcing float data. Better example:
PHP Code:
new Float:gfPlayerGravity[ MAX_PLAYERS + 1 ]; //global float array to cache the last set gravity value by this plugin; for active gravity [from any plugin] use get_user_gravity instead of this array
SetPlayerGravity( iPlayer, Float:fGravity )
{
gfPlayerGravity[ iPlayer ] = fGravity; //update our cached value for iPlayer
set_user_gravity( iPlayer, fGravity ); //set gravity with fun module
}
- Pcvar example:
PHP Code:
new pcvar_max_money;
new giMaxMoney;
new giPlayerMoney[ MAX_PLAYERS + 1 ];
public plugin_init()
{
pcvar_max_money = get_cvar_pointer( "max_money" );
//get pcvar value
//giMaxMoney = get_pcvar_num( pcvar_max_money ); // this retrieves the cvar at time of plugin_init
bind_pcvar_num( pcvar_max_money, giMaxMoney ); // binds the cvar to the global variable, so we do not need to retrieve each time
}
public client_authorized( iPlayer )
{
giPlayerMoney[ iPlayer ] = giMaxMoney; //update our cached value for iPlayer
cs_set_user_money( iPlayer, giMaxMoney, .flash = 0); //set money with cstrike module
}
- MAX_PLAYERS is being used as a string length instead of an array size. Local string example:
PHP Code:
funcRandom( iPlayer )
{
new strPlayerName[ MAX_NAME_LENGTH ]; //creating a string 32 cells long
get_user_name( iPlayer, strPlayerName, charsmax( strPlayerName ) );
//...
}
Global string example:
PHP Code:
new gstrPlayerName[ MAX_PLAYERS + 1 ][ MAX_NAME_LENGTH ]; //creating a global string array to cache player names
funcRandom( iPlayer )
{
get_user_name( iPlayer, gstrPlayerName[ iPlayer ], charsmax( gstrPlayerName[] ) );
//...
}