+ Reply to Thread
Results 1 to 7 of 7

Thread: using entity discovery + findPlayerByName

  1. #1
    Wire Noob hammer whore's Avatar
    Join Date
    Mar 2009
    Posts
    6

    Unhappy using entity discovery + findPlayerByName

    ok, so i am trying to understand 2 things, how to use the find() function along with entity classes, and models, and i am trying to use findPlayerByName() to find players through the chat system.

    my current understanding of find() is very basic, this is all i would do:

    findIncludeModel("wood")
    ENT = find()

    so i pretty much am blind with entity discovery.


    and findPlayerByName(), i am oriented with, here is my code for it:

    if(owner():lastSaid():index(1)=="/")
    {Target = findPlayerByName(lastSaid():sub(2,lastSaid():lengt h)}

    i think i am doin it right, but all my turrets and protectors do when i use this method is point at vec(0,0,0) ITS REALLY ANNOYING

    any help would be extremely apreciated

  2. #2
    Wiremod Helper Donkie's Avatar
    Join Date
    May 2008
    Location
    Sweden
    Posts
    1,661

    Default Re: using entity discovery + findPlayerByName

    If they point at 0,0,0 it means it cant find a target. I dont understand what you want to get out though. Do you want to target the player who last said "/"?
    Get out. Seriously, do it.

  3. #3
    Wiremod Helper Lyinginbedmon's Avatar
    Join Date
    Mar 2009
    Location
    England
    Posts
    2,659

    Default Re: using entity discovery + findPlayerByName

    Either it's not finding a target or the point-at-target code is messed up.

    If we're assuming the case-sensitive name is being entered properly after "/", I'd use something like:[highlight=E2]Mes = owner():lastSaid()

    Target = Mes:right(Mes:length()-1)[/highlight]

    Which will cut out the "/" and leave the player name.

  4. #4
    Wire Amateur no_one's Avatar
    Join Date
    Mar 2009
    Posts
    88

    Default Re: using entity discovery + findPlayerByName

    find is much nicer. Although I would put in a word like

    [highlight=e2]if (owner():latsSaid():find("/find ")) {
    Target = findPlayerByName(Owner:lastSaid():sub(7, owner():lastSaid():length()))
    }[/highlight]
    New to Expression 2? Read this: E2 Guide [WIP]
    Steam ID ► Easton741
    Connect Now!

  5. #5
    Wire Noob fughilli's Avatar
    Join Date
    Jul 2009
    Posts
    1

    Question Re: using entity discovery + findPlayerByName

    So, I took some code from around the forums and compiled it into this overhead floater, which, in theory, should float over my head, play and stop music, stop following me, have a lololol trail, and follow other people. I used the find command idea using "/follow " trigger. I haven't tested this yet, but I just wanted to know someone's opinion on it.

    Cheers!

    Code:
    @name AwesomeChip
    @persist Vectorz:vector Vector:vector E:entity CurPos:vector
    #Timers and trails
    #YES, I KNOW THAT I COPIED PEOPLES' SCRIPTS. I JUST WANTED TO USE THEM AS A BASE FOR MY OWN.
    #If anyone has any problems with me copying them, I will remove them from the thread.
    if(first())
    {
        runOnTick(1)
        runOnChat(1)
        
        entity():setTrails(50,50,3,"trails/lol",vec(255,255,255),200)
    }
    
    
    #If run on game ticks
    if(tickClk())
    {
    if(entity():isConstrained()) {
        E=entity():isConstrainedTo()
        } 
        else {
            E=entity()
            }
    
    Vector=owner():pos()-E:pos()+vec(0,0,100)
    E:applyForce(1*(2*Vector+30*$Vector))
    }
    
    
    #When something is said
    if(chatClk(owner())){
         Said = owner():lastSaid():lower()
         if(Said:find("/music_disco")){
            hint("Music: HL1 Disco Remix", 5)
              entity():soundPlay(1,0,"music/HL1_song25_REMIX3.mp3")
         }
    }
    #When something is said
    if(chatClk(owner())){
         Said = owner():lastSaid():lower()
         if(Said:find("/music_stillalive")){
            hint("Music: Still Alive", 5)
              entity():soundPlay(1,0,"music/portal_still_alive.mp3")
         }
    if(chatClk(owner())){
         Said = owner():lastSaid():lower()
         if(Said:find("/music_rock")){
            hint("Music: Combine Theme", 5)
              entity():soundPlay(1,0,"music/hl2_song15.mp3")
         }
    }
         if(Said:find("/nomusic")){
            hint("Music off", 5)
              soundStop(1)
          }
    }
        if(Said:find("/stay")){
            Follow = 0
            hint("Staying at current world position", 5)
            CurPos = E:pos()
        
    }
    if(Said:find("/followme")){
            Follow = 1
            hint("Following you", 5)
            CurPos = E:pos()
        
    }
    if (owner():latsSaid():find("/follow ")) {
    Follow = 0
    Name = Owner:lastSaid():sub(9, owner():lastSaid():length())
    Target = findPlayerByName(Name)
    Vectorz=Target:pos()-E:pos()+vec(0,0,100)
    E:applyForce(1*(2*Vectorz+30*$Vectorz))
    hint("Following "+ Name, 5)
    }
     
        if(Follow == 0){
            if(tickClk())
    {
    if(entity():isConstrained()) {
        E=entity():isConstrainedTo()
        } 
        else {
            E=entity()
            }
            
    }
    }

  6. #6
    billywitchdoctor.com Whosdr's Avatar
    Join Date
    Dec 2008
    Posts
    2,300

    Default Re: using entity discovery + findPlayerByName

    you didn't persist Name or Target.
    .siht daer ot gniyrt emit detsaw ev'uoY

  7. #7
    Wire Amateur abysal's Avatar
    Join Date
    Sep 2008
    Posts
    55

    Default Re: using entity discovery + findPlayerByName

    Quote Originally Posted by Whosdr View Post
    you didn't persist Name or Target.
    You don't need to. you miss spelled lastSaid and owner() at two spots, btw.

+ Reply to Thread

Similar Threads

  1. Entity Discovery, LUA error after a few tries.
    By vortexnl in forum Expression 2 Discussion & Help
    Replies: 0
    Last Post: 05-21-2009, 07:33 AM
  2. Entity Discovery Searching
    By Playzr in forum Expression 2 Discussion & Help
    Replies: 9
    Last Post: 05-16-2009, 10:04 AM
  3. Learning Entity Discovery.
    By vortexnl in forum Expression 2 Discussion & Help
    Replies: 10
    Last Post: 05-03-2009, 04:16 PM
  4. Entity Discovery Bugs
    By goluch in forum Expression 2 Discussion & Help
    Replies: 9
    Last Post: 04-19-2009, 02:06 PM
  5. Expression 2 - Entity Discovery
    By chiss in forum Expression 2 Discussion & Help
    Replies: 12
    Last Post: 03-17-2009, 01:02 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots