How can I get chat room player name?

All about the macro plugin can be found in this forum. This forum is intended for the macro plugin only.

Moderator: Moderators

Post Reply
Message
Author
bluesky
Noob
Noob
Posts: 13
Joined: 15 Feb 2016, 02:09
Noob?: No

How can I get chat room player name?

#1 Post by bluesky »

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

Code: Select all

[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: Select all

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~

Mortimal
Developers
Developers
Posts: 389
Joined: 01 Nov 2008, 15:31
Noob?: No

Re: How can I get chat room player name?

#2 Post by Mortimal »

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

Code: Select all

@eval($::currentChatRoomUsers[0])
Please use pin function for uploading your file contents!

bluesky
Noob
Noob
Posts: 13
Joined: 15 Feb 2016, 02:09
Noob?: No

Re: How can I get chat room player name?

#3 Post by bluesky »

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

Code: Select all

@eval($::currentChatRoomUsers[0])
It's worked!
Thank you!! :D

But I have a little problem

example

Code: Select all

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

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

end loop

$player$chatnumber is wrong
I tried

Code: Select all

$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!

Mortimal
Developers
Developers
Posts: 389
Joined: 01 Nov 2008, 15:31
Noob?: No

Re: How can I get chat room player name?

#4 Post by Mortimal »

Gets list of users in chatroom(maybe xD ) stores it in $s:

Code: Select all

$s = @eval(print "@::currentChatRoomUsers")
Gets n user from list $s:

Code: Select all

@arg ("$s", n)
Output list of users in chatroom:

Code: Select all

$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 -_-
Please use pin function for uploading your file contents!

bluesky
Noob
Noob
Posts: 13
Joined: 15 Feb 2016, 02:09
Noob?: No

Re: How can I get chat room player name?

#5 Post by bluesky »

Mortimal wrote:Gets list of users in chatroom(maybe xD ) stores it in $s:

Code: Select all

$s = @eval(print "@::currentChatRoomUsers")
Gets n user from list $s:

Code: Select all

@arg ("$s", n)
Output list of users in chatroom:

Code: Select all

$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:

bluesky
Noob
Noob
Posts: 13
Joined: 15 Feb 2016, 02:09
Noob?: No

Re: How can I get chat room player name?

#6 Post by bluesky »

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: Select all

$player1 = 321654
do pm "$player1" test
always got error message

Code: Select all

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: Select all

"$.lastpm"
$.lastpm
'$.lastpm'
"$player1"
$player1
'$player1'
how can I pm to a number man?
thank you~

Mortimal
Developers
Developers
Posts: 389
Joined: 01 Nov 2008, 15:31
Noob?: No

Re: How can I get chat room player name?

#7 Post by Mortimal »

w8 il look up for this in souce code

.....

ok we got bug here..... fixing

.....

src/Commands.pm line 4137
replace:

Code: Select all

	} elsif ($user =~ /^\d+$/) {
with:

Code: Select all

	} elsif ($user =~ /^[^"]{1}\d+[^"]{1}$/) {
add before line 4152:

Code: Select all

$user =~ s/^\"(.*)\"$/\1/;
my pull request https://github.com/OpenKore/openkore/pull/550/files

Now will work:

Code: Select all

pm "1234434" Hello World!
Please use pin function for uploading your file contents!

bluesky
Noob
Noob
Posts: 13
Joined: 15 Feb 2016, 02:09
Noob?: No

Re: How can I get chat room player name?

#8 Post by bluesky »

Mortimal wrote:

Code: Select all

$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: Select all

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

Post Reply