Author Topic: if not  (Read 1749 times)

0 Members and 1 Guest are viewing this topic.

Offline ??Empie??

  • Junior Member
  • **
  • Posts: 11
  • Karma: +0/-0
if not
« 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:

Code: [Select]
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 :)
« Last Edit: 16 December, 2003, 14:42:08 by ??Empie?? »

PtokaX forum

if not
« on: 16 December, 2003, 14:41:43 »

Offline kepp

  • Scripter
  • King
  • ******
  • Posts: 790
  • Karma: +2/-0
(No subject)
« Reply #1 on: 16 December, 2003, 15:46:04 »
Code: [Select]
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:

Code: [Select]
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()
Guarding    

Offline ??Empie??

  • Junior Member
  • **
  • Posts: 11
  • Karma: +0/-0
(No subject)
« Reply #2 on: 16 December, 2003, 16:57:34 »
I got it working finally!

I did it like this:

Code: [Select]
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 :)

Offline tezlo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +1/-0
(No subject)
« Reply #3 on: 16 December, 2003, 17:09:15 »
or..
Code: [Select]
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

Offline kepp

  • Scripter
  • King
  • ******
  • Posts: 790
  • Karma: +2/-0
(No subject)
« Reply #4 on: 16 December, 2003, 17:22:02 »
Yep, oDC uses the same tag as dc++
Guarding    

PtokaX forum

(No subject)
« Reply #4 on: 16 December, 2003, 17:22:02 »