Page 1 of 3

New server feature - Event command scripts

Posted: Sun Apr 01, 2007 9:28 pm
by Mit
Hia.. Heres a nice new toy that should become quite a powerful tool for serious world owners. In the 0.50.6 servers you'll be able to add a file called Data/ServerGameScript.mts - a text file like the 'GameScript.mts' that can contain commands and 'events'. heres an example of one..

Code: Select all

Event( "NewBuilding", "3" )
{
*command=say %PLAYER% built building 3
*command=grantcash %PLAYER% 400
}
Event( "UseItem", "KudosItem1" )
{
*command=say %PLAYER% used the kudos item
*command=grantkudos %PLAYER% 1
*command=resetpos %PLAYER%
}
This file defines 2 events. In the example above, whenever a player ('Mit' for instance) builds building type 3, the commands within { } braces are executed.
i.e.
*say Mit built building 3
*grantcash Mit 400

would be entered - the say message will appear in red for all players and 'Mit' will get an extra 40s. Similar procedure for the other event should someone use the kudos item.
Hopefully should be fairly straightforward to get..

With all the different * commands available i reckon it could allow some useful effects and novel gameplay features.

More event types (other than just 'UseItem' and 'NewBuilding' ) can/will be added.. feel free to pop ideas/requests/questions on this thread as im sure you'll be able to think of some interesting possibilities.
Longer term i'll also look at adding some conditional operations (so bits of script can only be run when certain other conditions have been met) and some persistent variable storage (so for instance, you can have a flag to indicate whether the player has already achieved a particular award).

Posted: Sun Apr 01, 2007 10:41 pm
by morbydvisns
:) been waiting for this

Code: Select all

Event( "MonthDate", "1" )
{
*command=whatever
}

Event( "Gamedate", "December 25" )
{
*command=say MERRY CHRISTMAS
}
the first would run said command every gamemonth on that set date

the 2nd one is obvious

Posted: Mon Apr 02, 2007 2:00 am
by zaroba
thats freakin awesome!

useing the item/command type thing, it should be possible to get all those extra things to work. like the resetpos item, flogging stick, etc. plus could easily rename other things for other commands. not to mention it vastly increases the options for items on a world for food, materials, etc :)

but...hmm...when 'used' will the item diseapear?
or will that still depend on the items design?

Posted: Mon Apr 02, 2007 2:50 am
by morbydvisns
i image it would work like a kudos item does as it is anyway.. whether not the system uses it and anything is gaind, if its used, its gone.
would using a food type item trigger such an event, is what id like to know.

some example script ideas:

Code: Select all

Event("killcount","25")
{
*comamnd=grantkudos %player% 1
}    (executes when player makes x kills)

Event ("deathcount","25")
{
*command=grantkudos %player% -1
}   (opposit of previous)

Event ("playerkill")  
{
*command=grantcash %player% 50
*command=grantkudos %player% 1
}  (executes when %player% kills another player)

Event ("playerdeath")
{
*command=grantcash %player% -50
*command=grantkudos %player% -1
}       (executes when %player% dies)

Event ("buildingdestroy","15")
*command=grantkudos %player% 1
} (when %player% destroyes building 15, executes script.   a 0 would apply to 'any building')

Event ("buildingdecay","15")
{
*command= say %player% has let his %buildingname% go to waste!
}  (executes when %player% building has decayed to destruction, %buildingdesc% would be building description as in bdat(or possibly on planet use %buildingname%))  use "0" for any building.

