PtokaX forum

Archive => Archived 5.1 boards => HOW-TO's => Topic started by: DJ Bert on 29 March, 2006, 23:42:44

Title: How to change to 5.1
Post by: DJ Bert on 29 March, 2006, 23:42:44
What are all the things be changed for lua 5.1. Try to find some. I wil update Guardian to lua 5.1, but get some errors in section Tag in Description.
Title: Re: How to change to 5.1
Post by: bastya_elvtars on 30 March, 2006, 00:02:14
Well, you should post the chunk and the error here in order to get help IMHO.
Title: Re: How to change to 5.1
Post by: DJ Bert on 30 March, 2006, 00:46:38

--Description Tag by ??????Hawk?????? 27-02-2005 LUA 5

--===Sets the tag to be shown in reg's descriptions=================

regTagInDescription = "??????Reg??????" --\\ Tag

--==================================================================
--===Sets the tag to be shown in Vip's descriptions=================

VipTagInDescription = "??????Vip??????" --\\ Tag

--==================================================================
--===Sets the tag to be shown in op's descriptions==================

OpsTagInDescription = "??????Op??????" --\\ Tag

--==================================================================
--===Sets the tag to be shown in masters's descriptions=============

MastersTagInDescription = "??????Master??????" --\\ Tag

--==================================================================
--===Sets the time for the tags to be updated=======================

MastersTagInDescription = "??????Owner??????" --\\ Tag

--==================================================================

Mins = 1

--==================================================================



timer = 60000 * Mins
function Main()
SetTimer(timer)
StartTimer()
end

function OnTimer()
TagInDescription()
end

function TagInDescription()
local aux,usr
for aux, usr in GetUsersByProfile("vip") do
if (GetItemByName(usr) ~= nil) then
local userToShow = GetItemByName(usr)
if (userToShow.sMyInfoString ~= nil) then
local s,e,name,desc,speed,email,share = string.find(userToShow.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)$ $([^$]*)$([^$]*)$([^$]+)")
SendToAll( "$MyINFO $ALL "..name.." "..VipTagInDescription.." "..desc.."$ $"..speed.."$"..email.."$"..share.."$")
end
end
end
for aux, usr in GetUsersByProfile("operator") do
if (GetItemByName(usr) ~= nil) then
local userToShow = GetItemByName(usr)
if (userToShow.sMyInfoString ~= nil) then
local s,e,name,desc,speed,email,share = string.find(userToShow.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)$ $([^$]*)$([^$]*)$([^$]+)")
SendToAll( "$MyINFO $ALL "..name.." "..OpsTagInDescription.." "..desc.."$ $"..speed.."$"..email.."$"..share.."$")
end
end
end
for aux, usr in GetUsersByProfile("master") do
if (GetItemByName(usr) ~= nil) then
local userToShow = GetItemByName(usr)
if (userToShow.sMyInfoString ~= nil) then
local s,e,name,desc,speed,email,share = string.find(userToShow.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)$ $([^$]*)$([^$]*)$([^$]+)")
SendToAll( "$MyINFO $ALL "..name.." "..MastersTagInDescription.." "..desc.."$ $"..speed.."$"..email.."$"..share.."$")
end
end
end
for aux, usr in GetUsersByProfile("reg") do
if (GetItemByName(usr) ~= nil) then
local userToShow = GetItemByName(usr)
if (userToShow.sMyInfoString ~= nil) then
local s,e,name,desc,speed,email,share = string.find(userToShow.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)$ $([^$]*)$([^$]*)$([^$]+)")
SendToAll( "$MyINFO $ALL "..name.." "..regTagInDescription.." "..desc.."$ $"..speed.."$"..email.."$"..share.."$")
end
end
end
end



The error i get is in next line

for aux, usr in GetUsersByProfile("vip") do


attempt to call a table value

That is the same code what's is used in Guardian.
Title: Re: How to change to 5.1
Post by: bastya_elvtars on 30 March, 2006, 00:52:37
for aux, usr in ipairs(GetUsersByProfile("vip")) do

Use ipairs for arrays, pairs for tables.
Title: Re: How to change to 5.1
Post by: DJ Bert on 30 March, 2006, 00:57:51
Quote from: bastya_elvtars on 30 March, 2006, 00:52:37
for aux, usr in ipairs(GetUsersByProfile("vip")) do

Use ipairs for arrays, pairs for tables.

Oke, gonna try this,

Thnx bastya