Jump to content
Sanchez

[C++]Attribute changing log

Recommended Posts

Hi,

I know now its easy to "fix" the switchbot in the binary, but maybe this short code snippet will be helpful for some servers. Functions:

  • You can specify the range of the checking (Just check if the user change the bonus within every 1 sec or within every 5 sec)
  • You can check if the user change the bonuses always in the same time or if you want to be more specify you can use +1/-1 range

Open game/item_attribute.cpp and search for the ChangeAttribute event. Add this code to the begin of the event:
 

	LPCHARACTER	ch = GetOwner();
	SwitchTimeNow = thecore_pulse();
	if (SwitchTimeNow < (LastSwitchTime + CHECK_SWITCH_TIME * 25))
	{
		/* if (-1 <= SwitchTimeNow - LastSwitchTime - PassedSwitchTime && SwitchTimeNow - LastSwitchTime - PassedSwitchTime <= 1) - Uncomment if you want to be more specify, use -1/+1 range - */
		if (SwitchTimeNow - LastSwitchTime == PassedSwitchTime)
		{
			sys_log(0, "%s[%d] probably using a switchbot", ch->GetName(), ch->GetAID());
			/* ch->Disconnect("ChangeAttribute"); - Uncomment if you want to kick the player - */
		}
		else
		{
			PassedSwitchTime = SwitchTimeNow - LastSwitchTime;
		}
	}

 
And add this to the end of the event:
 

LastSwitchTime = thecore_pulse();

 
Open game/item.h and add these:
 

		int				PassedSwitchTime;
		int				LastSwitchTime;
		int				SwitchTimeNow;

 
Open game/length.h and add this:
 

	CHECK_SWITCH_TIME		= 5, // Now the function will be active if the user changing the bonuses within 5 seconds

Tip, the thecore_pulse() function is not giving back a time, if you want to check one second then you have to multiply the number with 25. So:
 
5 seconds: 5*25 = 125
5 minutes: 5*60*25 = 7500
 
 
If you have any question or suggestion, please just reply to this topic.
 
Kind Regards,
Sanchez

  • Love 19

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.