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

modifying sm_beacon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lake393
AlliedModders Donor
Join Date: Oct 2008
Old 09-03-2009 , 02:42   modifying sm_beacon
Reply With Quote #1

Hello, I am trying to modify the base plugin sm_beacon to act like accept an additional parameter of 0 or 1 instead of acting like a toggle.

For instance, instead of typing sm_beacon #userid, I want to type sm_beacon #userid 1 to turn it on, and sm_beacon #userid 0 to turn it off.

I am looking in beacon.sp at the Action:Command_Beacon() function.

Can I call CreateBeacon() and KillBeacon() directly from the Command_Beacon() function? I have concerns with what will happen if I call CreateBeacon on a target who already has a beacon, or if I call KillBeacon on a target that does not have a beacon.

Sorry, I really don't know what I'm doing in this language. Any assistance would be greatly appreciated.
lake393 is offline
Flynn
Senior Member
Join Date: Sep 2009
Old 09-04-2009 , 13:34   Re: modifying sm_beacon
Reply With Quote #2

Well, whilst I find it mind-boggingly illogical as to why you could possibly want this, I took the liberty of making the simple modifications to the code to enable this. I don't guarantee it will work.

First, open beacon (make a backup copy!), find and replace PerformBeacon with this...
Code:
PerformBeacon(client, target, bool:set)
{
	if(set)
	{

		if (g_BeaconSerial[target] == 0)
		{
			CreateBeacon(target);
			LogAction(client, target, "\"%L\" set a beacon on \"%L\"", client, target);
		}
	}
	else
	{
		if(g_BeaconSerial[target] != 0)
		{
			KillBeacon(target);
			LogAction(client, target, "\"%L\" removed a beacon on \"%L\"", client, target);
		}
	}
}
And find and replace Command_Beacon with this:
Code:
public Action:Command_Beacon(client, args)
{
	if (args < 2)
	{
		ReplyToCommand(client, "[SM] Usage: sm_beacon <#userid|name> <set>");
		return Plugin_Handled;
	}

	decl String:arg[65];
	decl bool:set;
	
	GetCmdArg(2, arg, sizeof(arg));
	set = StringToInt(arg);

	GetCmdArg(1, arg, sizeof(arg));
	

	decl String:target_name[MAX_TARGET_LENGTH];
	decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
	
	if ((target_count = ProcessTargetString(
			arg,
			client,
			target_list,
			MAXPLAYERS,
			COMMAND_FILTER_ALIVE,
			target_name,
			sizeof(target_name),
			tn_is_ml)) <= 0)
	{
		ReplyToTargetError(client, target_count);
		return Plugin_Handled;
	}
	
	for (new i = 0; i < target_count; i++)
	{
		PerformBeacon(client, target_list[i]);
	}
	
	if (tn_is_ml)
	{
		ShowActivity2(client, "[SM] ", "%t", "Toggled beacon on target", target_name);
	}
	else
	{
		ShowActivity2(client, "[SM] ", "%t", "Toggled beacon on target", "_s", target_name);
	}
	
	return Plugin_Handled;
}
Compile funcommands. It will probably produce a warning about the conversion of an int to a bool, however this is a cheap-hack (which I also can't guarantee will work).

It will now require two arguments. The ID and the boolean operator for on and off.
Flynn is offline
Send a message via MSN to Flynn Send a message via Skype™ to Flynn
ilovelamp
Junior Member
Join Date: Aug 2009
Old 09-04-2009 , 23:12   Re: modifying sm_beacon
Reply With Quote #3

Hehe, I asked him to do it, we're trying to phase out Mani admin on our Jailbreak server, and bonbon's code uses ma_beacon (which has the toggle), and we're trying to port it to SM (which currently doesn't have a boolean toggle).

And it's on a linux box which crashes every time we load ESTools >.>
ilovelamp is offline
lake393
AlliedModders Donor
Join Date: Oct 2008
Old 09-04-2009 , 23:15   Re: modifying sm_beacon
Reply With Quote #4

wow thanks flynn! We will check this out right away!!!
lake393 is offline
Flynn
Senior Member
Join Date: Sep 2009
Old 09-05-2009 , 00:12   Re: modifying sm_beacon
Reply With Quote #5

