Results 1 to 9 of 9

Thread: Question about GUI Scripting

  1. #1
    Newcomer Evination's Avatar
    Join Date
    Mar 2018
    Location
    Austria
    Posts
    10

    Question about GUI Scripting

    Greetings,

    I wrote a GUI script recently and while scripting a question came up in my mind.
    Basically I created one main GUIControl with some more controls added to it.

    Doesnt matter but I defined the position of a GUIControl (x and y axis).

    I have optimized the position and scaling to my 1920x1080px monitor.
    The question is if someone with f.e. a 4k resolution monitor joins the server will the gui be somewhere in the middle of the screen? Or with a smaller monitor even outside of the screen?

    Is there a way to define position and scaling in % or a script to get the screensize of the device?

    Thanks for the help =)

  2. #2
    Big Cheese Captain
    Join Date
    Jun 2013
    Posts
    1,029
    There's 2 readonly variables in Graal which can be useful to you: screenwidth and screenheight. You can use these 2 in a GuiControl

    PHP Code:
    // A GuiControl that is in the center of the screen, regardless of the size/resolution of the screen
    new GuiControl("blah") {
      
    width 500;
      
    height 400;
      
    = (screenwidth 2) - (width 2)
      
    = (screenheight 2) - (height /2)


  3. #3
    Newcomer Evination's Avatar
    Join Date
    Mar 2018
    Location
    Austria
    Posts
    10
    Quote Originally Posted by iMask View Post
    There's 2 readonly variables in Graal which can be useful to you: screenwidth and screenheight. You can use these 2 in a GuiControl

    PHP Code:
    // A GuiControl that is in the center of the screen, regardless of the size/resolution of the screen
    new GuiControl("blah") {
      
    width 500;
      
    height 400;
      
    = (screenwidth 2) - (width 2)
      
    = (screenheight 2) - (height /2)

    Thanks! I have trouble understanding Player Attributes or Attractions.

    For Example:
    PHP Code:
    //#CLIENTSIDE
    function onWeaponFired(){
      
    player.attr[1]="something.gani";

    This places the gani on top of the player, so what exactly is player.attr?

    Thanks for help =)

  4. #4
    Big Boss
    Join Date
    Nov 2017
    Posts
    33
    Attributes are basically a way to pass information about a player's or NPC's appearance to other players. There are 30 total attributes, numbered 1-30. Generally, player.attr[1] is reserved for hat images, and on most servers player.attr[3] is reserved for carried objects like bushes, but beyond that it depends on the server. If you set a player.attr to a gani, it will display that gani at the player's position and follow them around. You can configure ganis to show sprites based on attributes as well, which is how the carry gani works. It looks at attr[3] in order to get the image name of the carried object.

    You can also send text and numbers through attributes. For example, the fishing rod on Ol' West uses attributes to pass the lure's position to other players, allowing them to see each other's lures move around in the world.

  5. #5
    Newcomer Evination's Avatar
    Join Date
    Mar 2018
    Location
    Austria
    Posts
    10
    Quote Originally Posted by Hoyt View Post
    Attributes are basically a way to pass information about a player's or NPC's appearance to other players. There are 30 total attributes, numbered 1-30. Generally, player.attr[1] is reserved for hat images, and on most servers player.attr[3] is reserved for carried objects like bushes, but beyond that it depends on the server. If you set a player.attr to a gani, it will display that gani at the player's position and follow them around. You can configure ganis to show sprites based on attributes as well, which is how the carry gani works. It looks at attr[3] in order to get the image name of the carried object.

    You can also send text and numbers through attributes. For example, the fishing rod on Ol' West uses attributes to pass the lure's position to other players, allowing them to see each other's lures move around in the world.
    Thanks.

    Are Player Attributes the most practical way to change a players gani for example when equipping a weapon?

  6. #6
    Big Boss
    Join Date
    Nov 2017
    Posts
    33
    To just change a player's gani, you can use the setani(aniName,aniParams) function.
    PHP Code:
    //#CLIENTSIDE
    //Example 1: Set the player's ani to sword.gani, pass no gani params
    function onCreated(){
      
    setani("sword",null);

    PHP Code:
    //#CLIENTSIDE
    //Example 2: Set the player's ani to gralats.gani and pass "3" through as an aniparam, which picks the third gralat type, red gralats
    function onCreated(){
      
    setani("gralats",3);

    If you want to replace a default gani, you can use the replaceani(defaultAniName,replaceName) function. It lets you totally replace a default animation like walk or idle with a different one. This is really useful for equipping items so that you can have custom idle and walk animations where the player is holding the item.
    PHP Code:
    //#CLIENTSIDE
    function onCreated(){
      
    replaceani("idle","carrystill");
      
    replaceani("walk","carry");

    That replaces your idle and walk animations with carry animations. To change them back to normal you would use the following code:
    PHP Code:
    //#CLIENTSIDE
    function onCreated(){
      
    replaceani("idle","idle");
      
    replaceani("walk","walk");

    Player attributes wouldn't be a great way to change the player's gani to display an equipped weapon, but you could use player attributes to hold the image name of their currently equipped weapon if you had a single gani that was set up to display many different weapons in it. Normally your best bet would be making different ganis for each different weapon though.

  7. #7
    Newcomer Evination's Avatar
    Join Date
    Mar 2018
    Location
    Austria
    Posts
    10
    Thanks.

    I still have another question, how do I add a package containing the ganis etc. to the server content.
    So people download it when connecting to the server?

  8. #8
    Big Boss
    Join Date
    Nov 2017
    Posts
    33
    There are a couple things you need to do when uploading files for players to download. First, you have to upload the file to the file browser. Second, you have to set up the folder configuration so players can receive the files. Once you have done both of those things, players will automatically download files as they are displayed.

    All of the files you upload need to go in a sub-folder of the "levels" folder in the file browser if you want players to be able to download them. I'd suggest giving each different file type its own folder, so ganis go in a gani folder, heads in a head folder, etc. You can create new folders by giving yourself specific folder rights, such as:
    Code:
    rw levels/ganis/*.gani
    After you have uploaded the files, you need to make sure players have permission to download them. This is done in the folder config settings. You put the type of file, and the path to the file in there. It only looks in the levels/ folder, so you do not need to include levels/ in the path. If your ganis are uploaded to levels/ganis/ you would put the following in the folder config:
    Code:
    file ganis/*.gani
    Regular images, ganis and sounds are listed as generic "file" types in the folder config settings, some files have specific types, "body" for bodies, "head" for heads, "level" for levels etc. There is a basic RC guide over at the GraalBible: https://www.graal.net/index.php/RC_Guide that you can check out for a bit more info.

  9. #9
    Newcomer Evination's Avatar
    Join Date
    Mar 2018
    Location
    Austria
    Posts
    10
    Thanks a lot Hoyt and iMask.

    If I come up with other questions I will ask here.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •