PtokaX forum

Development Section => Your Developing Problems => Topic started by: NightLitch on 22 January, 2004, 14:02:22

Title: Resolving the Tag from Table.
Post by: NightLitch on 22 January, 2004, 14:02:22
I must suck... :-) don't get this working.

AllowClient = {
["DC++"] = "<++",
}

function ParseMyInfo(MyInfo)
local s,e,vTag = strfind( MyInfo , "^%$MyINFO %$ALL [^ ]+ [^$]([^$<>]+)>%$" )
local s,e,vSpeed,sShare = strfind( MyInfo, "^%$MyINFO %$ALL [^ ]+ [^$]*%$ $([^$]+)[^$]%$[^$]*%$%s*(%d+)%$" )
local vShare = tonumber(sShare)

--- HELP HERE
if strfind(vTag, AllowClient[??]) then
vClient = AllowClient[??]
else
vClient = "Unknown"
end
--- HELP HERE

return vClient, vTag, vSpeed, vShare
end

function NewUserConnected(curUser)
local vClient, vTag, vSpeed, vShare = ParseMyInfo(curUser.sMyInfoString)
SendToAll("C: "..Client.." TAG: "..Tag.." Speed: "..Speed.." Share: "..Share)
end

help me out somebody
Title:
Post by: c h i l l a on 22 January, 2004, 15:17:16
well thing is if you want to call a index of a table you will need to know what the index is..

so need a for i,v in AllowClient do
to run through all clinets..

is stripped this from LIS.
It open anyways.. so you can see the whole script if you want anyways.. well my strfind isn't so advanced as yours but working.



local _,_,nickdescr,share = strfind(data,"^$MyINFO $ALL ([^$]+)%$ %$[^$]*%$[^$]*%$(%d+)%$|$")

SplitInfoString(share,nickdescr)

-------------------------------------------------------------------------------------------------------------------------------------------
--// *** Do SPLIT MyINFO ***
-------------------------------------------------------------------------------------------------------------------------------------------
ClientDetec = {
{ "<%+%+","oDC" },
{ "<%+%+","DC++" },
{ "{ "{ "http://dc.ketelhot.de","DCGUI" },
{ "}
function SplitInfoString(share,InfoString)
local client,version,mode,hubs,slots = "N/A","N/A","N/A","N/A","N/A"
for i = 1,getn(ClientDetec) do
if strfind(InfoString,ClientDetec[i][1]) then
client = ClientDetec[i][2]
end
end
_,_,version,mode,hubs,slots = strfind(InfoString,"V:(%S+),M:(%w+),H:(%S+),S:(%d+)")
share = share / (1024 * 1024 * 1024)
share = format("%.2f",share)
return { client,version,mode,hubs,slots,share }
end
Title:
Post by: NightLitch on 22 January, 2004, 16:44:18
Solved it thx. Notice a bug in the strfind to...