Noobish questions, mostly about scripting
My first Script
The Question is how can i add a task loading bar, an image and a sound to the script
My first Script Thanks to all that helped.
I always laugh when the Tree takes revenge
Code: Select all
Tree
------------------------------------------------------------------------------------------------------------------
EVENT("accessbuilding", "8")
{
$RS = sysPlayerInventory("Axe")
if ($RS < 1)
{
osdcreate(OSDBUILDING, "Chop", "Tree")
osdadditem(OSDBIGTEXT, " ", "You need an AXE")
osdadditem(OSDBIGTEXT, " ", "")
osdadditem(OSDBIGTEXT, " ", "")
osdadditem(OSDEXITBUTTON, "exit", "OK")
osdactivate()
}
ELSE IF ($RS >= 1)
{
osdcreate(OSDBUILDING, "Chop", "Tree")
osdadditem(OSDBIGTEXT, "", "Chop the Tree to get a Log")
osdadditem(OSDBIGTEXT, " ", "")
osdadditem(OSDBIGTEXT, " ", "")
osdadditem(OSDEXITBUTTON,"1", "Chop")
osdadditem(OSDEXITBUTTON,"2", "Leave")
osdactivate()
}
}
EVENT("OSDSELECT", "Chop:1")
{
Event ("Useitem","Axe")
{
$myVar = sysRand(50)
If ( $myVar = 1 )
{
*msg %player% I Told you!!!
*msg %player% The Axe has broken down
*grantitem %player% -1 Axe
}
else If ( $myVar >= 2 )
{
*msg %player% Ouch it hurts!!!, Someday I'll take revenge
*grantitem %player% 1 log
}
osdactivate()
}
I always laugh when the Tree takes revenge
- MasterNiCron
- Posts: 582
- Joined: Wed Feb 17, 2010 10:57 pm
- Location: Frost
not really shur how my self so i just been useing sleep timers
like this
where it says sleep(100) will make it wate for 10 sec then finsh the script
like this
Code: Select all
EVENT("playerlogin", "")
{
$gPlayerVar[2] = $gPlayerVar[3]
IF ($gPlayerVar[1] >= 1)
{
sleep(100)
IF ($gPlayerVar[6] >= 1)
{
CustomEvent( "TIMERS" )
}
ELSE
{
*say blaze %player% battles ant working.
}
}
ELSE
{
*say %PLAYER% is new and may need help.
sleep(100)
CustomEvent( "newplayer" )
}
*say Type &cps any time to see your current player stats.
}
tasks is a combo of script and * command.
*dotask (player name) (task#) (text to use)
it links to a TaskStart event with a timer PlayerTaskStartSetTime
one i had made for zoric while testing is:
Event( "OSDSelect", "b44o:b44opmsmap" )
{
$gBuildingVar41=$gBuildingVar41+1
*dotask %player% 100 Working on the $gPlayerVar25
CustomEvent("b44opmsm2")
}
Event( "TaskStart", "100" )
{
PlayerTaskStartSetTime(20)
}
When the osd button is clicked to activate the first script, the task is done which lasts 20 seconds, then the first script continues, loading the custom event.
*dotask (player name) (task#) (text to use)
it links to a TaskStart event with a timer PlayerTaskStartSetTime
one i had made for zoric while testing is:
Event( "OSDSelect", "b44o:b44opmsmap" )
{
$gBuildingVar41=$gBuildingVar41+1
*dotask %player% 100 Working on the $gPlayerVar25
CustomEvent("b44opmsm2")
}
Event( "TaskStart", "100" )
{
PlayerTaskStartSetTime(20)
}
When the osd button is clicked to activate the first script, the task is done which lasts 20 seconds, then the first script continues, loading the custom event.
As of the 0.65.2 buildings editor you've also got a new building type ("Scripted-NoWindow") which triggers the normal 'AccessBuilding' event but doesn't open the standard building window. You can then script whatever display you want (e.g. an OSDLIST).
What we don't have at the moment is a way to close an already open buildings window from script (which is something I've found I need for Galleons) so that'll be added later.
What we don't have at the moment is a way to close an already open buildings window from script (which is something I've found I need for Galleons) so that'll be added later.
- flametard
- Posts: 1245
- Joined: Sun Apr 01, 2007 2:05 am
- Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
- Contact:
Also, could someone help me build a script that allows a player to set one tile (tile#2 for this example) under the position they are standing... but only in a town that they own. I know it's possible.
I know it has something to do with:
*settile 2,$gPlayerWorldX,$gPlayerWorldY
but i dont know where all the other stuff goes and how similar it is to construction a building. thanks!
I know it has something to do with:
*settile 2,$gPlayerWorldX,$gPlayerWorldY
but i dont know where all the other stuff goes and how similar it is to construction a building. thanks!
- flametard
- Posts: 1245
- Joined: Sun Apr 01, 2007 2:05 am
- Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
- Contact:
hi, i need help getting the script to properly name the town building the name the player wantsit to be named. right now, i skipped all the building names and made it so whatever they try to type, the default building name is a space.. but since towns NEED unique names as to not confuse the server, i need this one to work right. here is my script:
thanks!!
Code: Select all
Event( "UseSkill", "Build Town" )
{
$itemcount = sysPlayerinventory("Stone")
If ($Itemcount > 49)
{
CustomEvent("towntown")
}
else
{
*msg %PLAYER% You need 50 stone to construct the new town.
}
}
Event( "Custom", "towntown" )
{
$itemcount = sysPlayerinventory("Villagers")
If ($Itemcount > 49)
{
*buildingconstruct %PLAYER% 64
}
else
{
*msg %PLAYER% You need 50 villagers to construct the new town.
}
}
Event( "PlaceBuilding", "64" )
{
$valid = sysIsBuildingPositionValid( $nBuildingCode )
if ( $valid = 1 )
{
*grantitem %player% -50 stone
$didAdd = sysAddBuildingWorld( 64, $gPlayerID,
$gPlayerWorldX,$gPlayerWorldY,New %player%town, $constrAmount )
}
else
{
*Customsound %player% 12
}
}
This should work. Hope you don't mind that I slightly changed it based on how I have zoric's building script, but hey, everybody will have their own variations :p
-combined the first 2 events so the use skill event will check stone then villagers. Also added a message so if you don't have enough stone, the script will also tell you if you need more villagers.
-since the script appears to only be for towns (building 64) made it use that number instead of using $gBuildingCode (which appears to only work while your *in* a script activated by a building)
-changed it to use $gBuildingName so spaces can be used
-removed $constrAmount, which doesn't appear to do anything in the script you posted. I don't have it anywhere on zoric's buildings and they seem to be working completely fine
-the $didAdd part in your script is on 2 seperate lines which will cause it to not work. But that could have been due to the forum.
I notice you don't have it removing villagers from the players inventory despite requiring them for a town. Don't know if that was intentional or just a mistake, so I'll leave that to you.
-combined the first 2 events so the use skill event will check stone then villagers. Also added a message so if you don't have enough stone, the script will also tell you if you need more villagers.
-since the script appears to only be for towns (building 64) made it use that number instead of using $gBuildingCode (which appears to only work while your *in* a script activated by a building)
-changed it to use $gBuildingName so spaces can be used
-removed $constrAmount, which doesn't appear to do anything in the script you posted. I don't have it anywhere on zoric's buildings and they seem to be working completely fine
-the $didAdd part in your script is on 2 seperate lines which will cause it to not work. But that could have been due to the forum.
I notice you don't have it removing villagers from the players inventory despite requiring them for a town. Don't know if that was intentional or just a mistake, so I'll leave that to you.
Code: Select all
Event( "UseSkill", "Build Town" )
{
$stone = sysPlayerinventory("Stone")
$villagers = sysPlayerinventory("Villagers")
If ($stone > 49)
{
If ($villagers > 49)
{
$buildingname = "%player%'s town"
*buildingconstruct %PLAYER% 64 $buildingname
}
else
{
*msg %PLAYER% You need 50 villagers to construct the new town.
}
}
else
{
*msg %PLAYER% You need 50 stone to construct the new town.
If ($villagers < 50)
{
*msg %PLAYER% You need 50 villagers to construct the new town.
}
}
}
Event( "PlaceBuilding", "64" )
{
$valid = sysIsBuildingPositionValid( 64 )
if ( $valid = 1 )
{
*grantitem %player% -50 stone
$buildingName = sysGetTextEntry()
$didAdd = sysAddBuildingWorld( 64, $gPlayerID, $gPlayerWorldX,$gPlayerWorldY, $buildingname )
}
else
{
*Customsound %player% 12
}
}
There is the command: *removebuilding type,mapX,mapY
Does anybody know if this will work with $gBuildingWorldX, $gBuildingWorldY
If it only uses $gBuildingX, $gBuildingY then I need an alternative way for a script to automatically remove a building on a tile that may have mulitple copies of the same building.
Does anybody know if this will work with $gBuildingWorldX, $gBuildingWorldY
If it only uses $gBuildingX, $gBuildingY then I need an alternative way for a script to automatically remove a building on a tile that may have mulitple copies of the same building.
- flametard
- Posts: 1245
- Joined: Sun Apr 01, 2007 2:05 am
- Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
- Contact:
i need to figure out how to get the sysgettextentry () stuff to work for naming the new towns as theyre built. this is what i got so far:
Code: Select all
Event( "UseSkill", "Build Town" )
{
$buildingName = "%PLAYER%town"
*buildingconstruct %PLAYER% 64 $buildingname
}
Event( "PlaceBuilding", "64" )
{
$buildingName = sysGetTextEntry()
$didAdd = sysAddBuildingWorld(64,$gPlayerID,$gPlayerWorldX,$gPlayerWorldY,$buildingName,)
if ( $didAdd != 0 )
{
*msg %player% construction complete
}
}
- flametard
- Posts: 1245
- Joined: Sun Apr 01, 2007 2:05 am
- Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
- Contact:
i need to figure out how to get the sysgettextentry () stuff to work for naming the new towns as theyre built. this is what i got so far:
Code: Select all
Event( "UseSkill", "Build Town" )
{
$buildingName = "%PLAYER%town"
*buildingconstruct %PLAYER% 64 $buildingname
}
Event( "PlaceBuilding", "64" )
{
$buildingName = sysGetTextEntry()
$didAdd = sysAddBuildingWorld(64,$gPlayerID,$gPlayerWorldX,$gPlayerWorldY,$buildingName,)
if ( $didAdd != 0 )
{
*msg %player% construction complete
}
}
- flametard
- Posts: 1245
- Joined: Sun Apr 01, 2007 2:05 am
- Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
- Contact:
damn i swore this was working before... but it doesnt work now, causing problems. players need to be able to name their new town upon building it. its only naming it the default name, which means players will only be able to build a town once, after that, the script thinks the town name already exists.
Code: Select all
Event( "PlaceBuilding", "64" )
{
$buildingName = sysGetTextEntry()
$didAdd = sysAddBuildingWorld(64,$gPlayerID,$gPlayerWorldX,$gPlayerWorldY,$buildingName,)
if ( $didAdd != 0 )
}
Event( "Custom", "towntown" )
{
$buildingName = "%PLAYER%ton"
*buildingconstruct %PLAYER% 64 $buildingname
}