Raised This Month: $51 Target: $400
 12% 

Сhange the string "rebuy"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
artist
Member
Join Date: Nov 2013
Old 05-26-2016 , 15:16   Сhange the string "rebuy"
Reply With Quote #1

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...

Last edited by artist; 05-26-2016 at 15:24.
artist is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 05-26-2016 , 15:49   Re: Сhange the string "rebuy"
Reply With Quote #2

Try with 589 instead of 2356. char pointers (strings) are integer aligned, so you should divide by 4.

Last edited by klippy; 05-26-2016 at 15:49.
klippy is offline
artist
Member
Join Date: Nov 2013
Old 05-26-2016 , 15:51   Re: Сhange the string "rebuy"
Reply With Quote #3

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...

Last edited by artist; 05-26-2016 at 16:00.
artist is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-30-2016 , 09:07   Re: Сhange the string "rebuy"
Reply With Quote #4

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;

siriusmd99 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 12:37.


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