Problem exploding a recieved umsg

I have a problem with this code:
[lua]function u_message_hook( um )
Msg( um:ReadString() … "
" )
local half = string.Explode("|", um:ReadString())
print(half[2]) – “thejjokerr/gamemode/cl_init.lua:52: attempt to concatenate field ‘?’ (a nil value)”
local title = string.Explode(";", half[1])[1]
local descript = string.Explode(";", half[1])[2]
local opts = string.Explode(";", half[2])
createmenu( title, descript, opts, um:ReadLong())
end
usermessage.Hook(“player_message”, u_message_hook)[/lua]

You can see where I get the error, the way I’m sending the umsg is like this:
[lua]function OnPlayerConsoleCommandVote( ply, command, args )
if( ply:IsAdmin() )then
print("S1: " … args[1], args[2], args[3], args[4])
SendVote(args[1], args[2], args[3], args[4])
end
end
concommand.Add( “tj_vote”, OnPlayerConsoleCommandVote )

function SendVote(title, description, options, time)
local rp = RecipientFilter() – Grab a CRecipientFilter object
rp:AddAllPlayers() – Send to all players!
print(“S2”)
umsg.Start(“player_message”, rp)
umsg.String( title … “;” … description … “|” … options)
umsg.Long( time )
umsg.End()
end[/lua]

The consolecommand I use is:


 tj_vote "Title" "HOLY SHIT IT's a Description!" "vote1;vote2;vote3" 10

But I dont think that’s the problem…

Thanks in advance

why not sending multiple umsg.String ?

Alright, the reason this happens is because as soon as you read the string once, it is deleted. That means, when you do that Msg() thing, it reads the string and after that deletes it. When you then try to retrieve the same string again, it is no longer present. All you have to do, is before you do anything to the string, just do: [lua]local string = um:ReadString();[/lua]

Only it’ll be [lua]local str = um:ReadString()[/lua] because he wants to use the string library in that function. :wink:

Awesome, thanks all!

Hehe, that’s true. :stuck_out_tongue: Just quickly typed that.