Sign in to follow this  
Blinker.

string.find problem

Recommended Posts

Hello Folks,

i've a problem with string.find , i am trying to do if the guy who's spectating another guy is on the list then highlight his name.

i have 2 tables :

1 - deathlist

2 - speclist

if the guy in the speclist is 1 of the people in deathlist then

highlight his name

thats my code

  
for i ,v in ipairs (speclist) do 
for k , s in ipairs (deathlist) do 
if string.find(getUncolored(v),getUncolored(s),3,false) then 
  
r ,g ,b = 255,153,0 
outputDebugString("spectator: ".. getUncolored(v).." "..getUncolored(s)) 
else 
r ,g ,b = 255,255,255 
outputDebugString("no spectator: ".. getUncolored(v).." "..getUncolored(s)) 
  
end 
end 
end 
  
  
  
  

i don't know why it's not working the color stays white ,

when i am spectating a guy called KnoX,

it outputs: INFO:no spectator: [LoA]KnoX 3) [LoA]KnoX ...

i don't know why it doesn't find [LoA]KnoX in 3) [LoA]KnoX

thanks in advance.

Share this post


Link to post
for i ,v in ipairs (speclist) do 
for k , s in ipairs (deathlist) do 
local v = v:gsub("([%*%+%?%.%(%)%[%]%{%}%\%/%|%^%$%-])","%%%1") 
local s = s:gsub("([%*%+%?%.%(%)%[%]%{%}%\%/%|%^%$%-])","%%%1") 
if string.find(getUncolored(v),getUncolored(s),3,false) then 
  
r ,g ,b = 255,153,0 
outputDebugString("spectator: ".. getUncolored(v).." "..getUncolored(s)) 
else 
r ,g ,b = 255,255,255 
outputDebugString("no spectator: ".. getUncolored(v).." "..getUncolored(s)) 
  
end 
end 
end 

because there's [ in his name ( not only if there's [ even if there's [,],(,) etc )

Share this post


Link to post

at first you dont have to use string.find

just use equal (v == s)

second are you sure your tables looks like that or something like that

table = {"Player1","Player2","Player3"} 

Share this post


Link to post

no man i have to use string.find because i use PlayerRank..") " .. playername in tables

it will return like that

table = {"1) Blinker" , "2) anyone"}

Share this post


Link to post

wtf?

Use player elements, or serials if u want the script to highlight the spectator's nick even after he reconnected

Share this post


Link to post
wtf?

Use player elements, or serials if u want the script to highlight the spectator's nick even after he reconnected

ithink he's script a deathlist so he dont have to use elements as you said.

Idont know if this is exactly what do you want to do,

table1 = {"1) Player1","2) Player2","3) Player3"} 
table2 = {"2) Player2","1) Player1"} 
  
for k,v1 in ipairs(table1) do 
    for k,v2 in ipairs(table2) do 
        if v1:gsub(".-%) ","") == v2:gsub(".-%) ","") then 
        print(v1:gsub(".-%) ","").." - "..v2:gsub(".-%) ","")) 
        end 
    end 
end 

Share this post


Link to post

no man ,

  
deathlist = { 1) playername1 (whokilledplayer1) , 2) playername2 , 3)playername3 
speclist = { spectatorname1 , spectatorname2 } 
  

player2 and player3 no one killed them so no "(whokilledplayer)"

Share this post


Link to post

Can you just explain more what you are trying to do and post your codes?

Share this post


Link to post

ok add me at skype : Mikaelkh98 , i will come after 30 mins because i have a clanwar now sorry , thank you

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.