Results 1 to 10 of 20

Thread: [Tutorial][Work in progress] Hud elements

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #17
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    I will try it later.

    The other purpose I had with it was to print variable messages to everyone (iprintln):
    Code:
    iprintln(&"BATTLEFIELD_MONSTERKILL", player);
    Localized string:
    Code:
    REFERENCE           MONSTERKILL
    LANG_ENGLISH        "&&1 ^7- ^1MONSTER KILL !!!"
    LANG_GERMAN         "#same"
    LANG_RUSSIAN        "#same"
    Edit #1: I posted because it worked without the need of setplayernamestring(player). I copied the way it is on meatbot.
    Edit #2: I tried izno's suggestion and it seems to be the best thing to do because (1) I only need 1 hud and (2) it is now perfectly centered. Thank you very much one again.
    Just one small corretion, change
    Code:
    hud.value = x;
    for
    Code:
    hud setValue(x);
    And here is the code for a simple hud for headshots.
    1. You must create the localized string for the label:
    Code:
    REFERENCE           HEADSHOT
    LANG_ENGLISH        "^7Headshot: ^1&&1 ^7m"
    2. On player connect, set self.headshothudid to 0;
    3. Call this function with the killer
    PHP Code:
    displayHeadshot(distanceduration)
    {
        
    self.headshothudid += 1;
        
    hudid self.headshothudid;

        if(
    isdefined(self.headshothud))
        {
            
    self.headshothud destroy();
        }

        
    self.headshothud newClientHudElem(self);
        
    self.headshothud.vertAlign "top";
        
    self.headshothud.horzAlign "center";
        
    self.headshothud.alignx "center";
        
    self.headshothud.120;
        
    self.headshothud setValue(distance);
        
    self.headshothud.label = &"FILENAME_HEADSHOT";
        
    self.headshothud.fontScale 1.4;
        
    self.headshothud.alpha 1;
        
    self.headshothud.sort 5000;
        
    self.headshothud.color = (111);

        
    wait(duration);

        
    // if the player performed another headshot, there will be a new hud, which should not be affected/deleted by the old hud function
        
    if(self.headshothudid == hudid)
        {
            
    self.headshothud fadeOverTime(1);
            
    self.headshothud.alpha 0;

            
    wait(1);

            if(
    self.headshothudid == hudid)
            {
                if(
    isdefined(self.headshothud))
                {
                    
    self.headshothud destroy();
                }

                
    self.headshothudid 0;
            }
        }

    Where FILENAME is the name of your localized strings file; duration is the duration of the hud (not counting the 1 second for fading); and distance(in meters) can be given as
    Code:
    distance = int(((distance(attacker.origin , self.origin)) * 0.0254) + 0.5);
    (the +0.5 is because int will round, for example, 3.7 to 3, and I'd rather have it rounding it to the nearest int)
    Last edited by guiismiti; 25th March 2017 at 13:59.
    set logfile 2

Posting Permissions

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