I'm in difficult. I'm a newbie to program in Lua. Now i work to create my first Bot. I have tried to do the command userinfo. But Ptokax give me an error.
function Arg1(data)
s,e,cmd,arg = strfind(data, "%b<>%s(%S+)%s(%S+)")
return arg
end
function UserInfo(user, data)
who = Arg1(data)
local usr = GetItemByName(who)
user:SendPM(BotName, "Informazioni:" ..usr.."|")
user:SendPM(BotName, "IP dell'utente:" ..usr.sIP.. "|")
user:SendPM(BotName, "Versione del dc:" ..usr.iVersion.."|")
end
function DataArrival(user, data)
......
......
if (cmd=="!ui) then
UserInfo(user, data)
return 1
end
end
Ptokax tell me that "who" (is a nil value)... Why??????
Please reply me...
well one error would be this:
local usr = GetItemByName(who)
user:SendPM(BotName, "Informazioni:" ..usr.."|")
if getitembyname as above then you should
call the name as you call a user. bad explaining in this.
english sucks for the moment..
here try this:
local usr = GetItemByName(who)
user:SendPM(BotName, "Informazioni:" ..usr.sName.."|")
doriangray try like this.
should give you some idea of whats going wrong.
who = Arg1(data)
if who then
local usr = GetItemByName(who)
if usr == nil then
user:SendData(BotName, who.." isn't in the hub|")
else
-- do your userinfo stuff here
end
else
user:SendData(BotName, "something gone wrong here, couldn't proces the command. who wasn't found!|")
end
if something goes wrong then try inserting some debugging lines like i did on the above.
plop
oh!! Yes :D . Thank you. Now It's all right. ;)