Jump to content
  • 0

(Help) Create @wings command


Myth_

Question


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   2
  • Joined:  11/30/14
  • Last Seen:  

Here's the thing, Im doing a private server with a friend and we don't really know that much about source edition. We were talking about creating a custom command that launchs a script.

 

For example, I have a script in this location: svn/trunk/npc/custom/project/wings.txt

 

Inside the game, at the moment a user types @wings the script mentioned above wich is a dialog script should launch.

 

I know that for some of you guys its a easy thing to do but it isnt for me, thats why im asking for help.

 

If you can explain me how to do it step by step ill be grateful.

 

Thanks in advance.

 

 

 

 

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

time to read doc/script_command.txt.


*bindatcmd "command","<NPC object name>::<event label>"{,<group level>,<group level char>,<log>};

This command will bind a NPC event label to an atcommand. Upon execution 
of the atcommand, the user will invoke the NPC event label. Each atcommand 
is only allowed one binding. If you rebind, it will override the original 
binding. If group level is provided, only users of that group level or 
above will be able to access the command, if not provided, everyone will 
be able to access the command.
"group level char" is the minimum group level required for the label to be 
used on others like a char command would, e.g. "#command "target" params", 
when not provided, "group level char" defaults to 99.
"log" whether to log the usages of this command with the atcommand log 
(1 = log, 0 = no log), default is to not log.

The following variables are set upon execution:
	.@atcmd_command$      =  The name of the @command used.
	.@atcmd_parameters$[] =  Array containing the given parameters,
	                         starting from an index of 0.
	.@atcmd_numparameters =  The number of parameters defined.

Parameters are split on spaces. Multiple spaces aren't grouped together, and
will create multiple (empty) arguments.
Any leading spaces before the first parameter will be omitted.

-	script	atcmd_example	-1,{
OnInit:
	bindatcmd "test",strnpcinfo(3)+"::OnAtcommand";
	end;
OnAtcommand:
	specialeffect2 338;
	end;
}

Parameter splitting example:
	@mycommand
		.@atcmd_numparameters -> 0
		.@atcmd_parameters$   -> { }
	@mycommand<space><space>
		.@atcmd_numparameters -> 0
		.@atcmd_parameters$   -> { }
	@mycommand<space>foo
		.@atcmd_numparameters -> 1
		.@atcmd_parameters$   -> { "foo" }
	@mycommand<space><space>foo
		.@atcmd_numparameters -> 1
		.@atcmd_parameters$   -> { "foo" }
	@mycommand<space>foo<space>bar
		.@atcmd_numparameters -> 2
		.@atcmd_parameters$   -> { "foo", "bar" }
	@mycommand<space>foo<space><space>bar
		.@atcmd_numparameters -> 3
		.@atcmd_parameters$   -> { "foo", "", "bar" }
	@mycommand<space>foo<space>
		.@atcmd_numparameters -> 2
		.@atcmd_parameters$   -> { "foo", "" }
	@mycommand<space>foo<space><space>
		.@atcmd_numparameters -> 3
		.@atcmd_parameters$   -> { "foo", "", "" }

-	script	atcmd_example	-1,{
OnInit:
	bindatcmd "test",strnpcinfo(3)+"::OnAtcommand";
	end;
OnAtcommand:
	// This command expects a character name (that may contain spaces) as
	// the only parameter.
	.@name$ = "";
	for (.@i = 0; .@i < .@atcmd_numparameters; ++.@i) {
		.@name$ += (.@i > 0 ? " " : "") + .@atcmd_parameters$[.@i];
	}
	dispbottom("The specified name is: '" + .@name$ + "'");
	end;
}
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   2
  • Joined:  11/30/14
  • Last Seen:  

That helped, I did what I wanted to. There was no need to make source edition after all.

 

Thanks!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...