New server feature - Event command scripts

Forum Archive - from http://theuniversal.net
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

i woulden't mind seeing a way to set a random resault for something.

being able to do soemthing along the lines of:

Code: Select all

Event("UseItem", "Brown Rock") 
{ 
*command=msg %player% You look at the rock, it has a large crack in it.  you throw it against another rock.

Chance =%75
*command=msg %player% it breaks open and there is nothing of interest.

Chance=%25
*command=msg %player% It breaks open and theres a Diamond inside!
*command=grantitem %player% 1 Diamond
}
would be quite useful for many types of worlds and for many different things.
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

oh nice i like that.


alot
User avatar
Rikku
Posts: 273
Joined: Sat Apr 21, 2007 8:51 pm
Location: World

Post by Rikku »

this a code

Code: Select all

 Event(   "skill", "10"  )
{
*command=setauth %player% 8
*command=grantkudos %player% 10
*command=grantcash %player% 1500
*command=grantitem %player% 1 Vehicle 10
*command=say %player% You are now a Knight Great Job! Relog for your new rank to show up!
*command=grantitem %player% 10 weap 2
*command=grantitem %player% 10 weap 3
}
is the skill 10 thing correct or what is it for a certain skill thing?
User avatar
VDZ
Posts: 1205
Joined: Wed Apr 07, 2004 11:32 am
Location: Netherlands

Post by VDZ »

There is no "skill" event, and there won't ever be that exact event: it needs a condition to react to, a trigger.
"skill" would trigger again and again as long as you have the skill, which can't be what you want.
Instead, we'd need either a Timer event, that triggers once every X seconds/minutes, with a conditional statement checking if you've got the skill, or if you mean when the skill is learned, a SkillLearned event.
The rest of the code is fine, though.
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

as bongz has indicated elsewhere, conditionals, player variables, global server variables, user defined variables, sleep/delays in scripts and various methods for retrieving player data have been aded for the latest servers. Full details will follow in the next update of the world owners manual, but for now, heres an example of the sorta thing you can do..

Code: Select all

//----------------- Server Vars
$kServerCigarCount = 1

//------------------ Script constants
$kSpecialValue = 200
$kCigarSmokeDelay = 30   // Seconds
Event( "UseItem", "Cigars" )
{
	if ( $PlayerTimeVar[1] < $gServerTime )
   {
		$gServerVar[$kServerCigarCount] = $gServerVar[$kServerCigarCount] + 1	
		$playerTimeVar[1] = $gServerTime + $kCigarSmokeDelay
		*say %PLAYER% lights up....
		Sleep(40)           // 1/10ths of a second = 4second delay

		*soundeffect 18
		*effect %PLAYER% 9
		*grantkudos %PLAYER% 1
		*say %PLAYER% smoked a cigar ($gPlayerKudos kudos) - $gServerVar[ $kServerCigarCount ] cigars have been smoked	
   }
	else
	{
		*msg %PLAYER% You can only smoke 1 cigar every $kCigarSmokeDelay seconds
		CancelTransaction()
	}

}
Event( "PlayerLogin", "" )
{
*msg %PLAYER% Welcome, %PLAYER%, to my special place
*msg %PLAYER% $gServerVar[ $kServerCigarCount ] cigars have been smoked here
}
Event( "&command", "help" )
{
*msg %PLAYER% Thank you, %PLAYER%, for trying the &help command. This command is no help.
}
Event( "UseItem", "Test Item" )
{
	*say %PLAYER% produces the jive
	*effect %PLAYER% 10
	*soundeffect 19
	*effect %PLAYER% 1
	Sleep(15)
	*effect %PLAYER% 5
	*effect %PLAYER% 1
	*soundeffect 20
	Sleep(10)
	*effect %PLAYER% 5
	*soundeffect 21
	Sleep(25)
	*effect %PLAYER% 5
}
Oh and theres also a Rand() function, amongst other things :]
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

any chance on getting a variable whos value is input by the player?
User avatar
Jayecifer
Posts: 475
Joined: Tue Apr 10, 2007 11:37 pm
Location: Ames, Iowa
Contact:

Post by Jayecifer »

lol old school q-basic..

CLS
INPUT X%
PRINT X%
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

erm..this isen't old school basic.
we can only use commands that mit PUT in the game
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

Code: Select all

PlayerVars( )
i was told
User avatar
Jayecifer
Posts: 475
Joined: Tue Apr 10, 2007 11:37 pm
Location: Ames, Iowa
Contact:

Post by Jayecifer »

zaroba wrote:erm..this isen't old school basic.
we can only use commands that mit PUT in the game
I know this isn't q-basic.
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

then what does input in basic have to do with the topic or even the question i posted?
User avatar
VDZ
Posts: 1205
Joined: Wed Apr 07, 2004 11:32 am
Location: Netherlands

Post by VDZ »

With a Listen(Text) event, the possiblities would be endless.
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

there are &commands

event ( "&command", "help" )
{
}
User avatar
Jayecifer
Posts: 475
Joined: Tue Apr 10, 2007 11:37 pm
Location: Ames, Iowa
Contact:

Post by Jayecifer »

zaroba wrote:then what does input in basic have to do with the topic or even the question i posted?
Nothing,... I'm just being an unhelpful tard.
Locked