Author Topic: it shouldn't show your own info...  (Read 3060 times)

0 Members and 1 Guest are viewing this topic.

Offline blackwings

  • Scripter
  • King
  • ******
  • Posts: 986
  • Karma: +12/-8
it shouldn't show your own info...
« on: 12 June, 2005, 14:36:29 »
Im making my own userinfo script just for fun and its almost finished, except when you use the command, it shows your own userinfo, not the username you wrote. Can anyone help me, because I cant see whats wrong, I must be blind :P
Code: [Select]
-- Userinfo 1.0 by blackwings

sBot = "#userinfo"

tPrefix = frmHub:GetPrefixes()

function ChatArrival(user, data)
return CmdUserInfo(user,data)
end
function ToArrival(user,data)
return CmdUserInfo(user,data)
end

function CmdUserInfo(user, data)
local s,e,Cmd,Name = string.find( data, "%b<>%s+(%S+)%s+(%S+)" )
local sCounter = 0
if IfValidCMD(Cmd, "userinfo") and user.bOperator then
return theUserInfo(user, data)
end
end

function IfValidCMD(sIsCMD, sWhatCMD)
for sIndex in tPrefix do
if sIsCMD == (tPrefix[sIndex]..sWhatCMD) then
return 1
end
end
end

cMode = ""
cDesc = ""
cEmail = ""

function theUserInfo(user, data)
cProfileNr = GetUserProfile(user.sName)
cProfile = GetProfileName(cProfileNr)
unitGB = 1073741824
cShare = user.iShareSize/unitGB
cShareSize = string.format("%0.2f %s",cShare,"")
if user.bActive then
cMode = "Active"
elseif not user.bActive then
cMode = "Passive"
end
if user.sDescription=="" then
cDesc = "None"
elseif not user.sDescription=="" then
cDesc = user.sDescription
end
if user.sEmail=="" then
cEmail = "None"
elseif not user.sEmail=="" then
cEmail = user.sEmail
end

cMsg = "\r\n\r\n"
cMsg = cMsg.."\t ################################## \r\n"
cMsg = cMsg.."\t # User info ########################## \r\n"
cMsg = cMsg.."\t ################################## \r\n"
cMsg = cMsg.."\t - Username: "..user.sName.." \r\n"
cMsg = cMsg.."\t - User Profile: "..cProfile.." \r\n"
cMsg = cMsg.."\t - User IP: "..user.sIP.." \r\n"
cMsg = cMsg.."\t - Client: "..user.sClient.." \r\n"
cMsg = cMsg.."\t - Version: "..user.sClientVersion.." \r\n"
cMsg = cMsg.."\t - User iVersion: "..user.iVersion.." \r\n"
cMsg = cMsg.."\t - User description: "..cDesc.." \r\n"
cMsg = cMsg.."\t - User Tag: "..user.sTag.." \r\n"
cMsg = cMsg.."\t - Mode: "..cMode.." \r\n"
cMsg = cMsg.."\t - Connection: "..user.sConnection.." \r\n"
cMsg = cMsg.."\t - User email: "..cEmail.." \r\n"
cMsg = cMsg.."\t - Share Size: "..cShareSize.." \r\n"
cMsg = cMsg.."\t ----------- \r\n"
cMsg = cMsg.."\t - Normal Hub Count: "..user.iNormalHubs.." \r\n"
cMsg = cMsg.."\t - Regged Hub Count: "..user.iRegHubs.." \r\n"
cMsg = cMsg.."\t - Operator Hub Count: "..user.iOpHubs.." \r\n"
cMsg = cMsg.."\t - Total Hub Count: "..user.iHubs.." \r\n"
cMsg = cMsg.."\t - Slots Count: "..user.iSlots.." \r\n"
cMsg = cMsg.."\t ---------------------------------------------------- \r\n"
user:SendPM(sBot, cMsg)
return 1
end


PtokaX forum

it shouldn't show your own info...
« on: 12 June, 2005, 14:36:29 »

