Weird issue where the plugin changes get undone

Posted by Glorimus on Thu 13 Oct 2016 07:45 PM — 2 posts, 11,652 views.

#0
I wrote a simple plugin to change characters. It looks like for brief moment, my settings take, but as soon as I connect all the changes are undone.


for example im setting the chat title,and the username,password. none of these are being used


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
    <plugin
    name="changechar"
    author="glorimus"
    id="726f33a0121c752b023e4371"
    language="Lua"
    purpose="changechar"
    requires="4.52"
    version="2.4"
    save_state="y"
    >
<description trim="y">
USAGE:
    Test
      
</description>
  
</plugin>
<aliases>
 <alias
   match="^(goappa)(\s.+)?$"
   enabled="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
Execute("zzap")
local charname = "my_new_char"
SetTitle(charname)
SetAlphaOption("name",charname)
SetAlphaOption("player",charname)
SetAlphaOption("password","xxx")
Connect()</send>
</alias>
</aliases>
<script>
<![CDATA[
]]>
</script>
</muclient>
Australia Forum Administrator #1
Your alias has a capture (wildcard) which you don't seem to be using.

The chat name is option "chat_name" which you are not using.




The alpha options name, player and password are not allowed to be changed by plugins as a security measure (for example, brute-force attempting to connect as different characters).

If you check the return code from those calls you would have seen an error message, eg.



check(SetAlphaOption("name",charname))
check(SetAlphaOption("player",charname))
check(SetAlphaOption("password","xxx"))



Now, testing the plugin gives:


Run-time error
Plugin: changechar (called from world: smaug)
Immediate execution
[string "Alias: "]:5: Plugin is not allowed to set this option





As a work-around you could call "Connect()" and then in the plugin callback "OnPluginConnect" send the character name, followed by the password.