PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: Dag on 27 February, 2005, 15:34:14

Title: Help with this script, please
Post by: Dag on 27 February, 2005, 15:34:14
Hi,

I need help with this script.

This is script is for redirect users, if they haven't required share.

---------------------------------------------------------------------
function ChatArrival(curUser, message)
   if curuser.iProfile == 0 ~= nil then
   s,e,cmd,param = string.find(message, "%b<>%s(.+)%s(.+)|")
   if param == nil then         
                   s,e,cmd = string.find(message, "%b<>%s(.+)|")      
                   end

   if (cmd == "!getshareredir") then
   curUser:SendPM(frmHub:GetHubSecAliasName(), "Redir users at now to: "..frmHub:GetShareRedirAddr())
   return 1
                 
         elseif (cmd == "!setshareredir") then         
         frmHub:SetShareRedirAddr(param)
         curUser:SendPM(frmHub:GetHubSecAliasName(), "You set redir to: "..frmHub:GetShareRedirAddr())
   return 1    
       end
        end
---------------------------------------------------------------------

But I want, this: !getshareredir is available for all OPerators, but  !setshareredir is available only to Masters!!

  Profiles:
Master = 0                                                                
OP = 1

Can you someone help with this, please?
 


Title:
Post by: [NL]Pur on 27 February, 2005, 15:45:43
not tested but should be something in the line of this ;)


function ChatArrival(curUser, message)
  if curuser.iProfile ~= nil then
    s,e,cmd,param = string.find(message, "%b<>%s(.+)%s(.+)|")
    if param == nil then
      s,e,cmd = string.find(message, "%b<>%s(.+)|")
    end

    if (cmd == "!getshareredir" and curUser.iProfile==1) then
      curUser:SendPM(frmHub:GetHubSecAliasName(), "Redir users at now to: "..frmHub:GetShareRedirAddr())
      return 1

    elseif (cmd == "!setshareredir" and curUser.iProfile==0) then
      frmHub:SetShareRedirAddr(param)
      curUser:SendPM(frmHub:GetHubSecAliasName(), "You set redir to: "..frmHub:GetShareRedirAddr())
      return 1
    end
  end
end  
Title: script
Post by: Dag on 27 February, 2005, 17:01:01
Hi [NL]Pur,
unfortunately that your script doesn't work, it writes : Syntax C:\PtokaX\scripts\redir.lua:3: attempt to index global `curuser' (a nil value)


thank you very much!
Title:
Post by: PPK on 27 February, 2005, 17:15:15
QuoteOriginally posted by Dag
Syntax C:\PtokaX\scripts\redir.lua:3: attempt to index global `curuser' (a nil value)
Lua si case-sensitive... replace curuser with curUser  :D
Title:
Post by: Dag on 27 February, 2005, 17:23:15
QuoteOriginally posted by PPK
Lua si case-sensitive... replace curuser with curUser  :D

Oh yes! :D
Thank you very much PPK and [NL]Pur!!! :))
Title: :)
Post by: Dag on 27 February, 2005, 19:46:47
Hello,
thank you for your advices, but I would have if OP writes !setshareredir -> PM come to him with message about not having a permission.
But without displaying !setshareredir command writen by OP in mainchat too.

THANK YOU VERY MUCH!
Title:
Post by: [NL]Pur on 27 February, 2005, 20:10:28
QuoteBut I want, this: !getshareredir is available for all OPerators, but !setshareredir is available only to Masters!!

that is what you asked ?

or is everything ok :D
Title:
Post by: Dag on 27 February, 2005, 21:46:20
QuoteOriginally posted by [NL]Pur
is everything ok :D

Yes, everything is OK! Script working perfect at the moment! ;)

But I need in to script finish off yet: if OP writes !setshareredir -> PM come to him with message about not having a permission.  :)