Openkore.com
http://forums.openkore.com/

How can I get chat room player name?
http://forums.openkore.com/viewtopic.php?f=32&t=211846
Page 1 of 1

Author:  bluesky [ 10 Apr 2017, 15:51 ]
Post subject:  How can I get chat room player name?

I want to get player real name in chat.
I used command "chat info" to catch it.

Code:
[list] -----------Chat Room Info-----------
Title                     Users   Public/Private
[list]                           2/      Private
[list] -- Users --
[list] 0   test°                       
[list] 1   mo mo                     


Question 1:
Behind name had many space.
name + space = 27 Character

Question 2:
If player name had space?
example name:mo mo



my test macro
Code:
automacro test1 {
   pubm /game start/i
        call {
           do chat info

        }
}
automacro test2 {
   console /0\ \ \ \ (.*)\ \[(.*)\](.*)\((\d+)\, (\d+)\)/i
        exclusive 1
        call {
           do pm '$.lastMatch1' 123

        }
}


How can I get real name to pm?
maybe should modify message TF source code, let surplus space do not show?
Thank you~

Author:  Mortimal [ 11 Apr 2017, 01:15 ]
Post subject:  Re: How can I get chat room player name?

Data is stored in global. So to get first man in chat room:

Code:
@eval($::currentChatRoomUsers[0])

Author:  bluesky [ 11 Apr 2017, 05:45 ]
Post subject:  Re: How can I get chat room player name?

Mortimal wrote:
Data is stored in global. So to get first man in chat room:

Code:
@eval($::currentChatRoomUsers[0])


It's worked!
Thank you!! :D

But I have a little problem

example
Code:
           
$chatnumber = 0
while ($chatnumber < 20)as loop
   $chatnumber++

   $player$chatnumber = @eval($::currentChatRoomUsers[$chatnumber])

end loop



$player$chatnumber is wrong
I tried
Code:
$player$chatnumber
'$player$chatnumber'
"$player$chatnumber"
$player'$chatnumber'
$player"$chatnumber"
$player+$chatnumber
$player+"$chatnumber"
$player+'$chatnumber'
$player $chatnumber

have other method can use varible on varible-name?

Thank you very much!

Author:  Mortimal [ 11 Apr 2017, 07:16 ]
Post subject:  Re: How can I get chat room player name?

Gets list of users in chatroom(maybe xD ) stores it in $s:
Code:
$s = @eval(print "@::currentChatRoomUsers")


Gets n user from list $s:
Code:
@arg ("$s", n)


Output list of users in chatroom:
Code:
$s = @eval(print "@::currentChatRoomUsers")
$chatnumber = 0
while ($chatnumber < 20) as loop
   $chatnumber++
   log @arg ("$s", $chatnumber)
end loop


try that... i dont know what your aim is so -_-

Author:  bluesky [ 11 Apr 2017, 08:27 ]
Post subject:  Re: How can I get chat room player name?

Mortimal wrote:
Gets list of users in chatroom(maybe xD ) stores it in $s:
Code:
$s = @eval(print "@::currentChatRoomUsers")


Gets n user from list $s:
Code:
@arg ("$s", n)


Output list of users in chatroom:
Code:
$s = @eval(print "@::currentChatRoomUsers")
$chatnumber = 0
while ($chatnumber < 20) as loop
   $chatnumber++
   log @arg ("$s", $chatnumber)
end loop


try that... i dont know what your aim is so -_-




:D :D
thank you a lot :lol:

Author:  bluesky [ 13 Apr 2017, 14:19 ]
Post subject:  Re: How can I get chat room player name?

Mortimal wrote:
try that... i dont know what your aim is so -_-


hello
I have got a little problem@@
although I got the player name and set to varible $player1

If the player name only have number
example:
Code:
$player1 = 321654
do pm "$player1" test


always got error message
Code:
Quick look-up 321654 not exist


because :(
<pm list #>
- a corresponding number from the pm list when you use the pml command.

I tried always error
Code:
"$.lastpm"
$.lastpm
'$.lastpm'
"$player1"
$player1
'$player1'


how can I pm to a number man?
thank you~

Author:  Mortimal [ 13 Apr 2017, 15:41 ]
Post subject:  Re: How can I get chat room player name?

w8 il look up for this in souce code

.....

ok we got bug here..... fixing

.....

src/Commands.pm line 4137
replace:
Code:
   } elsif ($user =~ /^\d+$/) {

with:
Code:
   } elsif ($user =~ /^[^"]{1}\d+[^"]{1}$/) {

add before line 4152:
Code:
$user =~ s/^\"(.*)\"$/\1/;


my pull request https://github.com/OpenKore/openkore/pull/550/files

Now will work:
Code:
pm "1234434" Hello World!

Author:  bluesky [ 14 Apr 2017, 04:05 ]
Post subject:  Re: How can I get chat room player name?

Mortimal wrote:
Code:
$user =~ s/^\"(.*)\"$/\1/;


my pull request https://github.com/OpenKore/openkore/pull/550/files


Thank you, but your line-4152 code had two version?
Code:
in here:
$user =~ s/^\"(.*)\"$/\1/;

in github:
$user =~ s/^\"(.*)\"$/$1/;


I download your github openkore
then I tried both version,but still Quick look-up 321654 does not exist :(
pm "321654" hello

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/