Jump to content

string.find problem


Blinker.

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.

Link to comment
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 )

Link to comment
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 

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...