Noobish questions, mostly about scripting

Forum Archive - from http://theuniversal.net
User avatar
flametard
Posts: 1245
Joined: Sun Apr 01, 2007 2:05 am
Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
Contact:

Post by flametard »

Question: can I make a gatehouse that "opens" and "closes" via script the same way different models are used in conjunction with buildingvar when buildings are in the various stages of construction on chapter 3?
User avatar
flametard
Posts: 1245
Joined: Sun Apr 01, 2007 2:05 am
Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
Contact:

Post by flametard »

Question:
Event( "AccessBuilding", "38" )
{
If ( $gBuildingOwnerId == $gPlayerID )
{
*setvehicle %player% 20
$playervar70 = 1
osdcreate(OSDBUILDING,"Hut","You are safe inside your hut.")
osdaddat(OSDIMAGE, 0, 0, 590, 300, "",

"http://upload.wikimedia.org/wikipedia/c ... ophylla_wo

od.jpg")
osdaddat(OSDIMAGE, 5, 5, 255, 290, "", "http://media-

cdn.tripadvisor.com/media/photo-s/01/28/f3/d9/inside-a-hut.jpg")
osdaddat(OSDBUTTON, 280, 240, 295, 20, "1", "Enter World")
OSDSet("BlockEscape")
osdactivate()
}
else
{
*msg %player% This hut belongs to %buildingowner%.
}
}

unfortunately, "OSDSet("BlockEscape")" doesnt seem to stop the esc key from closing the osd window. anyone know why?

ANSWER
escapeblock doesnt work when the osd is triggered by a building.
Last edited by flametard on Fri Feb 08, 2013 2:43 am, edited 1 time in total.
User avatar
flametard
Posts: 1245
Joined: Sun Apr 01, 2007 2:05 am
Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
Contact:

Post by flametard »

things i need to know:

is there a command to freeze a player's movements?
if not, can someone provide me with a really simple cutscene script that will show the camera above the player's position, in which cant be affected with the escape key, or by moving?

is there a command that will allow/not allow a player to receive damage from weapons fire?
User avatar
MasterNiCron
Posts: 582
Joined: Wed Feb 17, 2010 10:57 pm
Location: Frost

Post by MasterNiCron »

as you can see i put the osdset part of ur script right after the create clase it seems to work for me :)

Code: Select all

Event( "AccessBuilding", "38" )
{
If ( $gBuildingOwnerId == $gPlayerID )
{
*setvehicle %player% 20
$playervar70 = 1
osdcreate(OSDBUILDING,"Hut","You are safe inside your hut.")
OSDSet("BlockEscape")
osdaddat(OSDIMAGE, 0, 0, 590, 300, "", "http://upload.wikimedia.org/wikipedia/commons/3/34/Swietenia_macrophylla_wood.jpg")
osdaddat(OSDIMAGE, 5, 5, 255, 290, "", "http://mediacdn.tripadvisor.com/media/photos/01/28/f3/d9/inside-a-hut.jpg")
osdaddat(OSDBUTTON, 280, 240, 295, 20, "1", "Enter World")
osdactivate()
} 
else 
{ 
*msg %player% This hut belongs to %buildingowner%. 
} 
} 
User avatar
flametard
Posts: 1245
Joined: Sun Apr 01, 2007 2:05 am
Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
Contact:

Post by flametard »

thanks blaze! I hadn't tried that yet.

question:
I cant seem to set new sounds in the sound slots. the file seems empty but the file data>sounds is full of sounds. also, the server window appears cut off on the right and bottom sides:
Image
anyone have any ideas?
IT WAS THE SCREEN RESOLUTION ON THE TINY NEW MONITOR!
Last edited by flametard on Fri Feb 08, 2013 2:44 am, edited 1 time in total.
User avatar
MasterNiCron
Posts: 582
Joined: Wed Feb 17, 2010 10:57 pm
Location: Frost

Post by MasterNiCron »

how to check playerID??
i added the %player% and name in if clases for referance to what im asking :P

Code: Select all

EVENT("&command", "&cps")
 {
  osdcreate(OSDLIST, "stats" "%player% stats")
  IF (%Player% = blaze)
     {
      osdadditem(OSDIMAGE, "", "CUSTOM IMAGE HERE")
     }
  ELSE IF (%Player% = mit)
     {
      osdadditem(OSDIMAGE, "", "CUSTOM IMAGE HERE")
     }
  ELSE
     {
      osdadditem(OSDIMAGE, "", "DEFALT IMAGE HERE")
     }
  osdadditem(OSDBIGTE........
  .........
  .........
  osdactivate()
 }
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

MasterNiCron wrote:how to check playerID??
i added the %player% and name in if clases for referance to what im asking :P
Replace the (%Player% = blaze) with ($gPlayerID=##)
Player id being seen via *showbill playername (its the Bill rec # )
unfortunately, this requires players to log in before you can set them in the script.
Last edited by zaroba on Mon Oct 08, 2012 10:07 pm, edited 1 time in total.
User avatar
MasterNiCron
Posts: 582
Joined: Wed Feb 17, 2010 10:57 pm
Location: Frost

Post by MasterNiCron »

thanks :P
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

flametard wrote:thanks blaze! I hadn't tried that yet.

question:
I cant seem to set new sounds in the sound slots. the file seems empty but the file data>sounds is full of sounds. also, the server window appears cut off on the right and bottom sides:
anyone have any ideas?
There is a 'refresh directory listing' button on the bottom of the server panel, but it's cut off on your screen. If I recall from past times people had this issue, it had to do with windows font size being too large.
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

flametard wrote:Question: can I make a gatehouse that "opens" and "closes" via script the same way different models are used in conjunction with buildingvar when buildings are in the various stages of construction on chapter 3?
I'm certain the chap 3 construction progress scripts work by actually replacing the building. Each stage you see is a separate building in the buildings.dat file, as you construct the building, the script demolishes the building and places a different model in the same location. No items are lost during this because they are stored in vars and transferred over.
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

re: gate opening... theres plans for a better way of doing things like that (setting a param on the building via script which is used by the client to do a range of standard things - like putting the model in a particular animation state, or adding a chimney smoke effect etc). I'll try to get that finished up soon so you can make use of it. (You can do it by adding and removing buildings from script as zar says, but that's cumbersome and can be a bit tricky to implement).

sounds probably need some work (generally ive just been using the mp3 player so far)..
User avatar
flametard
Posts: 1245
Joined: Sun Apr 01, 2007 2:05 am
Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
Contact:

Post by flametard »

zaroba wrote: There is a 'refresh directory listing' button on the bottom of the server panel, but it's cut off on your screen. If I recall from past times people had this issue, it had to do with windows font size being too large.
thanks, that definitely worked.
zaroba wrote:I'm certain the chap 3 construction progress scripts work by actually replacing the building. Each stage you see is a separate building in the buildings.dat file, as you construct the building, the script demolishes the building and places a different model in the same location. No items are lost during this because they are stored in vars and transferred over.
If the building gets replaced with a building that is *rotatebuildinged in the same degree, then that 'clunky' idea that Zar mentioned will work, if not, I'll have to wait until said changes are applied. (which would be super cool)

as far as my blockescape problem is concerned, I can't figure it out. It might have something to do with my previous problem of not being able to get the newly saved script right away. :?
User avatar
MasterNiCron
Posts: 582
Joined: Wed Feb 17, 2010 10:57 pm
Location: Frost

Post by MasterNiCron »

Code: Select all

Event( "MenuOption", "3" )
{
   OSDCreate( OSDWINDOW, "Battle", "Battleing %TARGET%" )
   OSDAddItem( OSDBUTTON, "attack|$gTargetID", "Press here to attack %TARGET%" )
   OSDActivate()
}
Event( "OSDSelect", "Battle:attack" )
{
   $paramTargetID = $gParam[1]
   $targetName = sysGetPlayerName( $paramTargetID )
   *msg %PLAYER% You selected to challenge $targetName
}
so u just add |$gTargetID to the osd button just like this
OSDAddItem(OSDBUTTON, "attack|$gTargetID", "Press here to attack %TARGET%" )
to carey the targetID along to the next osd page to pop up right??
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

yup
User avatar
MasterNiCron
Posts: 582
Joined: Wed Feb 17, 2010 10:57 pm
Location: Frost

Post by MasterNiCron »

Code: Select all

EVENT("osdselect", "PvP:2")
	{
	 SetContext( $gTargetID )
	 $targetPvPW = $gPlayerVar[13]
	 RestoreContext()
	 *msg %player% you deside to run away
	 *msg %target% %player ran away
	 sleep(1)
	 $gPlayerVar[14] = $gPlayerVar[14] +1
	 $targetPvPW = $targetPvPW + 1
	 sleep(1)
	 SetContext( $gTargetID )
	 $gPlayerVar[13] = $targetPvPW
	 RestoreContext()
	}

this changes both playervar for bothe players but shuld only change 1 for eace why dont it work right??
User avatar
MasterNiCron
Posts: 582
Joined: Wed Feb 17, 2010 10:57 pm
Location: Frost

Post by MasterNiCron »

why is this not working right
it keeps makeing targets var same as player activating the script

Code: Select all

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

Event("MenuOption", "3")
	{
	 SetContext( $gTargetID )
	 $tHP = $gPlayerVar[2]
	 $tHPM = $gPlayerVar[3]
	 $tAtt = $gPlayerVar[4]
	 $tDef = $gPlayerVar[5]
	 RestoreContext()
	 osdcreate(OSDLIST, "PvP", "Chalenged %target% to Battle")
	 osdSet("BlockEscape")
	 osdadditem(OSDMINHEIGHT, "", "300")
	 osdaddat(osdIMAGE, 0, 5, 590, 290, "", "http://i48.tinypic.com/wkiidx.jpg")Papper
	 IF ($gTargetID = 2)
		{
		 osdaddat(OSDIMAGE, 25, 20, 200, 200, "", "http://i50.tinypic.com/npfmup.jpg")BLAZE
		}
	 ELSE
		{
		 osdaddat(OSDIMAGE, 25, 20, 200, 200, "", "http://i45.tinypic.com/2nulzdz.jpg")
		}
	 osdaddat(OSDBIGTEXT, 235, 25, 330, 20, "", "You Chalenge %target%")
	 osdaddat(OSDBIGTEXT, 25, 225, 200, 20, "", "HP:$tHP/$tHPM")
	 osdaddat(OSDBIGTEXT, 25, 245, 200, 20, "", "ATT:$tAtt")
	 osdaddat(OSDBIGTEXT, 25, 265, 200, 20, "", "DFF:$tDef")
	 osdaddat(OSDBIGTEXT, 235, 130, 330, 20, "", "__________________________")
	 osdaddat(OSDBIGTEXT, 235, 155, 330, 20, "", "What Will You Do")
	 osdaddat(OSDIMAGE, 235, 215, 330, 30, "1|$gTargetID", "http://i46.tinypic.com/33yna5c.jpg")ATTACK
	 osdaddat(OSDIMAGE, 235, 250, 330, 30, "2|$gTargetID", "http://i49.tinypic.com/2z6f495.jpg")DEFEND
	 osdactivate()
	}
------------------------------------------------------------------------------
EVENT("osdselect", "PvP:1")
	{
	 $YHP = $gPlayerVar[2]
	 $YHPM = $gPlayerVar[3]
	 $YAtt = $gPlayerVar[4]
	 $YDef = $gPlayerVar[5]
	 SetContext( $gTargetID )
	 $tHP = $gPlayerVar[2]
	 $tHPM = $gPlayerVar[3]
	 $tAtt = $gPlayerVar[4]
	 $tDef = $gPlayerVar[5]
	 RestoreContext()
	 $GD = $YAtt - $tDef
	 $TD = $TDef - $YAtt
	 IF ($YHP > 1)
		{
		 IF ($THP > 1)
			{
			 IF ($YAtt > $tDef)
				{
				 $tHP = $tHP - $GD
				 osdcreate(OSDLIST, "PvP", "BATTLE")
				 osdSet("BlockEscape")
				 osdadditem(OSDMINHEIGHT, "", "300")
				 osdaddat(osdIMAGE, 0, 5, 590, 290, "", "http://i48.tinypic.com/wkiidx.jpg")Papper
				 IF ($gTargetID = 2)
					{
					 osdaddat(OSDIMAGE, 25, 20, 200, 200, "", "http://i50.tinypic.com/npfmup.jpg")BLAZE
					}
				 ELSE
					{
					 osdaddat(OSDIMAGE, 25, 20, 200, 200, "", "http://i50.tinypic.com/2w4n120.jpg")
					}
				 osdaddat(OSDBIGTEXT, 235, 25, 330, 20, "", "%target% takes $GD damage form you.")
				 osdaddat(OSDBIGTEXT, 25, 225, 200, 20, "", "HP:$tHP/$tHPM")
				 osdaddat(OSDBIGTEXT, 25, 245, 200, 20, "", "ATT:$tAtt")
				 osdaddat(OSDBIGTEXT, 25, 265, 200, 20, "", "DFF:$tDef")
				 osdaddat(OSDIMAGE, 235, 215, 330, 30, "1|$gTargetID", "http://i46.tinypic.com/33yna5c.jpg")ATTACK
				 osdaddat(OSDIMAGE, 235, 250, 330, 30, "2|$gTargetID", "http://i49.tinypic.com/2qtl6l4.jpg")RUN
				 osdactivate()
				 SetContext( $gTargetID )
				 $gPlayerVar[2] = $tHP
				 RestoreContext()
				}
			 ELSE
				{
				 $YHP = $YHP - $TD
				 osdcreate(OSDLIST, "PvP", "BATTLE")
				 osdSet("BlockEscape")
				 osdadditem(OSDMINHEIGHT, "", "300")
				 osdaddat(osdIMAGE, 0, 5, 590, 290, "", "http://i48.tinypic.com/wkiidx.jpg")Papper
				 IF ($gTargetID = 2)
					{
					 osdaddat(OSDIMAGE, 25, 20, 200, 200, "", "http://i50.tinypic.com/npfmup.jpg")BLAZE
					}
				 ELSE
					{
					 osdaddat(OSDIMAGE, 25, 20, 200, 200, "", "http://i50.tinypic.com/2w4n120.jpg")
					}
				 osdaddat(OSDBIGTEXT, 235, 25, 330, 20, "", "You take $TD damage form %target%.")
				 osdaddat(OSDBIGTEXT, 25, 225, 200, 20, "", "HP:$tHP/$tHPM")
				 osdaddat(OSDBIGTEXT, 25, 245, 200, 20, "", "ATT:$tAtt")
				 osdaddat(OSDBIGTEXT, 25, 265, 200, 20, "", "DFF:$tDef")
				 osdaddat(OSDIMAGE, 235, 215, 330, 30, "1|$gTargetID", "http://i46.tinypic.com/33yna5c.jpg")ATTACK
				 osdaddat(OSDIMAGE, 235, 250, 330, 30, "2|$gTargetID", "http://i49.tinypic.com/2qtl6l4.jpg")RUN
				 osdactivate()
				 $gPlayerVar[2] = $YHP
				}
			}
		ELSE
			{
			 $gPlayerVar[13] = $gPlayerVar[13] +1
			 SetContext( $gTargetID )
			 $gPlayerVar[14] = $gPlayerVar[14] + 1
			 RestoreContext()
			}
		}
	 ELSE
		{
		 $gPlayerVar[14] = $gPlayerVar[14] +1
		 SetContext( $gTargetID )
		 $gPlayerVar[13] = $gPlayerVar[13] + 1
		 RestoreContext()
		}
	}
-----------------------------------------------------------------------------
EVENT("osdselect", "PvP:2")
	{
	 $gPlayerVar[14] = $gPlayerVar[14] +1
	 SetContext( $gTargetID )
	 $gPlayerVar[13] = $gPlayerVar[13] + 1
	 RestoreContext()
	 *msg %player% you deside to run away
	 *msg %target% %player% ran away
	}
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

$gTargetID is not valid in OSDSelect (You're selecting a generic button, not doing something specific to a particular player). You need to use params to pass in the target - whcih you're doing up to the last step.

i.e

Code: Select all

osdaddat(OSDIMAGE, 235, 250, 330, 30, "2|$gTargetID", "http://i49.tinypic.com/2qtl6l4.jpg")
is good.. you're setting up an image button called '2' with the target ID as the first parameter. ($gTargetID is valid in this MenuSelect event because its one that happens to a specific target player)

Now your OSDSelect event needs to pick up that parameter and use it. Essentially that means adding $myTargetID = $gParam[1]. (You need then to remove references to $gTargetID and %TARGET% - which'll never be valid in an OSDSelect event).

So your modified version of the OSDSelect "2" event would be:

Code: Select all

EVENT("osdselect", "PvP:2") 
   {
   $myTargetID = $gParam[1] 
   $targetName = sysGetPlayerName( $myTargetID )
 
    SetContext( $myTargetID ) 
    $targetPvPW = $gPlayerVar[13] 
    RestoreContext() 
    *msg %player% you deside to run away 
    *msg $targetName %player% ran away 
    sleep(1) 
    $gPlayerVar[14] = $gPlayerVar[14] +1 
    $targetPvPW = $targetPvPW + 1 
    sleep(1) 
    SetContext( $myTargetID ) 
    $gPlayerVar[13] = $targetPvPW 
    RestoreContext() 
   }
(and while im here.. theres a few bits in that code block that arent really necessary. A more optimal version that does essentially the same job would be :

Code: Select all

EVENT("osdselect", "PvP:2") 
{
   $myTargetID = $gParam[1] 
   $targetName = sysGetPlayerName( $myTargetID )
 
    SetContext( $myTargetID ) 
    $targetPvPW = $gPlayerVar[13]
    $gPlayerVar[13] = $gPlayerVar[13] + 1
    RestoreContext() 

    *msg %player% you deside to run away 
    *msg $targetName %player% ran away 
    $gPlayerVar[14] = $gPlayerVar[14] +1 
}
User avatar
MasterNiCron
Posts: 582
Joined: Wed Feb 17, 2010 10:57 pm
Location: Frost

Post by MasterNiCron »

thanks it works now :)
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

Supah
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

anybody know if these exist?

*addbuildinginvestment
*removebuildinginvestment
$gBuildingInvestment



I seem to think they do, but I can't find any record in the lists (or I'm not lookign hard enough)
Locked