Noobish questions, mostly about scripting
Ah um, you've been able to edit items for ages.. method is just a bit clunky and was supposed to be replaced by a world ed UI which i haven't finished yet. (That's probably why you don't know about it). Meanwhile..
Advanced nutrition isn't used anywhere yet. The main values for the 'UseVal' for *setitemuse are:
manually override the buttons you want to using:
Valid [OPTION_NUM]s right now are :
1- F9 option on the mini menu
2 - 1st option on the player popup menu (replaces barter)
3 - 2nd option on the player popup menu (replaces challenge)
4 - 3rd option on the player popup menu
5 - 4th option on the player popup menu
(more to follow..)
e.g. Doing
Means that when you click a player's name, instead of "Barter with" being the top option, "Attack" is instead. When selected by the user, the server triggers a MenuOption event instead of the Barter one. e.g.
Code: Select all
*setitemuse ItemName,[UseVal][|Size]
*setitemnutrition ItemName,[Primary]|[Health]|[MaxHealth]
*setitemadvancednutrition ItemName,[Val1]|[Val2]|...|[Val6]
Code: Select all
0 - None
1 - Food
2 - Drink
3 - Misc
12 - Scripted
13 - Combination
Just for reference, the 0.63.3 process is:You can now add custom named options to the main menu displays, and override each of the buttons in the player popup display, all of which trigger a 'MenuOption' event which your script can do what it likes with.
manually override the buttons you want to using:
Code: Select all
*scriptedoption [OPTION_NUM],[TEXT]
1- F9 option on the mini menu
2 - 1st option on the player popup menu (replaces barter)
3 - 2nd option on the player popup menu (replaces challenge)
4 - 3rd option on the player popup menu
5 - 4th option on the player popup menu
(more to follow..)
e.g. Doing
Code: Select all
*scriptoption 2,Attack
Code: Select all
Event( "MenuOption", "2" )
{
*msg %PLAYER% You selected option 1 on player %TARGET%
}
Last edited by Mit on Sat Oct 06, 2012 10:04 pm, edited 1 time in total.
- flametard
- Posts: 1245
- Joined: Sun Apr 01, 2007 2:05 am
- Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
- Contact:

