PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: Psycho_Chihuahua on 26 May, 2005, 18:25:47

Title: [request] User Profile Upgrade/Downgrade
Post by: Psycho_Chihuahua on 26 May, 2005, 18:25:47
What i'm looking for is a script with which one can up-/downgrade Userprofiles.....

Would be great if it would work with Profile numbers instead of Profile Names though (as a lot of ppl have custom profiles.

up-/Downgrade example:

reg to VIP/OP/Master
VIP to Reg/OP/Master
OP to Reg/VIP/Master
Master to Reg/Vip/OP and so on

Could someone be so kind  :D

Title:
Post by: Markitos on 26 May, 2005, 19:34:15
QuoteOriginally posted by Psycho_Chihuahua
What i'm looking for is a script with which one can up-/downgrade Userprofiles.....

Would be great if it would work with Profile numbers instead of Profile Names though (as a lot of ppl have custom profiles.

up-/Downgrade example:

reg to VIP/OP/Master
VIP to Reg/OP/Master
OP to Reg/VIP/Master
Master to Reg/Vip/OP and so on

Could someone be so kind  :D



Use robocop...
Title:
Post by: Psycho_Chihuahua on 26 May, 2005, 19:45:54
well a standalone would be more appropriate because i have german Users and they dont understand english thats why i requested one  :D
Title:
Post by: Madman on 26 May, 2005, 21:57:57
This should do it...

-- Up/Down-grade script
-- Made by Madman

Bot = "UpDownGrade"

function ChatArrival(curUser, data)
local data = string.sub(data, 1, -2)
local s,e,cmd = string.find(data, "%b<>%s+[%!%+%?%#](%S+)")
if cmd then
local tCmds = {
["upgrade"] = function(curUser, data)
if curUser.bOperator then
local s,e,Nick,pNr = string.find(data, "%b<>%s+%S+%s+(%S+)%s+(%d+)") -- Catch Nick and pNr
if not Nick or not pNr then -- We didn't find them
curUser:SendData(Bot, "I need a nick and a profile nr") return 1
end
if tonumber(pNr) >= 4 then -- If pNr higer then 4
curUser:SendData(Bot, "Profile number to high!") return 1 -- Stop the upgrade
end
if curUser.sName == Nick then -- You can't upgrade yourself
curUser:SendData(Bot, "You can't upgrade yourself")
end
if curUser.iProfile == 1 and tonumber(pNr) <= 1 then -- Block Ops from upgrade users to Op or higher
curUser:SendData(Bot, "You can't upgrade user to profiles higher then youself") return 1
end
if frmHub:isNickRegged(Nick) then -- If Nick is regged
if GetUserProfile(Nick) < curUser.iProfile then -- If Nick has higher profile then you
curUser:SendData(Bot, Nick.. " has a higher profile then you") return 1 -- Cant upgrade
end
AddRegUser(Nick, frmHub:GetUserPassword(Nick), pNr) -- Upgrade nick
SendToOps(Bot, curUser.sName.. " upgraded " ..Nick.. " to " ..GetProfileName(pNr)) return 1 --
end
curUser:SendData(Bot, "User ain't regged") return 1 -- User was not regged
end
curUser:SendData(Bot, "You are not allowed to use this command")
end,
}
if tCmds[cmd] then
return tCmds[cmd](curUser, data)
end
end
end
Title:
Post by: Psycho_Chihuahua on 26 May, 2005, 23:59:39
thnx m8 i'll give it a try  :D
Title:
Post by: jiten on 27 May, 2005, 12:29:33
Came too late :)
Anyway, here goes my attempt:
--/--------------------------------------------------------------------------------------------
-- Upgrade and Downgrade v1.0 by jiten
-- Small optimization in the error msgs
--/--------------------------------------------------------------------------------------------

sBot = frmHub:GetHubBotName()

-- Profiles allowed to use !upgrade command ([x] = 1 (allowed) or 0 (not))
AllowedProfiles = { [-1] = 0, [1] = 1, [2] = 0, [3] = 0, [4] = 1, [5] = 1, [0] = 1, }

-- Profile order (higher value means has more powerful)
Levels = { [-1] = 1, [3] = 2, [2] = 3, [1] = 4, [4] = 5, [0] = 6, [5] = 7, }

ChatArrival = function(user,data)
local data = string.sub(data, 1, -2)
local s,e,cmd = string.find(data,"%b<>%s+[%!%?%+%#](%S+)")
if cmd then
local tCmds = {
["upgrade"] = function(user,data)
s,e,nick,number = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(%d+)")
if nick == nil or number == nil then
user:SendData(sBot,"*** Syntax Error: Type !upgrade ")
elseif nick == user.sName then
user:SendData(sBot,"*** Error: You can't upgrade yourself.")
else
for i, profile in GetProfiles() do
if Levels[user.iProfile] >= Levels[GetItemByName(nick).iProfile] then cUp = 1
if string.lower(number) == string.lower(GetProfileIdx(profile)) then pExists = 1
if frmHub:isNickRegged(nick) then
AddRegUser(nick, frmHub:GetUserPassword(nick), number) isRegged = 1
user:SendData(sBot,nick.." was successfully upgraded by "..user.sName.." to "..GetProfileName(number).." status.")
SendPmToNick(nick,sBot,user.sName.." upgraded your status to "..GetProfileName(number).." profile!");
break
end
end
end
end
if cUp == nil then
user:SendData(sBot,"*** Error: You can't upgrade profiles higher than yours.")
elseif pExists == nil then
user:SendData(sBot,"*** Error: That profile doesn't exist.")
elseif isRegged == nil then
user:SendData(sBot,"*** Error: You can't upgrade unreg users.")
end
end
end,
}
if tCmds[cmd] and AllowedProfiles[user.iProfile] == 1 then
return tCmds[cmd](user,data), 1
else
return user:SendData(sBot,"*** Error: You are not allowed to use this command."), 1
end
end
end
-----------------------------------------------------------------------------------------------

Best regards,

jiten
Title:
Post by: Psycho_Chihuahua on 27 May, 2005, 12:40:43
QuoteOriginally posted by jiten
Came too late :)
Anyway, here goes my attempt:

 :D  thnx to you to Jiten, rather late then never *g well i'll give this one a try as well and then i shall see wich is better  ;)
Title:
Post by: jiten on 27 May, 2005, 17:39:24
Goody :]