[92.03] Add account benefits

Results 1 to 4 of 4
  1. #1
    Member Luciole is offline
    MemberRank
    Dec 2015 Join Date
    上海-ShanghaiLocation
    94Posts

    [92.03] Add account benefits

    [92.03] Add account benefits
    The account benefits is displayed in-game beside the VIP icon and on the right side in the lobby. It can be founder (Having a purchased account), TERA Club, PC cafe, etc...
    It's more convenient to have them set automatically than using the "add_privilege" QA method.

    Import this SQL file into your accountdb_2800 database:
    Code:
    DROP TABLE IF EXISTS `account_benefits`;
    CREATE TABLE `account_benefits` (
      `accountDBID` int(11) NOT NULL,
      `benefitId` int(11) NOT NULL,
      `availableUntil` int(11) NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    In the API, replace the "GetUserInfo" method with this one:
    Code:
    def GetUserInfo() {
            println '----------------GetUserInfo----------------'
            String msg = ''
            int returnCode = 0
            boolean paramLengthCheck = true
    
            params.putAll(request.JSON)
            params.each {
                if(it.getValue().toString().contains('./') || it.getValue().toString().contains('.?') || it.getValue().toString().length() > 1500)
                    paramLengthCheck = false
                msg = "$it.key parameter error"
            }
    
            if(!paramLengthCheck){
                JSONObject result = new JSONObject()
                result.put('Return',false)
                result.put('ReturnCode',50500)
                result.put('msg', msg)
                def resultJson = result as JSON
                response.setContentLength(resultJson.toString()?.bytes.length)
                render text : resultJson , contentType: 'application/json', encoding: 'UTF-8'
                println result
            }
            else {
                JSONObject result = new JSONObject()
                def paramMap = [:]
                try {
                    params.each { p ->
                        if (p.key != 'action' && p.key != 'controller') {
                            paramMap.put(p.key, p.value)
                            println 'Key: ' + p.key + ', value: ' + p.value
                        }
                    }
                } catch (RuntimeException e) {
                    returnCode = 58007
                    msg = 'invalid encoded parameter(base64)'
                    e.printStackTrace()
                }
    
                if(!params.user_srl || !params.server_id ||!params.ip || !params.serviceCode ){
                    returnCode = 2
                    msg = "user_srl=$params.user_srl&server_id=$params.server_id&ip=$params.ip&serviceCode=$params.serviceCode"
                }
    
                def accountList = []
                String selectQuery = "select * from AccountInfo where accountDBID = $params.user_srl"
                Sql sql = new Sql(dataSource)
                sql.eachRow(
                        selectQuery, {
                    it.eachWithIndex { row, index ->
                        accountList << [
                                charCount:        row.charCount,
                                //lastLoginTime:    row.lastLoginTime,
                                //playTimeLast:    row.playTimeLast,
                                isBlocked:        row.isBlocked,
                        ]
                    }
                }
                )
                sql.close()
    
                def benefit_array = []
                selectQuery = "select * from account_benefits where accountDBID = $params.user_srl"
                sql = new Sql(dataSource)
                sql.eachRow(
                        selectQuery, {
                            it.eachWithIndex { row, index ->
                            benefit_array << [
                                    row.benefitId,
                                    row.availableUntil - (System.currentTimeMillis()/1000).toInteger()
                            ]
                        }
                    }
                )
                if (accountList.size() != 1) {
                    msg = 'invalid login request'
                    returnCode = 50000
                }
                else {
                    def accountInfo = accountList.get(0)
                    def charCount = accountInfo.getAt('charCount')
                    def CharacterCount = "0|2800,$charCount|"
                    result.put("last_connected_server", null)
                    result.put("last_play_time", null)
                    result.put("logout_time_diff", null)
                    result.put("char_count_info", CharacterCount)
                    result.put("privilege", 0)
                    result.put("permission", accountInfo.getAt('isBlocked'))
                    result.put("result_code", returnCode)
                    result.put("benefit", benefit_array)
                    result.put("vip_pub_exp", 0)
                }
                if (returnCode > 0)
                    result.put("msg", msg)
                response.setContentLength((result as JSON).toString()?.size())
                render text: result as JSON, contentType: 'application/json', encoding: 'UTF-8'
                println result
            }
        }
    You can find the list of all the different benefits in the "StrSheet_AccountBenefit.xml" file in the datacenter, or use the list below

    Code:
    <String id="31" string="Proof of the expedition member" />
      <String id="32" string="Skillful Adventurer" />
      <String id="33" string="TERA Rewards" showLeftTimeOver1Year="False" />
      <String id="34" string="Frontier" hideCoolTime="True" />
      <String id="35" string="EP XP increases by 30" hideCoolTime="True" />
      <String id="70" string="" showLeftTimeOver1Year="False" />
      <String id="77" string="Monthly Pass" showLeftTimeOver1Year="False" />
      <String id="101" string="" showLeftTimeOver1Year="True" />
      <String id="102" string="" hideCoolTime="True" />
      <String id="103" string="Japan Returning user" />
      <String id="104" string="JP Tooltip" showLeftTimeOver1Year="True" />
      <String id="105" string="" showLeftTimeOver1Year="True" />
      <String id="106" string="" showLeftTimeOver1Year="True" />
      <String id="107" string="" showLeftTimeOver1Year="True" />
      <String id="108" string="" showLeftTimeOver1Year="True" />
      <String id="109" string="" showLeftTimeOver1Year="True" />
      <String id="333" string="Elite Status" />
      <String id="334" string="Founder" />
      <String id="335" string="Console Elite" />
      <String id="350" string="Server Benefit" />
      <String id="433" string="TERA Club" />
      <String id="434" string="Veteran" />
      <String id="435" string="Package Benefit I" />
      <String id="436" string="Package Benefit II" />
      <String id="437" string="Package Benefit III" />
      <String id="500" string="VIP" showLeftTimeOver1Year="False" />
      <String id="510" string="TW XP Boost Server" />
      <String id="520" string="VIP2" />
      <String id="530" string="" showLeftTimeOver1Year="False" />
      <String id="533" string="VIP" />
      <String id="534" string="Founder" hideCoolTime="True" />
      <String id="600" string="Trade restricted" hideCoolTime="True" />
      <String id="601" string="Basic Package" hideCoolTime="True" />
      <String id="691" string="Safe Mode" />
      <String id="701" string="VIP" showLeftTimeOver1Year="False" />
      <String id="800" string="PC Café (Minor)" />
      <String id="801" string="PC Café (Intermediate)" />
      <String id="802" string="PC Café (Major)" />
      <String id="803" string="PC Café (VIP)" />
      <String id="804" string="User ELITE (Minor)" />
      <String id="805" string="User ELITE (Intermediate)" />
      <String id="806" string="User ELITE (Major)" />
      <String id="807" string="User ELITE (VIP)" />
      <String id="808" string="" />
      <String id="809" string="" showLeftTimeOver1Year="False" />
      <String id="810" string="" showLeftTimeOver1Year="False" />
      <String id="1000" string="TERA PC cafe" hideCoolTime="True" />
      <String id="1001" string="" hideCoolTime="True" />
    In the new table account_benefit, set the "accountDBID" to yours found in the "accountinfo" table, "benefitId" with your wanted benefit from the list or datacenter file and "availableUntil" to the date you want this benefit to be available (set the date in 10 years if you want it permanently).


  2. #2
    Hardcore Member argeus99 is online now
    MemberRank
    Mar 2019 Join Date
    ColombiaLocation
    125Posts

    Re: [92.03] Add account benefits

    Thanks for sharing. Let me ask, is there a way to enable 2 accounts benefits at same time? like Founder and Elite/Club Status

  3. #3
    Member Luciole is offline
    MemberRank
    Dec 2015 Join Date
    上海-ShanghaiLocation
    94Posts

    Re: [92.03] Add account benefits

    Quote Originally Posted by argeus99 View Post
    Thanks for sharing. Let me ask, is there a way to enable 2 accounts benefits at same time? like Founder and Elite/Club Status
    Yeah sure. This is an array of array. Each benefit array is in this format: [benefit_id, time_remaining].

    So sending [[334, 600000], [433, 600000], [1000, 600000]] will result having founder (334), TERA CLUB EU (443) and KR pc cafe (1000) for 1h

  4. #4
    Member templar is offline
    MemberRank
    Mar 2012 Join Date
    42Posts

    Re: [92.03] Add account benefits

    what file in the api does this go into? and recompile?



Advertisement