User Tools

Site Tools


scripting:samples:simpleschool
$kSchoolBuildingNum = 10

Event( "AccessBuilding", "$kSchoolBuildingNum" )
{
    osdcreate(OSDBUILDING,"SchoolOSD", "Example School" ) 
    
    $liney = 10    
    $liney = ShowSkillButton( 10, 20, 100 )   // Skill num 10, 20 game days to learn, costs 100d
    $liney = ShowSkillButton( 12, 25, 200 )   // Skill num 12, 25 game days to learn, costs 200d
    $liney = ShowSkillButton( 16, 28, 300 )   // Skill num 16, 28 game days to learn, costs 300d
    
    osdactivate() 
}

function ShowSkillButton( $liney, $skillNum, $learnTime, $cost )
{
    $skillName = sysGetSkillName( $skillNum )
    osdadd(EXITBUTTON, 100, $liney, 400, 30, "Buy|$skillNum|$learntime|$cost", "Learn $skillName") 
    $liney += 35
    $priceText = sysGetPriceText( $cost )
    $learntimetext = sysGetRealTimeTextForDays( $learnTime )
    osdtextcentre( 300, $liney, "Costs $priceText, learnt in $learntimetext" )
    $liney += 20
    
    return( $liney )    
}

Event( "OSDSelect", "SchoolOSD:Buy" )
{
    $skillNum = $gParam[1]
    $learntime = $gParam[2]
    $cost = $gParam[3]

    $amountPaid = sysRemoveWealth( $cost, "Education Fees")
    if ( $amountPaid == $cost )
    {
        *addskill %PLAYER% $skillNum $learntime
    } 
}
scripting/samples/simpleschool.txt · Last modified: 2023/07/04 03:40 by mit

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki