Hello ppl
Well I'm trying to develop some kind of client check and I'm stuck (my skils with Lua are still very poor)
sVersion = "0.3.3cvs20040611"
sTempVer = ""
gsub(sVersion, "([0-9.])", function(x) sTempVer = sTempVer ..x end)
After this sTempVer = 0.3.3
The question is: how can I get sTemVer = 0.33 ?
(And thanks to NightLitch, from who I got some good ideas, and some pieces of code)
QuoteOriginally posted by Xico
Hello ppl
Well I'm trying to develop some kind of client check and I'm stuck (my skils with Lua are still very poor)
sVersion = "0.3.3cvs20040611"
sTempVer = ""
gsub(sVersion, "([0-9.])", function(x) sTempVer = sTempVer ..x end)
After this sTempVer = 0.3.3
The question is: how can I get sTemVer = 0.33 ?
(And thanks to NightLitch, from who I got some good ideas, and some pieces of code)
try:
gsub(sVersion, "(%d+%.([%d+%.]))", function(x) sTempVer = sTempVer ..x end)
Not sure at all, but I think it should something like that.
/NL
Well NightLitch you r my hero (don't take it wrong :) )but this time it doesn't work
From a sVersion= "0.3.3" I got a sTempVer = "0.3"
It laks the last digit
But tanks for the efort
(and sorry, but english is not my mother longuage)
Edited
and from sVersion= "0.3.020040508" I got sTempVer = "0.30.2".
Try this one then:
function Main()
sVersion = "0.3.3cvs20040611"
sTempVer = ""
sTempC = 0
msg = gsub(sVersion, "(%.)", function(x) if x and sTempC ~= 1 then sTempC = 1 return x else return "" end end)
SendToAll(msg)
end
Outcome:
0.33cvs20040611
dunno if this is how u want it...
Cheers / NL
Added a strfind to fix it like this:
sVersion = "0.3.3cvs20040611"
sTempVer = ""
sTempC = 0
_,_,sVersion = strfind(sVersion, "([%.%d]+)")
msg = gsub(sVersion, "(%.)", function(x) if x and sTempC ~= 1 then sTempC = 1 return x else return "" end end)
SendToAll(msg)
Outcome:
0.33
NL
Thanks NightLitch
I'm beeing a lot daring and i'm posting your VersionCheck() with "your" mod (I'm using it on my hub, a litle 1 with 110/150 users)
function VersionCheck(curUser, sCliente, vTag)
local sDownload = tFazerDown[sCliente]
local nVersao
local nVersaoMin
local sTempVer
local msg
sTempC = 0
_,_,sTempVer = strfind(vTag["V"], "([%.%d]+)")
msg = gsub(sTempVer, "(%.)", function(x) if x and sTempC ~= 1 then sTempC = 1 return x else return "" end end)
nVersao = tonumber(msg)
sTempC = 0
_,_,sTempVer = strfind(tVersaoCliente[sCliente], "([%.%d]+)")
msg = gsub(sTempVer, "(%.)", function(x) if x and sTempC ~= 1 then sTempC = 1 return x else return "" end end)
nVersaoMin = tonumber(msg)
-- // debug Information
--local usr = GetItemByName("Xico")
--if usr then
--usr:SendPM("Debug", "Cliente: "..sCliente.." Tag: "..vTag["V"].." MinVersion: "..nVersaoMin.." ActVersion: "..nVersao)
--end
if nVersao < nVersaoMin then
Counter["MinVer"] = Counter["MinVer"] + 1
curUser:SD(BotName,Arg(CC5, sCliente, "CLIENT", vTag["V"], "VERSION"))
curUser:SD(BotName,Arg(CC6, sCliente, "CLIENT", sVersao, "VERSION", sCliente, "CLI", sDownload, "DL"))
curUser:Disconnect()
end
end
Once more, many thanks for your help
Your welcome m8