Author Topic: 0.4.2.0 build 258  (Read 3939 times)

0 Members and 1 Guest are viewing this topic.

Offline PPK

  • Administrator
  • Emperor
  • *****
  • Posts: 1 475
  • Karma: +209/-22
  • PtokaX developer
0.4.2.0 build 258
« 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

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:
Code: [Select]
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
  1. function OnStartup()
  2.    if Core.BuildNumber == nil or Core.BuildNumber < 258 then
  3.       curScript = ScriptMan.GetScript()
  4.       ScriptMan.StopScript(curScript.sName)
  5.       error("This script require PtokaX 0.4.2.0 build 258 or higher!")
  6.    end
  7. end
  8.  
  9. function AddCountryCode(tUser)
  10.    sCountryCode = IP2Country.GetCountryCode(tUser.sIP)
  11.    if sCountryCode ~= nil and sCountryCode ~= "??" then
  12.       if SetMan.GetBool(13) == true then -- 13 is Strip user description
  13.          Core.SetUserInfo(tUser, 0, sCountryCode, true) -- 0 is sScriptedDescriptionShort
  14.       else
  15.          Core.SetUserInfo(tUser, 0, sCountryCode.." "..Core.GetUserValue(tUser, 2), true) -- 0 is sScriptedDescriptionShort, 2 is sDescription
  16.       end
  17.    end
  18. end
  19.  
  20. function OpConnected(tUser)
  21.    AddCountryCode(tUser)
  22. end
  23.  
  24. function RegConnected(tUser)
  25.    AddCountryCode(tUser)
  26. end
  27.  
  28. function UserConnected(tUser)
  29.    AddCountryCode(tUser)
  30. end
  31.  
  32. function MyINFOArrival(tUser, sData)
  33.    if Core.GetUserValue(tUser, 9) == false then -- 9 is bConnected
  34.       return
  35.    end
  36.  
  37.    if Core.GetUserValue(tUser, 28) == true then -- 28 is bDescriptionChanged
  38.       AddCountryCode(tUser)
  39.    end
  40. end
  41.  

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

Have fun!  ;D
« Last Edit: 13 September, 2013, 02:31:13 by PPK »
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

PtokaX forum

0.4.2.0 build 258
« on: 14 September, 2011, 00:19:33 »

Offline Dessamator

  • Scripter
  • Emperor
  • ******
  • Posts: 1 262
  • Karma: +13/-9
Re: 0.4.2.0 build 258
« Reply #1 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??
Ignorance is Bliss.

Offline PPK

  • Administrator
  • Emperor
  • *****
  • Posts: 1 475
  • Karma: +209/-22
  • PtokaX developer
Re: 0.4.2.0 build 258
« Reply #2 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  ::)
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

Offline Dessamator

  • Scripter
  • Emperor
  • ******
  • Posts: 1 262
  • Karma: +13/-9
Re: 0.4.2.0 build 258
« Reply #3 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.

Ignorance is Bliss.

Offline PPK

  • Administrator
  • Emperor
  • *****
  • Posts: 1 475
  • Karma: +209/-22
  • PtokaX developer
Re: 0.4.2.0 build 258
« Reply #4 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...
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

Offline Hamachi

  • Forum Ace
  • *****
  • Posts: 88
  • Karma: +0/-7
Re: 0.4.2.0 build 258
« Reply #5 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

Quote
OpConnected = 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

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
Re: 0.4.2.0 build 258
« Reply #6 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
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Offline PPK

  • Administrator
  • Emperor
  • *****
  • Posts: 1 475
  • Karma: +209/-22
  • PtokaX developer
Re: 0.4.2.0 build 258
« Reply #7 on: 16 February, 2012, 22:51:14 »
Some there can help me ?
Core.SetUserInfo have max nValueId 9... and you are using 16 ::)
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

Offline Hamachi

  • Forum Ace
  • *****
  • Posts: 88
  • Karma: +0/-7
Re: 0.4.2.0 build 258
« Reply #8 on: 17 February, 2012, 00:09:27 »
Core.SetUserInfo have max nValueId 9... and you are using 16 ::)

Ahh LOL

8 - ShareSizeShort
9 - ShareSizeLong

:)

PtokaX forum

Re: 0.4.2.0 build 258
« Reply #8 on: 17 February, 2012, 00:09:27 »