+ Reply to Thread
Results 1 to 10 of 10

Thread: Entity Discovery Searching

  1. #1
    Wire Amateur Playzr's Avatar
    Join Date
    May 2007
    Location
    UK
    Posts
    93

    Default Entity Discovery Searching

    I'm having some trouble with entity discovery. When i first spawn my exp2 gate it works and finds the props i want, but if I want to do a 2nd search it doesnt work, and when i dupe it, i have to update the exp2 gate so that it searches. I want to know how I can properly reset my search and start a new one.

    This is the searching part of the code that i was using

    Code:
    findByModel("models/hunter/plates/plate025.mdl")
    findIncludePlayerProps(owner())
    findSortByDistance(entity():pos())
    Keys= findToArray()

  2. #2
    Wirererer Masogir's Avatar
    Join Date
    Mar 2008
    Posts
    292

    Default Re: Entity Discovery Searching

    Quote Originally Posted by Playzr View Post
    I'm having some trouble with entity discovery. When i first spawn my exp2 gate it works and finds the props i want, but if I want to do a 2nd search it doesnt work, and when i dupe it, i have to update the exp2 gate so that it searches. I want to know how I can properly reset my search and start a new one.

    This is the searching part of the code that i was using

    Code:
    findByModel("models/hunter/plates/plate025.mdl")
    findIncludePlayerProps(owner())
    findSortByDistance(entity():pos())
    Keys= findToArray()
    Use a toggled button for this:
    Code:
    @inputs Button
    @persist Keys:array
    
    if(!Button&~Button) {
        findByModel("models/hunter/plates/plate025.mdl")
        findIncludePlayerProps(owner())
        findSortByDistance(entity():pos())
        Keys= findToArray()
    }
    
    if(Button&~Button) {
        #You can do an completely new search for this one.
        Keys= findToArray()
    }
    This is just an example for only 2 searches. If you need more help with this, post more of your E2 because I'm not exactly sure what you're trying to do.

    EDIT:
    I just made one that will search for 5 different models. Keep in mind that the strings you set in Model:array are being used with findByModel(). Make sure to use a no-toggled button for this one.

    Code:
    @inputs Button
    @persist Keys:array Model:array N
    
    Model:setString(1,"models/hunter/plates/plate025.mdl")
    Model:setString(2,"<model 2>")
    Model:setString(3,"<model 3>")
    Model:setString(4,"<model 4>")
    Model:setString(5,"<model 5>")
    
    if(Button&~Button) {
        N = N%5+1
        findByModel(Model:string(N))
        findIncludePlayerProps(owner())
        findSortByDistance(entity():pos())
        Keys= findToArray()
    }
    This is just another example of how you can do this.
    Last edited by Masogir; 05-15-2009 at 10:34 PM.

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

    Default Re: Entity Discovery Searching

    Mm, i have same problem but with > 5 findPlayerByName. Would i be able to make some sort of timer to switch between all finds?
    Code:
    @name PA Armor giver
    @inputs 
    @outputs MichA CookieA DonkieA AchmedA
    @persist Donkie:entity 
    @persist Mich:entity 
    @persist Cookie:entity 
    @persist Achmed:entity 
    @trigger all    
    interval(1000)   
     
        Donkie=findPlayerByName("Donkie")
        DonkieA=Donkie:isAlive()
        if(DonkieA&$DonkieA){concmd("ulx armor donkie 175")}
        
        Cookie=findPlayerByName("Cookie")
        CookieA=Cookie:isAlive()
        if(CookieA&$CookieA){concmd("ulx armor cookie 175")}
        
        Mich=findPlayerByName("Michael")
        MichA=Mich:isAlive()
        if(MichA&$MichA){concmd("ulx armor mich 175")}
        
        Achmed=findPlayerByName("Achmed")
        AchmedA=Achmed:isAlive()
        if(AchmedA&$AchmedA){concmd("ulx armor achmed 175")}
    Edit: It will give armor to those guys when they respawn automaticly.
    Get out. Seriously, do it.

  4. #4
    Wirererer Masogir's Avatar
    Join Date
    Mar 2008
    Posts
    292

    Default Re: Entity Discovery Searching

    Quote Originally Posted by donkan View Post
    Mm, i have same problem but with > 5 findPlayerByName. Would i be able to make some sort of timer to switch between all finds?

    Edit: It will give armor to those guys when they respawn automaticly.
    I'm sorry but I just had to just completely re-do your code . Let me know if it doesn't work.


    Code:
    @name PA Armor giver
    @persist Player:entity Name:array N
    interval(1000)  
     
    N = N%4+1
    
    Name:setString(1,"Donkie")
    Name:setString(2,"Cookie")
    Name:setString(3,"Michael")
    Name:setString(4,"Achmed")
    
    
    if($N) {
        Player=findPlayerByName(Name:string(N))
        if(Player:armor() != 175&Player:isAlive()){concmd("ulx armor "+Name:string(N)+" 175")}
    }
    OOPS! Important EDIT: added &Player:isAlive() and changed the concmd() line to fit the Name:array and not Player:name().
    Last edited by Masogir; 05-16-2009 at 12:17 AM.

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

    Default Re: Entity Discovery Searching

    Ty :3

    ......
    Get out. Seriously, do it.

  6. #6
    Wire Amateur Playzr's Avatar
    Join Date
    May 2007
    Location
    UK
    Posts
    93

    Default Re: Entity Discovery Searching

    Thanks Masogir. I'm sure I'm triggering my search correctly, it's just that it doesnt seem to work twice, like as though the search parameters were getting mixed up with previous finds.

    Can I assume 2 searches would work like this

    Code:
    findByModel("models/hunter/plates/plate025.mdl")
    findIncludePlayerProps(owner())
    findSortByDistance(entity():pos())
    Keys= findToArray()
    
    findByModel("models/hunter/plates/plate05.mdl")
    findIncludePlayerProps(owner())
    findSortByDistance(entity():pos())
    Otherthings= findToArray()
    Do I need to remove my models from the white list before I do another search? Or are all the search parameters like model/player cleared when i run one of the find functions? Doing 2 searches hasn't worked for me yet, even with the same way. It's entirely possible that I'm just not running the search at the right time, but I've been trying endlessly and I'm pretty certain the search part is what is causing it to only find things once.

    Edit: When I do the 2nd search, it just finds the first prop type again.
    Last edited by Playzr; 05-16-2009 at 07:29 AM.

  7. #7
    Wirererer Masogir's Avatar
    Join Date
    Mar 2008
    Posts
    292

    Default Re: Entity Discovery Searching

    Quote Originally Posted by Playzr View Post
    Thanks Masogir. I'm sure I'm triggering my search correctly, it's just that it doesnt seem to work twice, like as though the search parameters were getting mixed up with previous finds.

    Can I assume 2 searches would work like this

    Code:
    findByModel("models/hunter/plates/plate025.mdl")
    findIncludePlayerProps(owner())
    findSortByDistance(entity():pos())
    Keys= findToArray()
    
    findByModel("models/hunter/plates/plate05.mdl")
    findIncludePlayerProps(owner())
    findSortByDistance(entity():pos())
    Otherthings= findToArray()
    Do I need to remove my models from the white list before I do another search? Or are all the search parameters like model/player cleared when i run one of the find functions? Doing 2 searches hasn't worked for me yet, even with the same way. It's entirely possible that I'm just not running the search at the right time, but I've been trying endlessly and I'm pretty certain the search part is what is causing it to only find things once.

    Edit: When I do the 2nd search, it just finds the first prop type again.
    The problem is you are trying to find things WAY too fast and E2 will not allow you to find 2 things at the same time due to wire_exp2_entFindRate and wire_exp2_playerFindRate (the wiki will give you a better description of what those are). If you just want continuously search for 2 models without a button, you can do this:
    [highlight=e2]#It is VERY important you put these in persist or it won't store what it finds
    @persist Keys:array Otherthings:array N

    #I'm using a timer assuming you have interval(10) or runOnTick(1) in your full expression
    timer("find",500) #This will run an internal timer every 1/2 second
    if(clk("find")) {N = !N} #ever 1/2 second N will go from 0 to 1 to 0 ect...

    #If N is 0 and change of N, it will do this search and store what it finds in Keys:array
    if(!N&$N) {
    findByModel("models/hunter/plates/plate025.mdl")
    findIncludePlayerProps(owner())
    findSortByDistance(entity()os())
    Keys= findToArray()
    }

    #If N is 1 and change of N, it will do this search and store what it finds in Otherthings:array
    if(N&$N) {
    findByModel("models/hunter/plates/plate05.mdl")
    findIncludePlayerProps(owner())
    findSortByDistance(entity()os())
    Otherthings= findToArray()
    }[/highlight]

  8. #8
    Wire Amateur Playzr's Avatar
    Join Date
    May 2007
    Location
    UK
    Posts
    93

    Default Re: Entity Discovery Searching

    Thanks very much, I'll try that. So I need to space them apart. Can I use findUpdateRate() to find out how far apart they need to be?

  9. #9
    Wirererer Masogir's Avatar
    Join Date
    Mar 2008
    Posts
    292

    Default Re: Entity Discovery Searching

    Quote Originally Posted by Playzr View Post
    Thanks very much, I'll try that. So I need to space them apart. Can I use findUpdateRate() to find out how far apart they need to be?
    Absolutely. Change timer("find",500) to timer("find",findUpdateRate()*1000).

  10. #10
    Wire Amateur Playzr's Avatar
    Join Date
    May 2007
    Location
    UK
    Posts
    93

    Default Re: Entity Discovery Searching

    Thanks again . FYI this is for an entity keyboard with 0 buttons. The keys are stored in an array in the correct order. I just needed to find the other 'buttons'. Now I'll put some delays in the process and it will hopefully find all the buttons at the start.

+ Reply to Thread

Similar Threads

  1. Entity discovery - Not targetting prop spawners.
    By Jonds in forum Expression 2 Discussion & Help
    Replies: 9
    Last Post: 05-05-2009, 11:18 AM
  2. Learning Entity Discovery.
    By vortexnl in forum Expression 2 Discussion & Help
    Replies: 10
    Last Post: 05-03-2009, 04:16 PM
  3. Entity Discovery Bugs
    By goluch in forum Expression 2 Discussion & Help
    Replies: 9
    Last Post: 04-19-2009, 02:06 PM
  4. Expression 2 - Entity Discovery
    By chiss in forum Expression 2 Discussion & Help
    Replies: 12
    Last Post: 03-17-2009, 01:02 PM
  5. E2 Entity Discovery, findResult , Loops?
    By Dave-X in forum Expression 2 Discussion & Help
    Replies: 4
    Last Post: 02-09-2009, 01:13 PM

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