Author Topic: Problem with gsub!  (Read 1189 times)

0 Members and 1 Guest are viewing this topic.

Offline Corayzon

  • Lord
  • ***
  • Posts: 464
  • Karma: +1/-0
Problem with gsub!
« on: 23 March, 2004, 04:55:16 »
im just having some probs with the gsub function...it works and then it dont...what is going on?

working example:-
function Main()
   local sString = "hello #u welcome to: #h!!! Have a nice stay"
   local sHubName = "Some Hub"
   local sUserName = "someone"
   sOut, x = gsub(sString, "#u", sUserName)
   sOut, x = gsub(sOut, "#h", sHubName)
   SendToAll("heelo", sOut.." - "..x)
end

return == " hello someone welcome to: Some Hub!!! Have a nice stay - 1"

and the one that sometimes works:-
function convertKickString(sIn, kicker, kicked, reason)
   sIn, x = gsub(sIn, "#u", kicked.sName)
   sIn, x = gsub(sIn, "#e", kicker.sName)
   if strfind(sIn, "#r") then sIn, x = gsub(sIn, "#r", reason) end
   return sIn
end


any ideas guys?

PtokaX forum

Problem with gsub!
« on: 23 March, 2004, 04:55:16 »

Offline Corayzon

  • Lord
  • ***
  • Posts: 464
  • Karma: +1/-0
(No subject)
« Reply #1 on: 23 March, 2004, 07:38:25 »
all good guys...got it all down ;)

Code: [Select]
-- #u - UserName
-- #h - HubName
-- #e - extra
-- #x - extra

sBot = "BotName"

function Main()
translateString("#u has been kicked by #e because: #x", "somedude", "Corayzon", "get lost man!")
end

function translateString(sString, sUserName, e, x)

-- System Strings
sString, _ = gsub(sString, "#h", frmHub:GetHubName())

-- Input Strings
sString, _ = gsub(sString, "#u", sUserName)
sString, _ = gsub(sString, "#e", e)
sString, _ = gsub(sString, "#x", x)
SendToAll(sBot, sString)

end

 8)

PtokaX forum

(No subject)
« Reply #1 on: 23 March, 2004, 07:38:25 »