PtokaX forum

Development Section => Your Developing Problems => Topic started by: ??Empie?? on 16 December, 2003, 14:41:43

Title: if not
Post by: ??Empie?? on 16 December, 2003, 14:41:43
Im working on a script that check needs an if not statement:

I have experience with other programming languages but not Lua, and I am trying to get this work:

if !(strfind(description,"<++")) then
curUser:SendPM(botname, "Hello "..curUser.sName..". Your client is too old or incorrect. Upgrade to the following: Windows 98: [URL]http://dcplusplus.sourceforge.net,[/URL] Windows 2K/XP: [URL]http://dcplusplus.sourceforge.net[/URL] or [URL]http://www.neo-modus.com,[/URL] MacOS: [URL]http://dc.ketelhot.de,[/URL] Linux: [URL]http://dc.ketelhot.de.[/URL]")
curUser:Disconnect()
end

the if !(blabla) doesn't seem to work, and even after searching this forum, lua.org and google I cant seem to get my hands on the right syntax.

Can anyone please help me with it (I feel kinda stupid becouse the problem seems so simple)?

p.s. the whole script contains a lot more code, but this part gives enough to see what I mean I think :)
Title:
Post by: kepp on 16 December, 2003, 15:46:04
if (strfind(description,"<++")) then
curUser:SendPM(botname, "Hello "..curUser.sName..". Your client is too old or incorrect. Upgrade to the following: Windows 98: [URL]http://dcplusplus.sourceforge.net,[/URL] Windows 2K/XP: [URL]http://dcplusplus.sourceforge.net[/URL] or [URL]http://www.neo-modus.com,[/URL] MacOS: [URL]http://dc.ketelhot.de,[/URL] Linux: [URL]http://dc.ketelhot.de.[/URL]")
curUser:Disconnect()
end

First you don't need any "!"..
Then everything look just great, exept for one thing, depends if "description" is Equal to curUser.sMyInfoString that is...

I prefer this way:

CheckDCPP = { "<++" }

if not (strfind(user.sMyInfoString,CheckDCPP,1,1)) then
      curUser:SendPM(botname, "Hello "..curUser.sName..". Your client is too old or incorrect. Upgrade to the following: Windows 98: [URL]http://dcplusplus.sourceforge.net,[/URL] Windows 2K/XP: [URL]http://dcplusplus.sourceforge.net[/URL] or [URL]http://www.neo-modus.com,[/URL] MacOS: [URL]http://dc.ketelhot.de,[/URL] Linux: [URL]http://dc.ketelhot.de.[/URL]")
curUser:Disconnect()
Title:
Post by: ??Empie?? on 16 December, 2003, 16:57:34
I got it working finally!

I did it like this:

function NewUserConnected(curUser)
ClientOK=0
if (strfind(curUser.sMyInfoString," ClientOK=1
end
if (strfind(curUser.sMyInfoString,"<++",1,1)) then
ClientOK=1
end
if (strfind(ClientOK,"0",1,1)) then
      curUser:SendPM(botname, "Hello "..curUser.sName..". Your client is too old or incorrect. Upgrade to the following: Windows 98: [URL]http://dcplusplus.sourceforge.net,[/URL] Windows 2K/XP: [URL]http://dcplusplus.sourceforge.net[/URL] or [URL]http://www.neo-modus.com,[/URL] MacOS: [URL]http://dc.ketelhot.de,[/URL] Linux: [URL]http://dc.ketelhot.de.[/URL]")
curUser:Disconnect()
end
end

thx for the example kepp!

everybody feel free to use this scriptpart, it disconnects users who don't have a neat nmdc v2.x, dc++, dcgui or oDC tag.

I've implemented this rule in my hub becouse I suspect a lot of tag-less users of being nmdc v1 fakers, which I cannot inspect, but since for every operating system now is a descent client with tag this solves it :)
Title:
Post by: tezlo on 16 December, 2003, 17:09:15
or..function NewUserConnected(curUser)
if strfind(curUser.sMyInfoString," else curUser:SendPM(botname, "Hello "..curUser.sName..". Your client is too old or incorrect. Upgrade to the following: Windows 98: [URL]http://dcplusplus.sourceforge.net,[/URL] Windows 2K/XP: [URL]http://dcplusplus.sourceforge.net[/URL] or [URL]http://www.neo-modus.com,[/URL] MacOS: [URL]http://dc.ketelhot.de,[/URL] Linux: [URL]http://dc.ketelhot.de.[/URL]")
curUser:Disconnect()
end
end
Title:
Post by: kepp on 16 December, 2003, 17:22:02
Yep, oDC uses the same tag as dc++