so just to be noobish,
the designation %target% will apply even in the event script thats triggered after the barterrequest?
ANSWER
CUSTOM EVENTS REMEMBER WHO THE TARGET IS!!
Code: Select all
Event( "Custom", "sayhi" )
{
SetContext( $gTargetID )
CustomEvent("hi")
RestoreContext()
sleep (1)
CustomEvent("hello")
}
Event( "Custom", "hi" )
{
*msg %player% HI %player%!!!
}
Event( "Custom", "hello" )
{
*msg %player% youre saying hi to %target%
*msg %target% %player% said hi to you
}
Last edited by flametard on Fri Feb 08, 2013 2:38 am, edited 1 time in total.
- MasterNiCron
- Posts: 582
- Joined: Wed Feb 17, 2010 10:57 pm
- Location: Frost
how would target verables work then any thing like this??
---------------------------------------------------
or is this not evan close?
---------------------------------------------------
Code: Select all
Event( "MenuOption", "2" )
{
IF (%TARGET% PLAYERVAR[#] = #)
{
someting here
}
ELSE
{
something else here
}
}
We're in to quite 'Intermediate level' territory here now 
Firstly, the target variables will only apply within the event (and any events/functions called from it).. each event has a different 'context' - so, for instance, when you access a building the $gBuildingID field is valid, but in other cases (like a & command for instance) theres no building involved so the field wouldn't be relevant... $gTargetID (and %TARGET%) are relevant in events like those menu selections and other things like 'RobocrowKill'. etc.
%TARGET% (like %PLAYER%) is just a quick way of doing :
though theres nothing wrong with that either.
To get details of the target's playerVars (for instance), you need to get to grips with 'SetContext' and 'RestoreContext'. Setting the context allows you to choose who the 'current player' is. For example :
There are various ways you could keep the target player's info around for later events - you could save it in a playerVar, or pass it as a param via events, timers and osd buttons.
Heres a quick example of a targetted MenuOption event that brings up an OSD with a param to pass in a targetID when the button is pressed.
Keep those questions coming.. this'll be a handy thread to know what sorta questions other folks will have and will help form better documentation when its all written up.

Firstly, the target variables will only apply within the event (and any events/functions called from it).. each event has a different 'context' - so, for instance, when you access a building the $gBuildingID field is valid, but in other cases (like a & command for instance) theres no building involved so the field wouldn't be relevant... $gTargetID (and %TARGET%) are relevant in events like those menu selections and other things like 'RobocrowKill'. etc.
%TARGET% (like %PLAYER%) is just a quick way of doing :
Code: Select all
$targetName = sysGetPlayerName( $gTargetID )
To get details of the target's playerVars (for instance), you need to get to grips with 'SetContext' and 'RestoreContext'. Setting the context allows you to choose who the 'current player' is. For example :
Code: Select all
$myKudos = $gPlayerKudos
SetContext( $gTargetID )
$targetKudos = $gPlayerKudos
RestoreContext()
*msg %PLAYER% Your kudos is $myKudos. %TARGET%'s kudos is $targetKudos
Heres a quick example of a targetted MenuOption event that brings up an OSD with a param to pass in a targetID when the button is pressed.
Code: Select all
Event( "MenuOption", "2" )
{
OSDCreate( OSDWINDOW, "TargetOSD", "Challenge %TARGET%" )
OSDAddItem( OSDBUTTON, "Button|$gTargetID", "Press here to challenge %TARGET%" )
OSDActivate()
}
Event( "OSDSelect", "TargetOSD:Button" )
{
$paramTargetID = $gParam[1]
$targetName = sysGetPlayerName( $paramTargetID )
*msg %PLAYER% You selected to challenge $targetName
}
Last edited by Mit on Sun Oct 07, 2012 1:20 am, edited 1 time in total.
- flametard
- Posts: 1245
- Joined: Sun Apr 01, 2007 2:05 am
- Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
- Contact:
back to a noobish question:
I tried to add more stuff like:
I'm running all my programs, notepad, buildings editor, Server, Client, as administrator and on the latest patches and I don't understand why things arent working. Weridly, one of my old building trigger scripts still works, and I copied the exact script to another building in the script and no script popped up. So i know my scripts are working, the new trigger buildings just arent reading them for some reason.
HELP!!
I tried to add more stuff like:
(i've tried all sorts of stuff and nothing works, so i've fallen back to test script)Event( "AccessBuilding", "40" )
{
*msg %player% A castle belonging to %buildingowner%.
}
I'm running all my programs, notepad, buildings editor, Server, Client, as administrator and on the latest patches and I don't understand why things arent working. Weridly, one of my old building trigger scripts still works, and I copied the exact script to another building in the script and no script popped up. So i know my scripts are working, the new trigger buildings just arent reading them for some reason.
HELP!!

- MasterNiCron
- Posts: 582
- Joined: Wed Feb 17, 2010 10:57 pm
- Location: Frost
ok being that did not anser the question let me refraze it
im makeing a player 2 player battle script and dont know how to compare %player% playervar to the %target% playervar such as.
im makeing a player 2 player battle script and dont know how to compare %player% playervar to the %target% playervar such as.
Code: Select all
EVENT("MenuOption", "2")
{
IF ([[%player%]] $gplayervar[1] > [[%target%]] $gplayervar[1])
{
DO THIS
}
ELSE
{
DO THIS
}
}
Last edited by MasterNiCron on Sun Oct 07, 2012 6:17 pm, edited 1 time in total.
forget about %TARGET% and stuff in statements like that.. they're just for getting the name text for commands like '*say The Winner was %TARGET%'
To do the stuff you want you need to use SetContext, as described above.
Or to re-do your example :
To do the stuff you want you need to use SetContext, as described above.
Or to re-do your example :
Code: Select all
Event( "MenuOption", "2" )
{
// Get the player's var 1
$myVar = $gPlayerVar[1]
// Get the target's var 1
SetContext( $gTargetID )
$targetVar = $gPlayerVar[1]
RestoreContext()
if ( $myVar > $targetVar )
{
DO THIS
}
else
{
DO THIS
}
}
- MasterNiCron
- Posts: 582
- Joined: Wed Feb 17, 2010 10:57 pm
- Location: Frost
- MasterNiCron
- Posts: 582
- Joined: Wed Feb 17, 2010 10:57 pm
- Location: Frost
- MasterNiCron
- Posts: 582
- Joined: Wed Feb 17, 2010 10:57 pm
- Location: Frost