AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Сhange the string "rebuy" (https://forums.alliedmods.net/showthread.php?t=283151)

artist 05-26-2016 15:16

Сhange the string "rebuy"
 
I want to add a weapon to "F2", when issued its "give_item(id, "weapon_m4a1")"

Code:

void _ClientCommand(edict_t *pEntity)
{
        //........................
        else if (FStrEq(pcmd, "cl_setrebuy"))
        {
                if (CMD_ARGC() == 2)
                {
                        player->InitRebuyData(CMD_ARGV(1));

                        BOOL oldval = g_bClientPrintEnable;
                        g_bClientPrintEnable = false;
                        player->Rebuy();
                        g_bClientPrintEnable = oldval;
                }

                return;
        }
        //........................
}

Code:

void CBasePlayer::Rebuy(void)
{
        char *string = m_rebuyString;
        char *token;

        m_bIsInRebuy = true;

        while(1)
        {
                string = MP_COM_Parse(string);
                token = MP_COM_GetToken();

                if(!string) break;

                if(!stricmp(token, "primaryWeapon")) RebuyPrimaryWeapon();
                else if(!stricmp(token, "primaryAmmo")) RebuyPrimaryAmmo();
                else if(!stricmp(token, "secondaryWeapon")) RebuySecondaryWeapon();
                else if(!stricmp(token, "secondaryAmmo")) RebuySecondaryAmmo();
                else if(!stricmp(token, "hegrenade")) RebuyHEGrenade();
                else if(!stricmp(token, "flashbang")) RebuyFlashbang();
                else if(!stricmp(token, "smokegrenade")) RebuySmokeGrenade();
                else if(!stricmp(token, "defuser")) RebuyDefuser();
                else if(!stricmp(token, "nightvision")) RebuyNightVision();
                else if(!stricmp(token, "armor")) RebuyArmor();
        }
        m_bIsInRebuy = false;
}

Code:

char *m_rebuyString;              /*  2356    4 */
PHP Code:

static bufer[256]; get_pdata_string(id2356bufercharsmax(bufer), 14)
client_print(idprint_chatbufer

CS crashes...

klippy 05-26-2016 15:49

Re: Сhange the string "rebuy"
 
Try with 589 instead of 2356. char pointers (strings) are integer aligned, so you should divide by 4.

artist 05-26-2016 15:51

Re: Сhange the string "rebuy"
 
Thank you ))

Nothing displays, empty string...
First introduced in the console "autobuy", later "kill", later "rebuy", and then I tried to get a string from the offset...

siriusmd99 05-30-2016 09:07

Re: Сhange the string "rebuy"
 
:?::?:at?

Why not :

PHP Code:

#include <amxmodx>
#include <fun>

public plugin_init() {
    
register_plugin("F2 Button Give Item""1.0""siriusmd99")
    
    
register_clcmd("rebuy""rebuy_caught")
}    

public 
rebuy_caught(id){

  
give_item(id"weapon_m4a1")
  return 
PLUGIN_HANDLED;




All times are GMT -4. The time now is 18:41.

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