Event ("startcapture","74")
{
*command=say WAKE UP, TEAM 213!  %Player% HAS STARTED TO CAPTURE YOUR NUKE LAB!
} (executed on capture start, 74 being the building number in bdat.    use 0 for 'any building to exectue script'  %buildingname% or %buildingdesc% could also pull the bdat 'description' (or name of the building on planet)

Event ("buildingcapture","74")
{
*command=say Well what are you going to do now? %player% now has your nuke building! 
*command=Grantcash %player% 50000
*command=grantitem %player% 1 beer
} (executed on capture successfull, 74 being the building number in bdat.    use 0 for 'any building to exectue script' again, %buildingname% or %buildingdesc% for more generic messages)
 
Event ("buildingpurchase","30")
{
*command=say %Player% has purchased the Startersville Plinth
*command=*knight %player%
} (same building scenarios as above)
is there any way to get a command to grant all players that are members of a certain
team cash and items and such?

and a command to demolish any of a certain building # (Bdat building #) currently standing

umm a little thought and i could kick up some more.

*edit* cleaned up with a code box, and used examples as examples on if i were to use them on my planet.

Posted: Mon Apr 02, 2007 7:05 am
by VDZ

Code: Select all

Event( "Listen", "test" ) 
{ 
*command=say Hello there, %player%.
} 
That would be really useful, as you could have customized commands using scripts.

Posted: Mon Apr 02, 2007 11:17 am
by zaroba
that could work for making a new player help file script.

Posted: Mon Apr 02, 2007 2:15 pm
by VDZ

Code: Select all

Event( "Buildingclick", 2) //Click Tractor Factory
{
*command=setvehicle %player% 2 //set to Tractor
}
This would be especially useful for making NPCs (click them, and they say something).
To do that, this would be useful as well:

Code: Select all

*msg VDZ 1 Hello, I'm an NPC.
This would display the text "Hello, I'm an NPC." for VDZ only, in the color assigned to #1.
It would be useful if *say would have multiple colors, too.

Posted: Mon Apr 02, 2007 6:11 pm
by VDZ

Code: Select all

*Textbox VDZ test.txt
This would make a small window pop up on VDZ's client, with the contents of test.txt.
This could be useful for several things, such as:

Code: Select all

Event( "Listen", "help me" )
{
*command=textbox %player% newbie.txt //Send newbie help
}

Posted: Mon Apr 02, 2007 7:44 pm
by Magicfinger
zaroba wrote: but...hmm...when 'used' will the item diseapear?
or will that still depend on the items design?

Code: Select all

Event( "UseItem", "KudosItem1" )
{
*command=say %PLAYER% used the kudos item
*command=grantkudos %PLAYER% 1
*command=grantitem %PLAYER% -1 KudosItem1
*command=resetpos %PLAYER%
}
wouldn't that do what you wanted?

Posted: Mon Apr 02, 2007 9:36 pm
by Mit
as bongz correctly surmised.. the useitem event will be called when the player manually selects to use one of those items that work that way.. e.g. kudos items and anything else not food, a vehicle or a weapon. the items do get automatically removed in that case, so the script above would remove 2 items everytime u used one. not what's wanted probably, but still a valid script to use, aye..

lotsa nice script command suggestions.. particularly useful when they're in those little code boxes which provides a nice example use. :] will try to get some of em done before the new server goes up..

Posted: Tue Apr 03, 2007 12:40 am
by morbydvisns

Code: Select all

Event("itemcount", "Hemp Seeds,50,","OncePerLife" )
{
*command=grantskill %player% Colony Research
} 

Event("itemcount","Hemp Amulet,25","Holy Orb,3","OncePerLife")
{
*comamnd=grantitem %player% 1 Bongo's Blessing
}


itemcount event would requre an item, and amnt definer. This applies to item count in player inventory at that time. OncePerLife is an example of a needed way for this event to only happen once per players lifetime. (until a wipe / reset / whatever, regard;ess of 'lives' defined in *settings. This would both keep multiple grantskills that may remove a skill not intending to. also for abusers that may buidl a certain bldg or trigger over n over for cash and other prizes that my be only really meant for a one time thing.

the second demonstrates the ability to add multiple item requirements to in inventory to trigger the event.

i could cut out a few buildings with this XD

Posted: Tue Apr 03, 2007 2:18 am
by zaroba

Code: Select all

Event "*QuaryProperties" %item%
*msg %player% %item properties% (weight, max capacity if set, item type, hunger/thirst amount, etc)

Event "*QuaryScript" %item%
*msg %player% %Item Properties% (show any script effects associated with the item)
both of the above could be used in conjunction with a highlighted item to show the properties or script effect of the item.

of course, actual commands could be added for those, but, similer things could be used to 'make' new shortcut commands to do things.

like:

Code: Select all

Event= "*2"
Command="*setvehicle %player% vehicle 2"

Event= "*worldreset"
AuthReq="24"
Command="*Killbillall"
Command="*resetmap"
FileDelete="data/families.dat"
FileDelete="data/banking.dat"
FileDelete="data/towns/*.*"
FileDelete="data/mail/*.*"
the ability to link a script action with an auth level would be nice aswell.

Posted: Tue Apr 03, 2007 3:56 am
by morbydvisns
i like the listen events above.. and the requirements to execute would be a nice control.... along with an authreq, might as well throw a few more possibilities in....

Code: Select all

Event("listen","Ask For Blessing")
{
SkillReq="Colony Advancement"
ItemReq="Hemp Amulet,25","Holy Orb,3"  (((MUST BE IN INVENTORY)))
VehicleReq="7"              (((MUST BE IN VEH. 7)))
*command=%Player% has obtained 1 Bongo's Blessing (Kudo)
*command=Grantkudo %Player% 1
}

---other requirement strings of use---
MinKudos=
MaxKudos=
MaxKills=
MinKills=
MaxDeaths=
MinDeaths=
MinCash=
MaxCash=
VehicleReq=
TeamReq=

if an attempt to execute an event is made but a requirement isnt met a generic 'you do not have proper skill, items, not in proper vehicle, etc etc displayed on client end.

of course then theres the route of bringing if/thens into the equasion :wink:

Posted: Tue Apr 03, 2007 5:32 am
by VDZ
Yes, we would need conditional events for that.

Code: Select all

Event("listen","Ask For Blessing")
{
if (SkillPossessed("Colony Advancement") && ItemCount("Hemp Amulet") > 25 && ItemCount("Holy Orb") > 3 && CurrentVehicle=7)
 {
 *command=say %Player% has obtained 1 Bongo's Blessing (Kudo)
 *command=Grantkudo %Player% 1
 }
}

Posted: Tue Apr 03, 2007 12:17 pm
by Mit
lil extra update :
i've added the command..

Code: Select all

*msg <NAME> <TEXT>
and the event..

Code: Select all

Event ("buildingpurchase","30") 
{ 
...
}
as they'll be particularly useful (and were easy to add :])

Also.. on checking the inventory code i realised that currently the only items that you can actually 'use' are the Kudos Items, End Sequence Items and the demolition kit.. which isnt much use. Soo, rather than making all items 'usable' (which would have bandwidth implications for the general items that, currently, arent expected to be used that way), i've added 32 new 'Usable' items. These can be traded and sold as normal, but have the additional 'Use Item' option when selected from the inventory. (The selection screen for which has also been fixed up).
In addition, if you're not using hunger and thirst (i.e. *settings -> Life -> Hunger and thirst = 0 ) then any food or drink items also have the 'use item' option.

Posted: Tue Apr 03, 2007 6:23 pm
by Magicfinger
thought we would celebrate with a new style code block :)

Posted: Tue Apr 03, 2007 8:41 pm
by Mit
oooh eek nooo! :] can i have the old one back please? :]

Posted: Wed Apr 04, 2007 1:57 am
by zaroba
what about an event that will say a message to a player when they login?
that could be useful for many things. like world news/notices, help info, world info, etc.

Posted: Wed Apr 04, 2007 2:52 am
by morbydvisns
mit, on those 'usable items' youve added... can those be made to where a script can require certain amnts of those on hand, if the others arent?

Posted: Wed Apr 04, 2007 10:48 am
by Mit
not yet..
Longer term i'll also look at adding some conditional operations
;] Dont expect that sorta stuff for a month or three..