Page 1 of 3 123 LastLast
Results 1 to 10 of 30

Thread: how to call a value from another function?

  1. #1
    Private
    Join Date
    Jul 2016
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post

    how to call a value from another function?

    how to call a value from another function?

    for exmple i have test()
    and i wanna call from it a value 'slot' for example is it possible?

  2. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Not sure what you mean with your question. Here's a few examples:
    PHP Code:
    foo()
    {
        
    bar();
        
    iprintlnbold(a);
    }

    bar()
    {
        return 
    "hello world";

    PHP Code:
    foo()
    {
        
    iprintlnbold(bar());
    }

    bar()
    {
        return 
    "hello world";

    PHP Code:
    foo()
    {
        
    bar("world");
        
    iprintlnbold(a);
    }
    bar(asdf)
    {
        return 
    "hello " asdf;

    PHP Code:
    foo()
    {
        
    iprintlnbold(bar("hello""world"));
    }

    bar(asdfjkl)
    {
        return 
    asdf " " jkl;


    All these functions result in an iprintlnbold("hello world");
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  3. #3
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    Quote Originally Posted by xulikav View Post
    how to call a value from another function?

    for exmple i have test()
    and i wanna call from it a value 'slot' for example is it possible?
    test() call slot;


    or did you mean:
    PHP Code:
    test() 
    {
    // self is whatever the function called, for example player 
    if( isDefinedself ) )
    /* do something */ }
    }

    player test(); 
    Last edited by serthy; 23rd July 2016 at 12:46.

  4. #4
    Private
    Join Date
    Jul 2016
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post
    i wanna call slot not the function the slot inside the function
    Callback_PlayerDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, psOffsetTime)

    like if (swepon ==slot)

    do some shit

    test()
    {
    self endon("disconnect");
    self notify("start_sprinting");

    sprint_weap="iwx_sprint_mp";
    slot="";

    {

  5. #5
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    i still have no idea what you're trying to do. Explain better.

    Use code tags.

    Learn how to report on forums

    Learn some english.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  6. #6
    Private
    Join Date
    Jul 2016
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post
    do you see the slot=""; inside the test funtion i wanna call it in another function

  7. #7
    Private Paho's Avatar
    Join Date
    Feb 2014
    Location
    Russia
    Posts
    101
    Thanks
    43
    Thanked 48 Times in 37 Posts
    Quote Originally Posted by xulikav View Post
    slot="";
    This visible within a given function
    Use level or self or return;
    return slot;
    Code:
    test()
    {
    //... use if()
    slot="kot";
    //... use if()
    slot="pog";
    //... use if()
    slot="";
    //...
    return slot;
    }
    Code:
    CodeCallback_PlayerCommand(args)
    {
    self endon("disconnect");
    //...
    if(args[0]=="test")
    {
    iprintlnbold(test());//output: kot |or| pog |or| "" - using if()
    return;
    }
    //...
    }
    Last edited by Paho; 23rd July 2016 at 14:25.

  8. The Following User Says Thank You to Paho For This Useful Post:

    maxdamage99 (23rd July 2016)

  9. #8
    Private
    Join Date
    Jul 2016
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post
    i dont mean this
    i mean this

    CodeCallback_PlayerCommand(args)
    {
    self endon("disconnect");

    bingband=slot; /// how to call this slot from another function
    }


    test()

    {
    slot=3;/// i want to call the 3 to the other function how ?
    }

  10. #9
    Private Paho's Avatar
    Join Date
    Feb 2014
    Location
    Russia
    Posts
    101
    Thanks
    43
    Thanked 48 Times in 37 Posts
    CodeCallback_PlayerCommand(args)
    {
    self endon("disconnect");
    bingband=test();
    }
    test()
    {
    slot=3;
    return slot;
    }
    Last edited by Paho; 23rd July 2016 at 14:53.

  11. The Following User Says Thank You to Paho For This Useful Post:

    maxdamage99 (23rd July 2016)

  12. #10
    Private
    Join Date
    Jul 2016
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post
    test()
    {
    bosswp(slot)=3; // i want the 3 go to the bosswp function how to write that? is my writing correct?
    return slot;
    }




    bosswp(slot)
    {
    slotboss=slot;
    return slot;
    }

Posting Permissions

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