Author Topic: ULib usermessage bug ?  (Read 3344 times)

0 Members and 1 Guest are viewing this topic.

Offline Chironex

  • Full Member
  • ***
  • Posts: 197
  • Karma: 11
  • Formerly known as Kyzer
ULib usermessage bug ?
« on: February 29, 2008, 10:13:20 AM »
Hello all, I'm using a usermessage, this is the part on the client:
Code: [Select]
local wtsa_keywords_string_cl = ""
local function WTSA_Save_Keywords_CL( wtsa_usermessage )

    local wtsa_usermessage_string = wtsa_usermessage:ReadString()

    if wtsa_usermessage_string != "ULib_autocomplete" then

        if wtsa_usermessage_string != "WTSA_UMSG_END" then
            wtsa_keywords_string_cl = wtsa_keywords_string_cl .. wtsa_usermessage_string
            WTSA_Debug("wtsa_keywords_string_cl = \n" .. wtsa_keywords_string_cl )
        else
            WTSA_Debug("writing\n" .. wtsa_keywords_string_cl .."in file..")
            file.Write("wtsa_keywords.txt", wtsa_keywords_string_cl)
            wtsa_keywords_string_cl = ""
        end

    end

end
usermessage.Hook( "wtsa_save_keywords_um", WTSA_Save_Keywords_CL )

Notice the line: if wtsa_usermessage_string != "ULib_autocomplete" then

I needed to do that because for an unknow reason, i retrieve this string each time i use my usermessage :/
By that i mean that: WTSA_Debug("wtsa_keywords_string_cl = \n" .. wtsa_keywords_string_cl )
will print:
Code: [Select]
wtsa_keywords_string_cl = ULib_autocompleteif i don't put that IF statement.

Any idea why?

Here is the server part as well, if needed:
Code: [Select]
function WTSA_Save_Keywords_SV(ply)

    local plyid = ply:UniqueID() -- foutre ca apres if()

    if ply and ply:IsPlayer() and PlayerCustomsKeywords[plyid] != nil then

        local wtsa_keywords_string_sv = ""
        local RF = RecipientFilter()
        RF:AddPlayer( ply )

        for k, v in pairs(PlayerCustomsKeywords[plyid]) do
            wtsa_keywords_string_sv = k .. "=" .. v .. "\n"
            umsg.Start( "wtsa_save_keywords_um", RF)
                umsg.String(wtsa_keywords_string_sv)
            umsg.End()
        end

        umsg.Start( "wtsa_save_keywords_um", RF)
            umsg.String("WTSA_UMSG_END")
        umsg.End()

        WTSA_Debug(ply:Nick() .. "'s keywords are saved.")

    end

end
concommand.Add("wtsa_savekeywords", WTSA_Save_Keywords_SV)

I don't think i do something wrong, i believe this is because i use it in a concommand..?

Also, while i posted this code..any idea how to make it more efficient ? I'm not satisfied, all that to save a table from server to a client file, 1 line = 1 usermessage..what is umsg.PoolString, should i use that?

Thanks for helping me :D
« Last Edit: February 29, 2008, 10:40:11 AM by Kyzer »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: ULib usermessage bug ?
« Reply #1 on: March 04, 2008, 04:13:16 PM »
Kyzer, did you ever resolve this issue?
Experiencing God's grace one day at a time.

Offline Chironex

  • Full Member
  • ***
  • Posts: 197
  • Karma: 11
  • Formerly known as Kyzer
Re: ULib usermessage bug ?
« Reply #2 on: March 04, 2008, 10:14:27 PM »
Nope, as i said i used this workaoround:

if wtsa_usermessage_string != "ULib_autocomplete" then

There is nothing else i can do from my script :s

Offline spbogie

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 456
  • Karma: 41
Re: ULib usermessage bug ?
« Reply #3 on: March 04, 2008, 11:12:14 PM »
Hmmm, first thought is that somewhere umsg.End() isn't being called. I've double checked, and all usermessages in both ULib and ULX are properly ended.
I have not failed. I've just found 10,000 ways that won't work. - Thomas A. Edison
I reject your reality and substitute my own. - Adam Savage