Offline Pothead

  • Lord
  • ***
  • Posts: 455
  • Karma: +25/-4
(No subject)
« Reply #1 on: 12 June, 2005, 15:50:18 »
You are getting all the info of user instead of Name. :)
« Last Edit: 12 June, 2005, 15:51:06 by Pothead »

Offline blackwings

  • Scripter
  • King
  • ******
  • Posts: 986
  • Karma: +12/-8
(No subject)
« Reply #2 on: 12 June, 2005, 16:03:20 »
Quote
Originally posted by Pothead
You are getting all the info of user instead of Name. :)
First I did this =
Code: [Select]
return theUserInfo(user, data, Name)

function theUserInfo(user, data, Name)
end
then I changed all .user to .Name in function theUserInfo(). But it didn't work and I get this error message =
Code: [Select]
[15:55] Syntax C:\ptokax\scripts\userinfo.lua:35: attempt to index local `Name' (a string value)
« Last Edit: 12 June, 2005, 16:03:51 by blackwings »


Offline Dessamator

  • Scripter
  • Emperor
  • ******
  • Posts: 1 262
  • Karma: +13/-9
(No subject)
« Reply #3 on: 12 June, 2005, 16:53:50 »
u got it all wrong the prob is here
Code: [Select]
return theUserInfo(user, data)
hint :
first of all uve got to think like this, there are two user names, one who is sending and one who is receiving :)
Ignorance is Bliss.

Offline Pothead

  • Lord
  • ***
  • Posts: 455
  • Karma: +25/-4
(No subject)
« Reply #4 on: 12 June, 2005, 16:58:27 »
Try sommit like this: :)
Code: [Select]
function CmdUserInfo(user, data)
local s,e,Cmd,NameInText = string.find( data, "%b<>%s+(%S+)%s+(%S+)" )
local sCounter = 0
if IfValidCMD(Cmd, "userinfo") and user.bOperator then
local ActualUser = GetItemByName(NameInText)
return theUserInfo(user, data, ActualUser)
end
end
***Edit***Maybe need to check if the user is actually online, to stop if trying to perform operations on a NIL value. :)
« Last Edit: 12 June, 2005, 17:01:35 by Pothead »

Offline ??????Hawk??????

  • Emperor
  • **
  • Posts: 1 044
  • Karma: +12/-2
    • Leeds Laptop Repairs
(No subject)
« Reply #5 on: 12 June, 2005, 17:02:17 »
Try something like this  ..  

ive not tested it ..  but its closer to what your aiming at


Code: [Select]
-- Userinfo 1.0 by blackwings

sBot = "#userinfo"

tPrefix = frmHub:GetPrefixes()

function ChatArrival(user, data)
return CmdUserInfo(user,data)
end
function ToArrival(user,data)
return CmdUserInfo(user,data)
end

function CmdUserInfo(user, data)
local s,e,Cmd,Name = string.find( data, "%b<>%s+(%S+)%s+(%S+)" )
local sCounter = 0
if IfValidCMD(Cmd, "userinfo") and user.bOperator then
return theUserInfo(user, data, Name)
end
end

function IfValidCMD(sIsCMD, sWhatCMD)
for sIndex in tPrefix do
if sIsCMD == (tPrefix[sIndex]..sWhatCMD) then
return 1
end
end
end

cMode = ""
cDesc = ""
cEmail = ""

function theUserInfo(user, data, Name)
local INFO = GetItemByName(Name)
if INFO == nil then
curUser:SendData(bot_name1,"The user is offline..!")
return 1
end

cProfileNr = GetUserProfile(INFO.sName)
cProfile = GetProfileName(cProfileNr)
unitGB = 1073741824
cShare = INFO.iShareSize/unitGB
cShareSize = string.format("%0.2f %s",cShare,"")
if INFO.bActive then
cMode = "Active"
elseif not INFO.bActive then
cMode = "Passive"
end
if INFO.sDescription=="" then
cDesc = "None"
elseif not INFO.sDescription=="" then
cDesc = INFO.sDescription
end
if INFO.sEmail=="" then
cEmail = "None"
elseif not INFO.sEmail=="" then
cEmail = INFO.sEmail
end

cMsg = "\r\n\r\n"
cMsg = cMsg.."\t ################################## \r\n"
cMsg = cMsg.."\t # User info ########################## \r\n"
cMsg = cMsg.."\t ################################## \r\n"
cMsg = cMsg.."\t - Username: "..INFO.sName.." \r\n"
cMsg = cMsg.."\t - User Profile: "..cProfile.." \r\n"
cMsg = cMsg.."\t - User IP: "..INFO.sIP.." \r\n"
cMsg = cMsg.."\t - Client: "..INFO.sClient.." \r\n"
cMsg = cMsg.."\t - Version: "..INFO.sClientVersion.." \r\n"
cMsg = cMsg.."\t - User iVersion: "..INFO.iVersion.." \r\n"
cMsg = cMsg.."\t - User description: "..cDesc.." \r\n"
cMsg = cMsg.."\t - User Tag: "..INFO.sTag.." \r\n"
cMsg = cMsg.."\t - Mode: "..cMode.." \r\n"
cMsg = cMsg.."\t - Connection: "..INFO.sConnection.." \r\n"
cMsg = cMsg.."\t - User email: "..cEmail.." \r\n"
cMsg = cMsg.."\t - Share Size: "..cShareSize.." \r\n"
cMsg = cMsg.."\t ----------- \r\n"
cMsg = cMsg.."\t - Normal Hub Count: "..INFO.iNormalHubs.." \r\n"
cMsg = cMsg.."\t - Regged Hub Count: "..INFO.iRegHubs.." \r\n"
cMsg = cMsg.."\t - Operator Hub Count: "..INFO.iOpHubs.." \r\n"
cMsg = cMsg.."\t - Total Hub Count: "..INFOr.iHubs.." \r\n"
cMsg = cMsg.."\t - Slots Count: "..INFO.iSlots.." \r\n"
cMsg = cMsg.."\t ---------------------------------------------------- \r\n"
user:SendPM(sBot, cMsg)
return 1
end

Offline Dessamator

  • Scripter
  • Emperor
  • ******
  • Posts: 1 262
  • Karma: +13/-9
(No subject)
« Reply #6 on: 12 June, 2005, 17:37:18 »
lol, hawk and pothead ur "spoon feeding" him, hes trying to learn, its better to give hint than the answer :)
Ignorance is Bliss.

Offline ??????Hawk??????

  • Emperor
  • **
  • Posts: 1 044
  • Karma: +12/-2
    • Leeds Laptop Repairs
(No subject)
« Reply #7 on: 12 June, 2005, 17:55:28 »
Quote
Originally posted by Dessamator
lol, hawk and pothead ur "spoon feeding" him, hes trying to learn, its better to give hint than the answer :)

Maby  BUT it is blackwings ( not a Noob ) , he will still learn from it.   :P

Offline Dessamator

  • Scripter
  • Emperor
  • ******
  • Posts: 1 262
  • Karma: +13/-9
(No subject)
« Reply #8 on: 12 June, 2005, 17:58:54 »
hmm, indeed maybe im wrong in this case :)
Ignorance is Bliss.

Offline blackwings

  • Scripter
  • King
  • ******
  • Posts: 986
  • Karma: +12/-8
(No subject)
« Reply #9 on: 13 June, 2005, 05:39:43 »
thanx you, hawk,Pothead &  Dessamator. hmm, that was pretty obvious, I should have seen that :rolleyes: .

I also noticed another couple of problems too which I fixed :D
One of them was the way I checked the  profile on the target. Anyway its fixed and here is the code if anyone is interested :P =
Code: [Select]
-- Userinfo 1.3 by blackwings
-- FIXED: bug in local s,e,Cmd, Name
-- FIXED: bug with targets profile which caused problems
-- FIXED: bug with targets username - Thx ??????Hawk??????

sBot = "#userinfo"

tPrefix = frmHub:GetPrefixes()

function ChatArrival(user, data)
return CmdUserInfo(user,data)
end
function ToArrival(user,data)
return CmdUserInfo(user,data)
end

function CmdUserInfo(user, data)
local s,e,Cmd, Name = string.find(data, "%b<>%s+(%S+)%s*(%S*).*|")
if IfValidCMD(Cmd, "userinfo") and user.bOperator then
return theUserInfo(user, data, Name)
end
end

function IfValidCMD(sIsCMD, sWhatCMD)
for sIndex in tPrefix do
if sIsCMD == (tPrefix[sIndex]..sWhatCMD) then
return 1
end
end
end

cMode = ""
cDesc = ""
cEmail = ""
cProfile = ""

function theUserInfo(user, data, Name)
local onWho = GetItemByName(Name)
if onWho == nil then
user:SendData(sBot,"The user is offline..!")
return 1
end

if onWho.iProfile==0 then
cProfile = "Master"
elseif onWho.iProfile==1 then
cProfile = "Operator"
elseif onWho.iProfile==2 then
cProfile = "VIP"
elseif onWho.iProfile==3 then
cProfile = "REG"
elseif onWho.iProfile==-1 then
cProfile = "Normal"
end

unitGB = 1073741824
cShare = onWho.iShareSize/unitGB
cShareSize = string.format("%0.2f %s",cShare,"")
if onWho.bActive then
cMode = "Active"
elseif not onWho.bActive then
cMode = "Passive"
end
if onWho.sDescription=="" then
cDesc = "None"
elseif not onWho.sDescription=="" then
cDesc = onWho.sDescription
end
if onWho.sEmail=="" then
cEmail = "None"
elseif not onWho.sEmail=="" then
cEmail = onWho.sEmail
end

cMsg = "\r\n\r\n"
cMsg = cMsg.."\t ################################## \r\n"
cMsg = cMsg.."\t # User info ########################## \r\n"
cMsg = cMsg.."\t ################################## \r\n"
cMsg = cMsg.."\t - Username: "..onWho.sName.." \r\n"
cMsg = cMsg.."\t - User Profile: "..cProfile.." \r\n"
cMsg = cMsg.."\t - User IP: "..onWho.sIP.." \r\n"
cMsg = cMsg.."\t - Client: "..onWho.sClient.." \r\n"
cMsg = cMsg.."\t - Version: "..onWho.sClientVersion.." \r\n"
cMsg = cMsg.."\t - User iVersion: "..onWho.iVersion.." \r\n"
cMsg = cMsg.."\t - User description: "..cDesc.." \r\n"
cMsg = cMsg.."\t - User Tag: "..onWho.sTag.." \r\n"
cMsg = cMsg.."\t - Mode: "..cMode.." \r\n"
cMsg = cMsg.."\t - Connection: "..onWho.sConnection.." \r\n"
cMsg = cMsg.."\t - User email: "..cEmail.." \r\n"
cMsg = cMsg.."\t - Share Size: "..cShareSize.." \r\n"
cMsg = cMsg.."\t ----------- \r\n"
cMsg = cMsg.."\t - Normal Hub Count: "..onWho.iNormalHubs.." \r\n"
cMsg = cMsg.."\t - Regged Hub Count: "..onWho.iRegHubs.." \r\n"
cMsg = cMsg.."\t - Operator Hub Count: "..onWho.iOpHubs.." \r\n"
cMsg = cMsg.."\t - Total Hub Count: "..onWho.iHubs.." \r\n"
cMsg = cMsg.."\t - Slots Count: "..onWho.iSlots.." \r\n"
cMsg = cMsg.."\t ---------------------------------------------------- \r\n"
user:SendPM(sBot, cMsg)
return 1
end


PtokaX forum

(No subject)
« Reply #9 on: 13 June, 2005, 05:39:43 »