Page 2 of 2

Posted: Fri Sep 07, 2012 5:10 pm
by Mit
ah sorry yes.. *send was the one i meant.

Posted: Fri Sep 07, 2012 5:47 pm
by MasterNiCron
ok as for (1) and (2) i dont get how to set a playerver is the main problum i know its probly what ur showing me but i just dont understand it. i get what thay do and how to use them just not how to wright them to set them up

(3) thanks thats what i needed

(4) i asked becase when i activate the building wile moveing any it pops up my osdlist and a osdbuilding access osd as well.

Posted: Fri Sep 07, 2012 9:59 pm
by Mit
You can set them in script.. e.g.

Code: Select all

$gPlayerVar[1] = 10
and (generally for debug purposes) you can set them by command, e.g.

Code: Select all

*setplayervar Mit 1 10
Everyone's playerVars start at 0 until you've done one of those commands on them.

(For completeness you've also got *resetplayervars [name] and *resetallplayervars)

Posted: Fri Sep 07, 2012 10:36 pm
by MasterNiCron
thanks i get it :P

Posted: Sat Sep 08, 2012 3:56 pm
by MasterNiCron
well i thought i had it. but cant get it to work right. i can get the ( if ) part to work even duse the osd slect part but not the ( else ) part. what am i doing wrong?

trying to use playver 1 for building 1

Code: Select all

Event( "AccessBuilding", "1" )  
 { 
  $nextValidAccess = $gPlayerVar [1] 
  if ( $gPlayerNumDeaths >= $nextValidAccess ) 
   { 
    osdcreate(OSDLIST, "FOR TESTING", "Blah" )
    osdadditem(OSDBUTTON, "FT1", "blah blah" )
    osdactivate()
   } 
  else 
   {
    osdcreate(OSDLIST, "BLAH", "IT WORKED" )
    osdadditem(OSDEXITBUTTON, "EXIT", "OK" )
    osdactivate()
   } 
 }

EVENT(OSDSELECT, "FOR TESTING:FT1")
  {
   $gPlayerVar [1] = $gPlayerDeaths + 1
   osdcreate(OSDLIST, "just a list", "TEST" )
    osdadditem(OSDEXITBUTTON, "EXIT", "OK" )
    osdactivate()
  }

Posted: Sat Sep 08, 2012 7:13 pm
by Mit
you can't have a space between the playerVar and the [1].. needs to be all one word to identify which variable it is. Because it doesn't recognise the var, $nextValidAccess will always be 0.

Im not sure if you can have spaces in the name of an OSDCreate item (So 'FOR TESTING' might need changing).

Other than that tho, should work fine.

Posted: Mon Sep 10, 2012 4:18 pm
by MasterNiCron
how do i make it so a building sees if u got anuff of a item. i thought it was this but it dont seem to work. what did i do wrong???

Code: Select all

Event("AccessBuilding", "4")
 {
  if (Playerinventory gold >= 3)
  {
    osdcreate(OSD......if u do have anuff gold add osd for it here
  }
 else
  {
    osdcreate(osd......other wis add the osd for not haveing anuff here
  }
 }
it runs the if osd evan if i dont have the needed item

Posted: Mon Sep 10, 2012 5:38 pm
by morbydvisns
$goldCount = sysPlayerInventory("Gold")

if ($goldCount > 3)
{
}

Posted: Mon Sep 10, 2012 9:45 pm
by MasterNiCron
thanks now my first quest is done :)
now to quest 2 :P

Posted: Wed Sep 12, 2012 2:36 pm
by MasterNiCron
how can i make this work??

Code: Select all

Event("AccessBuilding", "5")
 {
  osdcreate(osdlist, "equipment", "Goods")
  osdadditem(OSDMINHEIGHT, "",450)
  osdadditem(OSDBIGTEXT, "", "click the item you want to buy.")
   {  
    $silverCount = sysPlayerInventory("silver coins")
    if ($silverCount >= 1)
     {
      osdaddat(OSDIMAGE, 5, 5, 50, 50, "buy sword", "image site here")
     }
    else
     {
      osdaddat(OSDFADDEDIMAGE, 5, 5, 50, 50, "", "image site here")
     }
   }
 THEN 
   {
    IF ($silverCount >= 3)
     {
      osdaddat(OSDIMAGE, 60, 60, 50, 50, "buy armer", "image site here")
     }
    else
     {
      osdaddat(OSDFADDEDIMAGE, 60, 60, 50, 50, "", "image site here")
     }
   }
  osdactivate()
 }

Posted: Wed Sep 12, 2012 5:12 pm
by zaroba
That one is a little tricky, and it kinda depends on what exactly you want to do with it.
For starters:
-move the $silverCount = sysPlayerInventory("silver coins") to the top, above the osd create line.
-remove the one { that's right above the first if statement
-the THEN part can be deleted as well.
-purely optional, but instead of doing ($silverCount >= 3), you could do ($silverCount > 2). then it would count for 3 or higher. it does the same but is one less character to type.


Now, this is where it depends on what exactly your trying to do and I may be a bit complex in my attempt to describe :p

If you want to provide one option *or* the other, then move the if ($silverCount >= 3) to above the ($silverCount >= 1) so it will provide that option instead of the one for 1 coin if the player has enough. The else statement could have to be changed to an 'IF' statement to display if the player has no coins. the 2nd else could be changed to another IF statement to display if the player has less then 3, or deleted completely.


I'm guessing you'd rather have both options though, so you could do this:

Code: Select all

Event("AccessBuilding", "5")
	{
	$silverCount = sysPlayerInventory("silver coins")
	osdcreate(osdlist, "equipment", "Goods")
	osdadditem(OSDMINHEIGHT, "",450)
	osdadditem(OSDBIGTEXT, "", "click the item you want to buy.")
	if ($silverCount > 0)
		{
		osdaddat(OSDIMAGE, 5, 5, 50, 50, "buy sword", "image site here")
		}
	if ($silverCount < 1)
		{
		osdaddat(OSDFADDEDIMAGE, 5, 5, 50, 50, "", "image site here")
		}
	if ($silverCount > 2)
		{
		osdaddat(OSDIMAGE, 60, 60, 50, 50, "buy armor", "image site here")
		}
	if ($silverCount < 3)
		{
		osdaddat(OSDFADDEDIMAGE, 60, 60, 50, 50, "", "image site here")
		}
	osdactivate()
	}
The 1st item will display any time the player has more then 0 coins.
The 2nd IF will display if the player only has 0 coins.
The 3rd IF will display anytime a player has 3 or more coins.
The 4th IF will display anytime the player has 0, 1, or 2 coins.



Image

Posted: Wed Sep 12, 2012 9:54 pm
by MasterNiCron
thanks thast great :)

Posted: Thu Sep 13, 2012 12:37 am
by MasterNiCron
my combat scrip dont work what i do wrong this time?
also is there a way to trigger this by killing a wildife

Code: Select all

EVENT("accessbuilding", "5")
 {
  $gPlayerVar[20] = rand 5
  $swordCount = sysPlayerInventory("sword")
  if ($swordCount >= 1)
  {
   $gPlayerVar[20] + 15
  }
  $armorCount = sysPlayerInventory("armor")
  if ($armorCount >= 1)
  {
   $gplayerver[20] + 5
  }
 if ($gplayerver[20] = 25 )
  {
   *msg %player% !!PERFICT HIT!!
  }
 if ($gplayerver[20] >= 20 )
  {
   *msg %player% !!20 and up!!
  }
 if ($gplayerver[20] >= 15 )
  {
   *msg %player% !!15 and up!!
  }
 if ($gplayerver[20] >= 10 )
  {
   *msg %player% !!10 and up!!
  }
 if ($gplayerver[20] >= 5 )
  {
   *msg %player% !!5 and up!!
  }
 if ($gplayerver[20] < 5 )
  {
   *msg %player% !!not evan 5!!
  }
 }

Posted: Thu Sep 13, 2012 2:16 am
by zaroba
My best guess is that the script is stopping after finishing the first IF statement.
It might also be due to the playervar20+# lines. Mit would have to confirm whether or not that works by itself or if it actually has to be playervar20=playervar20+#

Anyway, this might not be the cleanest solution, but it should work:

Code: Select all

EVENT("accessbuilding", "5")
	{
	$gPlayerVar[20] = rand 5
	$swordCount = sysPlayerInventory("sword")
	$armorCount = sysPlayerInventory("armor")
	if ($swordCount >= 1)
		{
		$gPlayerVar[20] = $gPlayerVar[20] + 15
		if ($armorCount >= 1)
			{
			$gPlayerVar[20] = $gPlayerVar[20] + 5
			CustomEvent( "building5" )
			}
		else
			{
			CustomEvent( "building5" )
			}
		}
	else
		{
		*msg %player% You need a sword!
		}
	}

Event("Custom","building5")
	{
	if ($gplayerver[20] = 25 )
		{
		*msg %player% !!PERFICT HIT!!
		}
	else if ($gplayerver[20] >= 20 )
		{
		*msg %player% !!20 and up!!
		}
	else if ($gplayerver[20] >= 15 )
		{
		*msg %player% !!15 and up!!
		}
	else if ($gplayerver[20] >= 10 )
		{
		*msg %player% !!10 and up!!
		}
	else if ($gplayerver[20] >= 5 )
		{
		*msg %player% !!5 and up!!
		}
	else
		{
		*msg %player% !!not evan 5!!
		}
	}
it uses a custom event type is to avoid having to put the stuff in it twice in the top script (once for sword only, once for sword + armor)

The initial script checks for and sets the sword var, if a player has no armor, it activates the 2nd script. If a player has armor, then it sets that var and then activates the 2nd script.

Up to you if you want it in there, but I added an 'else' in the top to tell a player they need no sword if they try and run the script without one.

Posted: Thu Sep 13, 2012 2:14 pm
by XmAkInA
zaroba wrote:It might also be due to the playervar20+# lines. Mit would have to confirm whether or not that works by itself or if it actually has to be playervar20=playervar20+#
http://theuniversal.net/worldmanual/dok ... sic_syntax already has your answer:
Basic maths operators are supported in simple form. Compound operations are not yet supported so each line needs to be kept basic, e.g. :

Code: Select all

     $var = $var + 1
     $newvar = $var * 100
Besides, even in C you'd need to use += rather than just +

Posted: Thu Sep 13, 2012 5:52 pm
by morbydvisns
I think I've ran across this before.. try $playervar# = # + $playervar#

Posted: Fri Sep 14, 2012 12:36 am
by MasterNiCron
i got it to work with this. also the comand ( rand 5 ) dont get a random # between 1 and 5 any clue y??

Code: Select all

EVENT("accessbuilding", "5")
 {
  $gPlayerVar[20] = rand 5
  $swordCount = sysPlayerInventory("sword")
  $armorCount = sysPlayerInventory("armor")
  if ($swordCount >= 1)
   {
    if ($armorCount >= 1)
     {
      CustomEvent( "battle4" )
     }
    else
     {
      CustomEvent( "battle2" )
     }
   }
  else if ($armorCount >= 1)
   {
    if ($swordCount >= 1)
     {
      CustomEvent( "battle4" )
     }
    else
     {
      CustomEvent( "battle3" )
     }
   }
  else
   {
    CustomEvent( "battle1" )
   }
 }


Event("Custom","battle1")
 {
  if ($gplayervar[20] >= 3 )
   {
    *msg %player% !!WIN!!
   }
  else
   {
    *msg %player% lose
   }
 }

Posted: Fri Sep 14, 2012 1:16 am
by zaroba
fixed via chatting ingame.


for others that may read. the problem was the rand and var in the 2nd part.
rand 5 needed to be changed to sysrand(5)

and in the 2nd part, $gplayerver[20] needed to be changed to gplayervar[20], since that is what rand was setting, and because it's a programmed in variable which is needed to go across events. The prior one isn't programmed in so gets erased at the end of the event its being used in.

Posted: Fri Sep 28, 2012 11:14 pm
by MasterNiCron
my random script dont work right
it runs the customevent more than 1 time makeing it have more than 1 osd popup
y it not working right??



Code: Select all

EVENT("playerlogin", "")
 {
  sleep(300)
  CustomEvent( "Random1" )
 }
-----------------------------------------------------
EVENT("Custom", "Random1")
 {
  $IT = sysrand(3) 
  if ($IT = 1)
   {
    OSD here
   }
  else if ($IT = 2)
   {
    OSD here
   }
 else
   {
    OSD here
   }
 }
---------------------------------------------------------------
Event("OSDSELECT", "Pyron Incounter:1")
 {
  CustomEvent("combat")
  sleep(10)
  CustomEvent( "Random1" )
 }
-----------------------------------------------------------------
Event("OSDSELECT", "Pyron Incounter:2")
 {
  sleep(11)
  CustomEvent( "Random1" )
 }