Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Expression 2 v
« Previous 1 … 4 5 6 7 8 Next »
HELP! with find()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pages (2): 1 2 Next »
Threaded Mode
HELP! with find()
19-02-2015, 01:43 PM,
#1
Alanzote Offline
TSCM Member
***
Posts: 123
Threads: 40
Joined: Oct 2013
HELP! with find()
Hi!, I am making a transporter EGP, and I use findByClass("player") to search for players and display them on the screen, but when I press a button on the EGP, it searches for a trasporter pad, with a specific owner, this especific owner is the one we selected on the screen, but I can't use findResult(1) in the other search, so, Is there a way that I can use a variable that fixes the Entity name on it, without using findResult(NUM)? Because it is checking for the 1st pad it finds owner, not the selected one!

Thank ypu for your attention,
Alanzote.

[Image: stargate_kawoosh_animation_HD_by_SergeyDruid.gif] [Image: kecepatan-cahaya-light-speed-warp-drive2....gif?w=640]
Find
Reply
20-02-2015, 10:18 PM,
#2
Alanzote Offline
TSCM Member
***
Posts: 123
Threads: 40
Joined: Oct 2013
RE: HELP! with find()
Anyone?

[Image: stargate_kawoosh_animation_HD_by_SergeyDruid.gif] [Image: kecepatan-cahaya-light-speed-warp-drive2....gif?w=640]
Find
Reply
20-02-2015, 11:38 PM,
#3
Blackhawk Offline
GMod Admin
Posts: 204
Threads: 9
Joined: Sep 2013
RE: HELP! with find()
You can store the players in an array:
Code:
Players = findByClass("player")

Then you can access the players by their find index with:
Code:
Players[index]

I'm not 100% sure if it works exactly like that in e2 (haven't used e2 for a while).
Find
Reply
21-02-2015, 04:52 AM,
#4
TheOneAndOnlyTee Offline
GMod Admin
Posts: 755
Threads: 47
Joined: Oct 2013
RE: HELP! with find()
Better to just use since it's less ops
Code:
if(changed(players()){ Players = players() }

Then just access it as Black said, also remember to persist Players:array

Steam Profile
My Discord Server
Need help with E2 or SF? , just ask me and i'll try to help.
[Image: 98Dkcoz.gif]
Find
Reply
21-02-2015, 11:59 AM, (This post was last modified: 21-02-2015, 12:00 PM by Alanzote.)
#5
Alanzote Offline
TSCM Member
***
Posts: 123
Threads: 40
Joined: Oct 2013
RE: HELP! with find()
(20-02-2015, 11:38 PM)Blackhawk Wrote: You can store the players in an array:
Code:
Players = findByClass("player")

Then you can access the players by their find index with:
Code:
Players[index]

I'm not 100% sure if it works exactly like that in e2 (haven't used e2 for a while).
I got an Error: "No such Operator: get array[normal]"

(21-02-2015, 04:52 AM)T-16 Wrote: Better to just use since it's less ops
Code:
if(changed(players()){ Players = players() }

Then just access it as Black said, also remember to persist Players:array
I also got an Error: "No Such function: Changed(array)"

[Image: stargate_kawoosh_animation_HD_by_SergeyDruid.gif] [Image: kecepatan-cahaya-light-speed-warp-drive2....gif?w=640]
Find
Reply
21-02-2015, 02:31 PM,
#6
Blackhawk Offline
GMod Admin
Posts: 204
Threads: 9
Joined: Sep 2013
RE: HELP! with find()
This code should help you. It prints a list of all players into the chat:
Code:
@name Player-List @persist Players:array Players = players() for (I=1, Players:count()) { print(Players[I, entity]:name()) }
Find
Reply
22-02-2015, 01:35 AM,
#7
TheOneAndOnlyTee Offline
GMod Admin
Posts: 755
Threads: 47
Joined: Oct 2013
RE: HELP! with find()
oh right didn't see that, Fix:
Code:
if(changed(players():count())){ Players = players() }
and if you wanted to know how you could display an entire list for your screen, Example:
Code:
@name Example Array Draw @inputs EGP:wirelink @persist Players if(first()|duped()|changed(EGP)){ EGP:egpBox(1,vec2(256,256),vec2(512,512)) EGP:egpColor(1,vec(0,164,255)) EGP:egpBox(2,vec2(256,256),vec2(492,492)) EGP:egpColor(2,vec(41,41,41)) Players = players() for(I =1,Players:count()){ EGP:egpText(2+I,Players[I,entity]:name(),vec2(50,50*I)) EGP:egpColor(2+I,vec(0,164,255)) } }

Steam Profile
My Discord Server
Need help with E2 or SF? , just ask me and i'll try to help.
[Image: 98Dkcoz.gif]
Find
Reply
28-02-2015, 01:59 PM,
#8
Alanzote Offline
TSCM Member
***
Posts: 123
Threads: 40
Joined: Oct 2013
RE: HELP! with find()
When it prints, it shows something like that:
[Player, [1],[NAME]][Player, [2]...][Player, [3]...][Player, [5]...][Player, [7]...][Player, [8]...] as you can see it jumps some numbers.

[Image: stargate_kawoosh_animation_HD_by_SergeyDruid.gif] [Image: kecepatan-cahaya-light-speed-warp-drive2....gif?w=640]
Find
Reply
28-02-2015, 02:46 PM,
#9
Blackhawk Offline
GMod Admin
Posts: 204
Threads: 9
Joined: Sep 2013
RE: HELP! with find()
As far as I know, the player index jumps some numbers because players are leaving/joining all the time, which manipulates the index. The important thing is, does it show all players or are there some names missing?
Find
Reply
28-02-2015, 04:56 PM,
#10
Alanzote Offline
TSCM Member
***
Posts: 123
Threads: 40
Joined: Oct 2013
RE: HELP! with find()
(28-02-2015, 02:46 PM)Blackhawk Wrote: As far as I know, the player index jumps some numbers because players are leaving/joining all the time, which manipulates the index. The important thing is, does it show all players or are there some names missing?
No missing players, but I think the numbers should be allways 1,2,3,4,5... because it is bugging with my E2, so then you are selecting the wrong player.

[Image: stargate_kawoosh_animation_HD_by_SergeyDruid.gif] [Image: kecepatan-cahaya-light-speed-warp-drive2....gif?w=640]
Find
Reply
« Next Oldest | Next Newest »
Pages (2): 1 2 Next »


  • View a Printable Version
Forum Jump:


Users browsing this thread:
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.