I hope it works out. If it doesn't, report the fault as best as you can and I'll try to fix it. The more information I have to work with, the better I do something.
Flynn is offline
Send a message via MSN to Flynn Send a message via Skype™ to Flynn
lake393
AlliedModders Donor
Join Date: Oct 2008
Old 09-05-2009 , 02:05   Re: modifying sm_beacon
Reply With Quote #6

Flynn, there was an error error 092: number of arguments does not match the definition. I believe I know what the problem is, but I am confused a bit.

This section:
PHP Code:
public Action:Command_Beacon(clientargs)
{
    if (
args 2)
    {
        
ReplyToCommand(client"[SM] Usage: sm_beacon <#userid|name> <set>");
        return 
Plugin_Handled;
    } 
This is the last time the variable args is used. It is never used again.

I think I need to use it for this somehow:

PHP Code:
    for (new 0target_counti++)
    {
        
PerformBeacon(clienttarget_list[i]);
    } 
Doesn't it need to pass a third parameter, like args[1] ?

Thank you for deciding to help us

Also, would it be advisable to take all the menu functions out of this? We won't need them for this purpose, but I don't want to break anything if they are needed.
lake393 is offline
Flynn
Senior Member
Join Date: Sep 2009
Old 09-05-2009 , 02:44   Re: modifying sm_beacon
Reply With Quote #7

No, the number of arguments is the incorrect number of arguments being passed, not 'args' (which is just a variable called args and isn't actually 'arguments' per se).

Replace Command_Beacon with this and recompile.
Code:
public Action:Command_Beacon(client, args)
{
	if (args < 2)
	{
		ReplyToCommand(client, "[SM] Usage: sm_beacon <#userid|name> <set>");
		return Plugin_Handled;
	}

	decl String:arg[65];
	decl bool:set;
	
	GetCmdArg(2, arg, sizeof(arg));
	set = StringToInt(arg);

	GetCmdArg(1, arg, sizeof(arg));
	

	decl String:target_name[MAX_TARGET_LENGTH];
	decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
	
	if ((target_count = ProcessTargetString(
			arg,
			client,
			target_list,
			MAXPLAYERS,
			COMMAND_FILTER_ALIVE,
			target_name,
			sizeof(target_name),
			tn_is_ml)) <= 0)
	{
		ReplyToTargetError(client, target_count);
		return Plugin_Handled;
	}
	
	for (new i = 0; i < target_count; i++)
	{
		PerformBeacon(client, target_list[i], set);
	}
	
	if (tn_is_ml)
	{
		ShowActivity2(client, "[SM] ", "%t", "Toggled beacon on target", target_name);
	}
	else
	{
		ShowActivity2(client, "[SM] ", "%t", "Toggled beacon on target", "_s", target_name);
	}
	
	return Plugin_Handled;
}
Helps if I actually make use of the updated function.
Flynn is offline
Send a message via MSN to Flynn Send a message via Skype™ to Flynn
lake393
AlliedModders Donor
Join Date: Oct 2008
Old 09-23-2009 , 00:10   Re: modifying sm_beacon
Reply With Quote #8

Hi Flynn, sorry about the late reply. These are the error's we're getting with the code now. I see some errors relating to the menu. its ok with us if we just get rid of the menu all together if that's possible.

Thanks!

lake393 is offline
Flynn
Senior Member
Join Date: Sep 2009
Old 09-23-2009 , 00:56   Re: modifying sm_beacon
Reply With Quote #9

Quote:
Originally Posted by lake393 View Post
Hi Flynn, sorry about the late reply. These are the error's we're getting with the code now. I see some errors relating to the menu. its ok with us if we just get rid of the menu all together if that's possible.
You're compiling beacon.sp. You need to Compile funcommands.sp (which incorporates beacon.sp into it).
Flynn is offline
Send a message via MSN to Flynn Send a message via Skype™ to Flynn
lake393
AlliedModders Donor
Join Date: Oct 2008
Old 10-06-2009 , 20:03   Re: modifying sm_beacon
Reply With Quote #10

Hello, we just tried compiling funcommands and it complained about this:

Error on line 193 ... number of arguments does not match

Code:
PerformBeacon(param1, target);
This is under the MenuHandler_Beacon function



Also, this line (217) has a minor error that says Tag Missmatch

Code:
set = StringToInt(arg);
lake393 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 13:03.


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