Anybody that knows E2 & the findPlayerByName() function, I need your help!
5 replies, posted
I am making a TF2 style capture point, but it uses a chat command of !blueteam and !redteam to set the teams which are up to a maximum of 4 each, but it only sets the first team member of the command, HELP!
[code]
@name Cap point
@model models/props_gameplay/cap_point_base.mdl
@inputs Target:entity Target1 Target2
@persist Red:entity Reda:entity Redb:entity Redc:entity Blue:entity Bluea:entity Blueb:entity Bluec:entity Tick Iscaptured Redcap Bluecap
#Team fortress 2 Capture point: By Fatman55
if(first() == 1)
{
runOnTick(1)
runOnChat(1)
Iscaptured = 0
Tick = 0
entity():setSkin(0)
entity():soundPlay(0, 0, "common/null.wav")
}
if( chatClk(owner()) )
{
ChatArray = owner():lastSaid():explode(" ")
if(ChatArray:string(1) == "!blueteam")
{
Blue = findPlayerByName(ChatArray:string(2))
Bluea = findPlayerByName(ChatArray:string(3))
Blueb = findPlayerByName(ChatArray:string(4))
Bluec = findPlayerByName(ChatArray:string(5))
hint("Blue team: " + Blue:name() + ", "
+ Bluea:name() + ", " + Blueb:name() + ", "
+ Bluec:name() , 10)
}
if( ChatArray:string(1) == "!redteam")
{
Red = findPlayerByName(ChatArray:string(2))
Red2 = findPlayerByName(ChatArray:string(3))
Red3 = findPlayerByName(ChatArray:string(4))
Red4 = findPlayerByName(ChatArray:string(5))
}
}
if(Target2 == 1){Target1 = 0}
if(tickClk() & Target1 == 1){Tick += 1}
elseif(Target1 == 0 & Iscaptured == 0){Tick = 0}
if(Tick == 250)
{
if
(
Target:name() == Blue:name() & Bluecap == 0|
Target:name() == Bluea:name() & Bluecap == 0|
Target:name() == Blueb:name() & Bluecap == 0|
Target:name() == Bluec:name() & Bluecap == 0
)
{
entity():soundPlay(0, 0, "music/portal_still_alive.mp3")
entity():setSkin(2)
print("Point captured by blue!")
Redcap = 0
Bluecap = 1
}
if
(
Target:name() == Red:name() & Redcap == 0|
Target:name() == Red2:name() & Redcap == 0|
Target:name() == Red3:name() & Redcap == 0|
Target:name() == Red4:name() & Redcap == 0
)
{
entity():soundPlay(0, 0, "music/portal_4000_degrees_kelvin.mp3")
entity():setSkin(1)
print("Point captured by red!")
Redcap = 1
Bluecap = 0
}
}
[/code]
You should post this on the wiremod forums.
I do not have a wiremod forum account.
You can only run the find function once every 100ms (1/10th second). Thus, the code above will not work.
[QUOTE=whosdr;22745518]You can only run the find function once every 100ms (1/10th second). Thus, the code above will not work.[/QUOTE]
Thank you, so I just need to add a 100ms delay between them?
just do
[code]@persist Target:entity
if (findCanQuery()) {Target = findPlayerByName("whatever")}[/code]
Sorry, you need to Log In to post a reply to this thread.