PtokaX forum

Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) => Help with scripts => Topic started by: Aragorn on 02 November, 2008, 07:56:39

Title: greeting script
Post by: Aragorn on 02 November, 2008, 07:56:39
I have made a short script for sending a greeting message to specific profiles but well actually it's not working. it is my first script and it would be nice if someone could fix it cause I am stuck. thanks

AllowedProfiles = {
[0] = 1, -- Owner
[1] = 2, -- Masters
[2] = 3, -- SuperUser
[3] = 4, -- Operator
[4] = 5, -- KVIP
[5] = 0, -- VIP
[6] = 0, -- Reg
[7] = 0, -- UnReg
}




function UserConnected(user)
Core.GetUserAllData(user)

if AllowedProfiles[user.iProfile] == 1 or AllowedProfiles[user.iProfile] == 2 or AllowedProfiles[user.iProfile] == 3 or AllowedProfiles[user.iProfile] == 4 or AllowedProfiles[user.iProfile] == 5 then
  if AllowedProfiles[user.iProfile] == 1 then
     Core.SendToAll("---A intrat Owner-ul " ..user.sNick.. ". Aveti grija---\r\n\r\n")
Core.SendToNick(user.sNick,"??? ?????? Bine ai venit Owner -?  " ..user.sNick.. "  ?-. Simte-te bine pe hub.Ip-ul tau este:" ..user.sIP
.. "  ?????? ???\r\n\r\n")
  end
  if AllowedProfiles[user.iProfile] == 2 then
     Core.SendToAll("---A intrat Master-ul " ..user.sNick.. ". Aveti grija---\r\n\r\n")
Core.SendToNick(user.sNick,"??? ?????? Bine ai venit Master -?  " ..user.sNick.. "  ?-. Simte-te bine pe hub.Ip-ul tau este:" ..user.sIP
.. "  ?????? ???\r\n\r\n")
  end
  if AllowedProfiles[user.iProfile] == 3 then
     Core.SendToAll("---A intrat SuperUser-ul " ..user.sNick.. ". Aveti grija---\r\n\r\n")
Core.SendToNick(user.sNick,"??? ?????? Bine ai venit SuperUser -?  " ..user.sNick.. "  ?-. Simte-te bine pe hub.Ip-ul tau este:" ..user.sIP
.. "  ?????? ???\r\n\r\n")
  end
  if AllowedProfiles[user.iProfile] == 4 then
     Core.SendToAll("---A intrat OP-ul " ..user.sNick.. ". Aveti grija---\r\n\r\n")
Core.SendToNick(user.sNick,"??? ?????? Bine ai venit OP -?  " ..user.sNick.. "  ?-. Simte-te bine pe hub.Ip-ul tau este:" ..user.sIP
.. "  ?????? ???\r\n\r\n")
  end
  if AllowedProfiles[user.iProfile] == 5 then
     Core.SendToAll("---A intrat KVIP-ul " ..user.sNick.. ". Aveti grija---\r\n\r\n")
Core.SendToNick(user.sNick,"??? ?????? Bine ai venit KVIP -?  " ..user.sNick.. "  ?-. Simte-te bine pe hub.Ip-ul tau este:" ..user.sIP
.. "  ?????? ???\r\n\r\n")
  end
end

OpConnected = UserConnected
RegConnected = UserConnected


I use ptokax 0.4.1.1 and I get this error: [08:58] Syntax E:\HubSoft\0411\scripts\greet.lua:47: 'end' expected (to close 'function' at line 15) near '<eof>' (and there might be a lot more lol)
Title: Re: greeting script
Post by: ?StIfFLEr?? on 02 November, 2008, 10:55:45
i think u forgot to end the program:P
i just added one more end
see if it works
AllowedProfiles = {
[0] = 1, -- Owner
[1] = 2, -- Masters
[2] = 3, -- SuperUser
[3] = 4, -- Operator
[4] = 5, -- KVIP
[5] = 0, -- VIP
[6] = 0, -- Reg
[7] = 0, -- UnReg
}
function UserConnected(user)
Core.GetUserAllData(user)

if AllowedProfiles[user.iProfile] == 1 or AllowedProfiles[user.iProfile] == 2 or AllowedProfiles[user.iProfile] == 3 or AllowedProfiles[user.iProfile] == 4 or AllowedProfiles[user.iProfile] == 5 then
  if AllowedProfiles[user.iProfile] == 1 then
     Core.SendToAll("---A intrat Owner-ul " ..user.sNick.. ". Aveti grija---\r\n\r\n")
Core.SendToNick(user.sNick,"??? ?????? Bine ai venit Owner -?  " ..user.sNick.. "  ?-. Simte-te bine pe hub.Ip-ul tau este:" ..user.sIP
.. "  ?????? ???\r\n\r\n")
  end
  if AllowedProfiles[user.iProfile] == 2 then
     Core.SendToAll("---A intrat Master-ul " ..user.sNick.. ". Aveti grija---\r\n\r\n")
Core.SendToNick(user.sNick,"??? ?????? Bine ai venit Master -?  " ..user.sNick.. "  ?-. Simte-te bine pe hub.Ip-ul tau este:" ..user.sIP
.. "  ?????? ???\r\n\r\n")
  end
  if AllowedProfiles[user.iProfile] == 3 then
     Core.SendToAll("---A intrat SuperUser-ul " ..user.sNick.. ". Aveti grija---\r\n\r\n")
Core.SendToNick(user.sNick,"??? ?????? Bine ai venit SuperUser -?  " ..user.sNick.. "  ?-. Simte-te bine pe hub.Ip-ul tau este:" ..user.sIP
.. "  ?????? ???\r\n\r\n")
  end
  if AllowedProfiles[user.iProfile] == 4 then
     Core.SendToAll("---A intrat OP-ul " ..user.sNick.. ". Aveti grija---\r\n\r\n")
Core.SendToNick(user.sNick,"??? ?????? Bine ai venit OP -?  " ..user.sNick.. "  ?-. Simte-te bine pe hub.Ip-ul tau este:" ..user.sIP
.. "  ?????? ???\r\n\r\n")
  end
  if AllowedProfiles[user.iProfile] == 5 then
     Core.SendToAll("---A intrat KVIP-ul " ..user.sNick.. ". Aveti grija---\r\n\r\n")
Core.SendToNick(user.sNick,"??? ?????? Bine ai venit KVIP -?  " ..user.sNick.. "  ?-. Simte-te bine pe hub.Ip-ul tau este:" ..user.sIP
.. "  ?????? ???\r\n\r\n")
end
end
end

OpConnected = UserConnected
RegConnected = UserConnected

Title: Re: greeting script
Post by: ?StIfFLEr?? on 02 November, 2008, 10:56:56
the script is working here with me see if it works for u:P
i hope i saved mutors time...
Title: Re: greeting script
Post by: Aragorn on 02 November, 2008, 18:05:29
Thank you very much. I am just beggining to understand lua so I make mistakes :P
Title: Re: greeting script
Post by: ?StIfFLEr?? on 02 November, 2008, 19:39:08
no problem buddy even m learning currently till now wasnt tat sure tat i can help in scripts but for the starters ur script was nice to do with... i hope this start takes me way ahead....