Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: Lasers (SCRIPT)

  1. #11
    Private
    Join Date
    Jan 2013
    Posts
    15
    Thanks
    3
    Thanked 4 Times in 3 Posts
    I made something like this :

    [sharp]trap1()
    {
    kosa = getent("kosa_1", "targetname");
    kosa_kill = getent("kosa_2", "targetname");
    kosa_kill enablelinkto();
    kosa_kill linkto(kosa);
    {
    kosa movex(82,5,2);
    wait (0.5);
    kosa movex(-82,5,2);
    wait (0.5);
    }
    }[/sharp]

    And it gives me that error:

    Attachment 189

  2. #12
    Private
    Join Date
    Mar 2013
    Posts
    12
    Thanks
    2
    Thanked 6 Times in 5 Posts
    @BaX

    PHP Code:
    main()
    {

    thread OnPlayerConnect();


    PHP Code:
    OnPlayerConnect()
    {

    for(;;)
    {

    level waittill("connecting"user);
    user thread trap1();

    }


    PHP Code:
    trap1()
    {
    kosa getent("kosa_1""targetname");
    kosa_kill getent("kosa_2""targetname");
    kosa_kill enablelinkto(); //i think it's useless
    kosa_kill linkto(kosa);
    while(
    1)
    {
    kosa movex(82,5,2);
    wait 0.5;
    kosa movex(-82,5,2);
    wait 0.5;
    }


  3. #13
    Private
    Join Date
    Jan 2013
    Posts
    15
    Thanks
    3
    Thanked 4 Times in 3 Posts
    It means that i need to add all traps which have linkto into this line ?

  4. #14
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by BaX View Post
    I made something like this :

    [sharp]trap1()
    {
    kosa = getent("kosa_1", "targetname");
    kosa_kill = getent("kosa_2", "targetname");
    kosa_kill enablelinkto();
    kosa_kill linkto(kosa);
    {
    kosa movex(82,5,2);
    wait (0.5);
    kosa movex(-82,5,2);
    wait (0.5);
    }
    }[/sharp]

    And it gives me that error:

    Attachment 189
    When you get an error like that - calling an entity for which there is more than 1 - it is telling you that you need to use getEntArray() (plural) and not getEnt() (singlular).

    When you use getEntArray() you must use a for() loop to find each member of the entity set. So, this is what you want:

    PHP Code:
    trap1()
    {
        
    kosa getentArray("kosa_1""targetname");
        
    kosa_kill getentArray("kosa_2""targetname");
        
        for( 
    i=0kosa.sizei++ )
        {
            for( 
    j=0kosa_kill.sizej++ )
            {
                
    kosa_kill[jenablelinkto();
                
    kosa_kill[jlinktokosa[i] );

                
    kosa[imovex(82,5,2);
                
    wait0.5 );
                
    kosa[imovex(-82,5,2);
                
    wait0.5 );
            }
        }


  5. #15
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by kat_ View Post
    @BaX

    PHP Code:
    main()
    {

    thread OnPlayerConnect();


    PHP Code:
    OnPlayerConnect()
    {

    for(;;)
    {

    level waittill("connecting"user);
    user thread trap1();

    }


    PHP Code:
    trap1()
    {
    kosa getent("kosa_1""targetname");
    kosa_kill getent("kosa_2""targetname");
    kosa_kill enablelinkto(); //i think it's useless
    kosa_kill linkto(kosa);
    while(
    1)
    {
    kosa movex(82,5,2);
    wait 0.5;
    kosa movex(-82,5,2);
    wait 0.5;
    }

    That code completely ignores the error stated in his first post, as it is still using getEnt() and not getEntArray().

  6. #16
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    @Tally

    Your code would make the lasers wait for one another to finish their "run"

  7. #17
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by IzNoGoD View Post
    @Tally

    Your code would make the lasers wait for one another to finish their "run"
    It's not "my code". I was merely demonstrating how to use for() loops to find each member of a class. I did not test the code for efficiency or otherwise. You really do need to stop thinking everything is some sort of contest, where you are always the hero.

  8. #18
    Private
    Join Date
    Jan 2013
    Posts
    15
    Thanks
    3
    Thanked 4 Times in 3 Posts
    Ok thanks a lot for help it worked

    But i have one more problem do you know why this trap work only once?

    PHP Code:
    trap5()
    {
        
    reka getent("reka_1""targetname");
        
    trig getent("t3","targetname");
        
    reka_kill getent("reka_kill""targetname");
        
    reka_kill enablelinkto();
        
    reka_kill linkto(reka);
        {
            
    trig waittill ("trigger");

            
    reka movex(208,0.7);
            
    reka waittill ("movedone");
            
    wait (0.5);
            
    reka movex(-208,0.7);
            
    reka waittill ("movedone");
            
    wait (6);
        }


  9. #19
    Private First Class
    Join Date
    Dec 2012
    Posts
    127
    Thanks
    132
    Thanked 114 Times in 63 Posts
    PHP Code:
    reka movex(208,0.7);
    reka waittill ("movedone");
    wait (0.5);
    reka movex(-208,0.7);
    reka waittill ("movedone");
    wait (6); 
    should be in a loop or thread it as loop... I'm not sure which method is better and correct.
    Last edited by Jeplaa; 7th March 2013 at 07:11.

  10. #20
    Private
    Join Date
    Jan 2013
    Posts
    15
    Thanks
    3
    Thanked 4 Times in 3 Posts
    But can you made example script for me?

Posting Permissions

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