PtokaX forum

Development Section => PtokaX Development Versions => Topic started by: PPK on 14 September, 2011, 00:19:33

Title: 0.4.2.0 build 258
Post by: PPK on 14 September, 2011, 00:19:33
Windows x86/x64 version with GUI: http://www.PtokaX.org/files/0.4.2.0b258.7z
Windows x86/x64 service: http://www.PtokaX.org/files/0.4.2.0b258-service.7z
Source is in SVN (http://forum.ptokax.org/index.php?topic=7821.0)

Quote from: Changes from build 241
Added: Core.SetUserInfo call to Lua api.
Added: IDs 28 - 42 for Core.GetUserValue Lua api call.

This version allow changes in MyINFO parts from Lua, for that MyINFO processing was little changed.
PtokaX now instead of full/original and stripped MyINFO have long (replacing full/original) and short (replacing stripped) MyINFO.
From Lua is possible to change in both MyINFOs: Description, Tag, Connection, Email and ShareSize.

New function was added for that:

Core.SetUserInfo(tUser, nValueId, nil/sValue/nValue, bPermanent)


tUser - Same table user as in many other api calls.
nValueId - Numeric indicator for MyINFO part to change.
nil/sValue/nValue - Use nil to remove change. Use string to change string value. Use number to change numeric value.
bPermanent - Boolean to make change permanent. When change is permanent then all next MyINFOs will contain that change.

IDs for nValueId:
Quote
0 - DescriptionShort
1 - DescriptionLong
2 - TagShort
3 - TagLong
4 - ConnectionShort
5 - ConnectionLong
6 - EmailShort
7 - EmailLong
8 - ShareSizeShort
9 - ShareSizeLong

New user data IDs for Core.GetUserValue:
Quote
28 - bDescriptionChanged
29 - bTagChanged
30 - bConnectionChanged
31 - bEmailChanged
32 - bShareChanged
33 - sScriptedDescriptionShort
34 - sScriptedDescriptionLong
35 - sScriptedTagShort
36 - sScriptedTagLong
37 - sScriptedConnectionShort
38 - sScriptedConnectionLong
39 - sScriptedEmailShort
40 - sScriptedEmailLong
41 - iScriptediShareSizeShort
42 - iScriptediShareSizeLong

IDs 28 - 32 can be used to check if MyINFO part was changed by user in last received MyINFO.
IDs 33 - 42 can be used by scripts to check if other script changed MyINFO part or to check own previous change.

And to show how it is working here is example script to add user country code to user description in short MyINFO:
Code (Lua) Select

function OnStartup()
   if Core.BuildNumber == nil or Core.BuildNumber < 258 then
      curScript = ScriptMan.GetScript()
      ScriptMan.StopScript(curScript.sName)
      error("This script require PtokaX 0.4.2.0 build 258 or higher!")
   end
end

function AddCountryCode(tUser)
   sCountryCode = IP2Country.GetCountryCode(tUser.sIP)
   if sCountryCode ~= nil and sCountryCode ~= "??" then
      if SetMan.GetBool(13) == true then -- 13 is Strip user description
         Core.SetUserInfo(tUser, 0, sCountryCode, true) -- 0 is sScriptedDescriptionShort
      else
         Core.SetUserInfo(tUser, 0, sCountryCode.." "..Core.GetUserValue(tUser, 2), true) -- 0 is sScriptedDescriptionShort, 2 is sDescription
      end
   end
end

function OpConnected(tUser)
   AddCountryCode(tUser)
end

function RegConnected(tUser)
   AddCountryCode(tUser)
end

function UserConnected(tUser)
   AddCountryCode(tUser)
end

function MyINFOArrival(tUser, sData)
   if Core.GetUserValue(tUser, 9) == false then -- 9 is bConnected
      return
   end

   if Core.GetUserValue(tUser, 28) == true then -- 28 is bDescriptionChanged
      AddCountryCode(tUser)
   end
end


Result as user see it in client http://www.PtokaX.org/files/images/CCinDescriptionByScript.png  8)

Have fun!  ;D
Title: Re: 0.4.2.0 build 258
Post by: Dessamator on 14 February, 2012, 09:43:30
Hi PPK, it seems from that description that it is possible to change everything except the user's name/nick. Is there any way to do so??
Title: Re: 0.4.2.0 build 258
Post by: PPK on 14 February, 2012, 10:47:15
Nick can't be changed, it will confuse client because he will not see yourself in userlist when you change nick... and will be not able to login correctly  ::)
Title: Re: 0.4.2.0 build 258
Post by: Dessamator on 14 February, 2012, 15:44:41
I was planning to convert to the latest PX the awayer script by herodes, it changes the nick to have a tag which shows if a user is away. Before he used a method where he would send "quit" to the original nick and show a nick with a tag.

I thought the new PX made it easier seems like it will still use the "messy" method.

Thanks anyway.

Title: Re: 0.4.2.0 build 258
Post by: PPK on 14 February, 2012, 16:09:41
Away is handled by protocol and working good, of course when client don't ignore that part of nmdc protocol (so it is not in dc++, but it is in most mods)  ::) So i'm actually don't see why script like that is needed...
Title: Re: 0.4.2.0 build 258
Post by: Hamachi on 16 February, 2012, 18:46:41
Hey i have try make a script to hide op share, but it down work!

Some there can help me ?

I use dev 316

OnError = send msg to all crew

QuoteOpConnected = function(tUser)
   if Core.SetUserInfo(tUser, 16, 0, true) then
   OnError(2)
   end
   
   if Core.BuildNumber == nil then
      OnError(Core.BuildNumber)
   end
end

MyINFOArrival = function(tUser, sData)
   if Core.GetUserValue(tUser, 9) == false then
      return
   end

   if Core.SetUserInfo(tUser, 16, 0, true) then
   OnError(1)
   end
end
Title: Re: 0.4.2.0 build 258
Post by: Psycho_Chihuahua on 16 February, 2012, 19:14:18
To hide share would be much easier by not sharing than using a script which would probably end up in higher bandwidth usage
Title: Re: 0.4.2.0 build 258
Post by: PPK on 16 February, 2012, 22:51:14
Quote from: Hamachi on 16 February, 2012, 18:46:41
Some there can help me ?
Core.SetUserInfo have max nValueId 9... and you are using 16 ::)
Title: Re: 0.4.2.0 build 258
Post by: Hamachi on 17 February, 2012, 00:09:27
Quote from: PPK on 16 February, 2012, 22:51:14
Core.SetUserInfo have max nValueId 9... and you are using 16 ::)

Ahh LOL

8 - ShareSizeShort
9 - ShareSizeLong

:)