Iris2.de http://iris2.de/forum/ |
|
few lines of code about party system : messagetoall http://iris2.de/forum/viewtopic.php?f=16&t=1233 |
Page 1 of 1 |
Author: | surcouf [ Tue Aug 26, 2008 10:36 pm ] |
Post subject: | few lines of code about party system : messagetoall |
this is my first lua piece of script so I hope there is no stupid thing in it and it may be usefull for you : Code: function gPartySystemHandler.kPartySubCmd_MessageToAll (input,size)
local speakerID = input:PopNetUint32() --TODO need to convert ID in name print("partysystem:test message",speakerID, input, size) local text = "" while true do local digit = input:PopNetUint16() if (digit == hex2num("0x0000")) then break end text = text..string.char(digit) end GuiAddChatLine (speakerID.. " tells you : "..text) end I didn't find a way to change the SpeakerId by it's name. Could you help me ? |
Author: | ghoulsblade [ Tue Aug 26, 2008 11:34 pm ] |
Post subject: | |
hi =) you can get the name like this : Code: local mobile = GetMobile(serial) local name = mobile and mobile.name or ("unknown"..serial) i added a bit of size checking and added it to the svn, thanks ! Code: function gPartySystemHandler.kPartySubCmd_MessageToAll (input,size)
local speakerID = input:PopNetUint32() size = size - 4 local mobile = GetMobile(speakerID) local name = mobile and mobile.name or ("unknown"..speakerID) print("partysystem:test message",speakerID,name, input, size) local text = "" while size >= 2 do local digit = input:PopNetUint16() if (digit == hex2num("0x0000")) then break end text = text..string.char(digit) end GuiAddChatLine ("["..name.."]: "..text) end |
Author: | ghoulsblade [ Tue Aug 26, 2008 11:39 pm ] |
Post subject: | |
the function was only for receiving, but i just added a stub for sending, if you want to try to fill in the code =) Code: function Send_PartyChat (chatmessage)
print("TODO : send party chat:",chatmessage) end EDIT : you can get the charcode at of a letter by string.byte(chatmessage,iLetterPosition) with iLetterPosition starting at 1 for the first letter. you can get the string length by local len = string.len(chatmessage) |
Author: | surcouf [ Wed Aug 27, 2008 10:10 pm ] |
Post subject: | |
something wrong with Send_PartyChat but I do not find what. no error on the runuo2.0RC2 server console but no party message on an other uo client. Code: function Send_PartyChat (chatmessage)
print("TODO : send party chat:",chatmessage) local out = GetSendFIFO() out:PushNetUint8(kPacket_Generic_Command)--id out:PushNetUint16(12 +string.len(chatmessage)*2) -- packet size out:PushNetUint16(kPacket_Generic_SubCommand_PartySystem) out:PushNetUint8(kPartySubCmd_MessageToAll)--4 local mobile = GetPlayerMobile() print("TODO : send party chat:",mobile.name,mobile.serial) out:PushNetUint32(mobile.serial) for i=1, string.len(chatmessage) do print("TODO : send party chat:",i,string.byte(chatmessage,i)) out:PushNetUint16(string.byte(chatmessage,i)) end out:PushNetUint16(hex2num("0x0000")) out:SendPacket() end |
Author: | ghoulsblade [ Thu Aug 28, 2008 9:07 am ] |
Post subject: | |
i think the size is wrong, 8 16 16 8 = 4 bytes 32 = 4 bytes stringlen * 2 16 zero terminator = 2 bytes, so 4 + 4 + 2 = 10 rather than 12 also i think you should also not send the playerid : Code: Subsubcommand 4: Tell full party a message (Variable # of bytes)
� BYTE[n][2] Null terminated Unicode message. Client Message. |
Author: | surcouf [ Thu Aug 28, 2008 5:48 pm ] |
Post subject: | |
It works ! I do not need to send the playerid as you said where do you find the protocol extract ? Do you have a good howto or an other example in order to create a small dialog interface to do "send to one a message, send invite, manage the team" ? Code: function Send_PartyChat (chatmessage)
print("partysystem : send party chat to all:",chatmessage) local out = GetSendFIFO() local len = string.len(chatmessage) out:PushNetUint8(kPacket_Generic_Command)--id out:PushNetUint16(8 +len*2) -- packet size out:PushNetUint16(kPacket_Generic_SubCommand_PartySystem) out:PushNetUint8(kPartySubCmd_MessageToAll) for i=1, len do --~ print("TODO : send party chat:",i,string.byte(chatmessage,i)) out:PushNetUint16(string.byte(chatmessage,i)) end out:PushNetUint16(hex2num("0x0000")) out:SendPacket() end |
Author: | ghoulsblade [ Thu Aug 28, 2008 6:35 pm ] |
Post subject: | |
cool thanks, adding it to svn =) i used the pol server protocol docs : http://docs.polserver.com/packets/ dialog : it's a bit hard right now because we're in the process of converting code from the old gui system (guimaker.*, don't use this) to our new gui system. The new system isn't fully finished yet, and we plan to create a html/xml like definition language for it. Not sure how long it'll take, but i think it's better to wait for that to be finished before you start coding with the currently rather lowlevel interface. i think the "invite" is most important, could you implement that please ? i'll try to add a hotkey for it that starts a targetting mode and then calls a function like Send_PartyInvitation(playerserial) |
Author: | surcouf [ Thu Aug 28, 2008 7:11 pm ] |
Post subject: | |
the problem is if you create "invite" you are the team leader, so you need to be able to kick someone or disband party. moreover, I think that the check "party can loot me" and "leave the party" are more important. If you can just create a small list with : invite, disband party, party can loot me, leave the party. I think that could be great |
Author: | ghoulsblade [ Thu Aug 28, 2008 10:40 pm ] |
Post subject: | |
ok, i added stubs for all commands, and a hotkey "alt+l" that opens a simple dialog, even the target-mode on invite should work. i'm not quite sure how the client knows the current status of "can loot me" before the user pressed a button (how does joining/leaving party affect it ? we have to be careful making assumptions here, displaying this wrong might cause some trouble) , so i simply added buttons for both on and off and no display of the current state =) |
Author: | surcouf [ Fri Aug 29, 2008 11:18 pm ] |
Post subject: | |
This post to do a point : invite works (I modify the dialog to keep the button after the first member of your team) kick works "can loot me" works but I notice that on a uo client, just after accept a party or just after the first guy accept your invitation, the client notify you that you accept loot. So we need to call the function: Easy when someone invite your char but still to do in the case you are the leader. (don't know how to do that except with a global flag). Leave and disband don't work cause I can't find the key to send to the server. here is a diff file. If you prefer I can add the whole script. Code: Index: ../lua/net/net.partysystem.lua
=================================================================== --- ../lua/net/net.partysystem.lua (revision 2422) +++ ../lua/net/net.partysystem.lua (working copy) @@ -22,7 +22,8 @@ out:PushNetUint16(6) -- packet size out:PushNetUint16(kPacket_Generic_SubCommand_PartySystem) out:PushNetUint8(kPartySubCmd_AcceptInvite) - out:SendPacket() + out:SendPacket() + PartySendCanLootMe(true) end function PartySendDecline () @@ -35,16 +36,41 @@ end function PartySendInvite(serial) - print("TODO : PartySendInvite",serial) + print("partysystem:PartySendInvite",serial) + local out = GetSendFIFO() + out:PushNetUint8(kPacket_Generic_Command)--id + out:PushNetUint16(10) -- packet size + out:PushNetUint16(kPacket_Generic_SubCommand_PartySystem) + out:PushNetUint8(kPartySubCmd_AddMembers) + out:PushNetUint32(serial) + out:SendPacket() end function PartySendKick(serial) - print("TODO : PartySendKick",serial) + print("partysystem:PartySendKick",serial) + local out = GetSendFIFO() + out:PushNetUint8(kPacket_Generic_Command)--id + out:PushNetUint16(10) -- packet size + out:PushNetUint16(kPacket_Generic_SubCommand_PartySystem) + out:PushNetUint8(kPartySubCmd_RemoveMembers) + out:PushNetUint32(serial) + out:SendPacket() end function PartySendDisband() print("TODO : PartySendDisband") end function PartySendCanLootMe (bState) - print("TODO : PartySendCanLootMe",bState) + print("partysystem:PartySendCanLootMe",bState) + local out = GetSendFIFO() + out:PushNetUint8(kPacket_Generic_Command)--id + out:PushNetUint16(7) -- packet size + out:PushNetUint16(kPacket_Generic_SubCommand_PartySystem) + out:PushNetUint8(kPartySubCmd_CanLoot) + if bState == true then + out:PushNetUint8(1) + else + out:PushNetUint8(0) + end + out:SendPacket() end function PartySendLeave () print("TODO : PartySendLeave") @@ -192,10 +218,16 @@ -- leave/disband if (bIAmLeader) then - table.insert(rows,{{"Disband",function () PartySendDisband() end}}) + table.insert(rows,{ + {"Disband",function () PartySendDisband() end}, + -- need to be able to invite new member + {"Invite",function () PartyListDialog_StartInviteMode() end}, + }) + else table.insert(rows,{{"Leave",function () PartySendLeave() end}}) - end + end + end gPartyListDialog = guimaker.MakeTableDlg(rows,100,100,false,true,gGuiDefaultStyleSet,"window") |
Author: | ghoulsblade [ Sat Aug 30, 2008 1:35 am ] |
Post subject: | |
excellent, thank you very much =) added the code to svn Leave and disband : i tried sending a kick/remove request on the players own id and it seems to work =) |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |