Jump to content

KeyWorld

Members
  • Posts

    379
  • Joined

  • Last visited

  • Days Won

    11

Posts posted by KeyWorld

  1. As far i know a "file structure/format" can't be copyright, just the content inside.

    Since no files from Gravity are packed in his GND/GAT/RSW, just used externally (sound/models/textures) he doesn't release a Gravity work, just 3 files that contain HIS content (mesh, maps infos, etc.).

    So no problem I think for your ,,Friend"" (if it was really a lawyer).

  2. Something like this:

    online_user.php:

    <?php
    
    header('Content-type:text/plain');
    
    // Configs
    $db_host    = "localhost";
    $db_name    = "ragnarok";
    $db_user    = "ragnarok";
    $db_pass    = "ragnarok";
    $cache_file = "status.txt";
    $cache_time = 60; // seconds.
    
    if ( !file_exists($cache_file) || filemtime($cache_file) + $cache_time < time() ) {
       $db    = new PDO("mysql:host={$db_host};dbname={$db_name}", $db_user, $db_pass );
       $count = $db->query("SELECT COUNT(*) FROM `char` WHERE `online` = '1'")->fetchColumn();
       file_put_contents( $cache_file, $count );
    }
    
    readfile($cache_file);
    ?>

    html page:

    <div id="online_user"><?php include('online_user.php'); ?></div>
    
    <script type="text/javascript">
    // lol IE lol
    window.XMLHttpRequest = window.XMLHttpRequest || function() {
       try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch (e) {}
       try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch (e) {}
       try { return new ActiveXObject('Microsoft.XMLHTTP');  } catch (e) {}
       throw new Error('No support for XMLHttpRequest ?');
    }
    
    setInterval( function() {
       var req = new XMLHttpRequest();
       req.onreadystatechange = function() {
           if ( this.readyState === 4 && this.status === 200 )
               document.getElementById('online_user').innerHTML = this.responseText; // IE love innerHTML 
       };
       req.open('GET', 'online_user.php', true );
       req.send(null);
    }, <?php echo $cache_time * 1000; ?> );
    </script>

  3. If it can help

    -    script    var    -1,{
    
       function inside_func { // own namespace
           // .@b: 0
           set .@c, 5;
       } // <- clean .@c
    
       OnInit:
           set .@a, 5;
           end; // <- clean .@a
    
    
       OnEvent: // Custom event
           // .@a: 0
           set .@b, 3;
           inside_func();
           // .@c: 0
           // .@b: 3
           goto OnTest;
    
       OnTest: // goto keep variables
           // .@b: 3
           set .@c, 8;
           callsub OnTest2;
           // .@b: 3
           // .@c: 8
           // .@d: 0
           end; // clean .@b, .@c
    
       OnTest2:
           // .@b: 0
           // .@c: 0
           set .@d, 5;
           return; // <- clean .@d
    
    }

    .@var are limited to their namespaces and not copy to their inside function/callsub.

    But you can modify them in a function using getarg():

    -    script    var    -1,{
    
       function double {
           set getarg(0), getarg(0) * 2;
       }
    
       OnInit:
           set .@b, 10;
           double(.@;
           // .@b: 20
    }

    No problem with switch in switch.

    You can even do function in function without problem :)

  4. Hi.

    From the doc:

            0: bare fist
           1: Daggers
           2: One-handed swords
           3: Two-handed swords
           4: One-handed spears
           5: Two-handed spears
           6: One-handed axes
           7: Two-handed axes
           8: Maces
           9: Unused
           10: Staves
           11: Bows
           12: Knuckles
           13: Musical Instruments
           14: Whips
           15: Books
           16: Katars
           17: Revolvers
           18: Rifles
           19: Gatling guns
           20: Shotguns
           21: Grenade launchers
           22: Fuuma Shurikens

  5.  // When loading frames:
    for( $i=0; $i<$this->sHeader['num_pal']; $i++ )
    {
       $this->frames[$i] = unpack('Swidth/Sheight/', fread($this->spr, 0x04));
       extract( unpack('Ssize', fread($this->spr,0x02) ) );
       $this->frames[$i]['data'] = fread( $this->spr, $size );
    }
    
    
    
    // When you want to draw a frame
    
    $frame  = $this->frames[$frame]; // $frame is the frame you want to render
    $width  = $frame['width'];
    $height = $frame['height'];
    $data   = $frame['data'];
    $img    = imagecreatetruecolor( $width, $height );
    
    
    // Allocate palette
    $pal = array();
    for ( $i=0, $j=4; $i<256; ++$i, ++$j )
       $pal[$i] = imagecolorallocate(
           $img,
           ord($this->palette[$j++]),
           ord($this->palette[$j++]),
           ord($this->palette[$j++])
       );
    
    // Render image
    for ( $i=0; $i < $width * $height; ++$i )
    {
       imagesetpixel( $img, $i % $width, $i/$width | 0, $pal[ ord($data[$i]) ] );
    }
    
    imagepng( $img );

    • Upvote 3
  6. Well, each frames in the sprite have a data ( the data start to $this->frames[<index>]['offset'] and end to ($this->frames[<index>]['offset'] + $this->frames[<index>]['data_length'] ).

    Each bytes of this data represent $spr_index.

  7. Palette contain 1024 bytes, so basically 256 * rgba values (when alpha isn't used).

    Sprite contain palette indexes (and in some cases, some raw images).

    And one (default) palette is also contain in the end of a sprite file, so if you can display a sprite without loading an extra .pal file you should be able to load a .pal file (it's the same thing).

    So basically:

    // Loading palette
    $pal_data = fread( $fp_pal, 1024 );
    
    // Allocate palettes
    $palette  = array();
    for ( $i=0, $j=0; $i<256; $i++, $j+=4 )
    {
       $palette[ $i ] = imagecolorallocate(
           ord( $pal_data[$j+0] ),
           ord( $pal_data[$j+1] ),
           ord( $pal_data[$j+2] )
        );
    }
    
    // Display a pixel : ($spr_index)
    imagesetpixel( $img, $x, $y, $palette[ $spr_index ] );

  8. You should test it before ask :)

    Missing a "{", missing a "}", bad else location, the announce is send every time a player log out, warp players every time the log out to prontera.

    Should be something like this:

    OnPCLogOutEvent:
    
       if ( strcharinfo(3) == "1@pump" )
       {
           if ( getmapusers("1@pump") == 0 ) // 0 or 1 ? Does the script is execute before decrement the map counter ?
           {
               hideoffnpc "MvP Summoner";
               announce "MvP room is now availabe.", bc_all;
               killmonsterall "1@pump";
           }
           warp "prontera", 150, 150;
           end;
       }

    • Upvote 1
  9. Hair sprites don't need a table. :)

    Are you sure ?

    M :

    start to index 2: 1 7 5 4 3 6 8 9 10 12 11 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

    F :

    start to index 2: 4 7 1 5 3 6 12 10 9 11 8 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

    (Default style: 2)

    It was base on an old client, things may have change, I didn't check it recently.

    Anyway, good job :)

  10. I feel the same thing Trojal.

    Happy development for this new CP, it's fun to make one from scratch.

    I hope you the best for this project :)

    About features: One thing I love is the page transition system : like github used ( html5 history API, if not present used hash url + ajax, if not change page). I used this in some recents projects and it's a good experience for the user. It could be fun, since you are a HTML5 guy :P to add this to the CP.

    All others things are just basics ideas that you can see in all others CPs, so not interesting.

    @EvilPuncker

    It's not because you have a module "Ladder" that you must use it lol

×
×
  • Create New...