View Single Post
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-15-2017 , 12:28   Re: Some simple solutions
#8

Quote:
Originally Posted by HamletEagle View Post
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:
  1. CS_TEAM_* constants are the CsTeams tag, no need to retag.
  2. Retagging floats is unnecessary.
  3. Untagged [int] array created, but forcing float data. Better example:
    PHP Code:
    new Float:gfPlayerGravityMAX_PLAYERS ];  //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

    SetPlayerGravityiPlayerFloat:fGravity )
    {
        
    gfPlayerGravityiPlayer ] = fGravity//update our cached value for iPlayer
        
    set_user_gravityiPlayerfGravity ); //set gravity with fun module

  4. Pcvar example:
    PHP Code:
    new pcvar_max_money;
    new 
    giMaxMoney;
    new 
    giPlayerMoneyMAX_PLAYERS ];

    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_numpcvar_max_moneygiMaxMoney ); // binds the cvar to the global variable, so we do not need to retrieve each time
    }
    public 
    client_authorizediPlayer )
    {
        
    giPlayerMoneyiPlayer ] = giMaxMoney//update our cached value for iPlayer
        
    cs_set_user_moneyiPlayergiMaxMoney, .flash 0); //set money with cstrike module

  5. MAX_PLAYERS is being used as a string length instead of an array size. Local string example:

    PHP Code:
    funcRandomiPlayer )
    {
        new 
    strPlayerNameMAX_NAME_LENGTH ];  //creating a string 32 cells long
        
    get_user_nameiPlayerstrPlayerNamecharsmaxstrPlayerName ) );
        
    //...

    Global string example:
    PHP Code:
    new gstrPlayerNameMAX_PLAYERS ][ MAX_NAME_LENGTH ]; //creating a global string array to cache player names

    funcRandomiPlayer )
    {
        
    get_user_nameiPlayergstrPlayerNameiPlayer ], charsmaxgstrPlayerName[] ) );
        
    //...

Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`