Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×

Player id in sendChat not considered

1560180411

Edited 1560180497
Hello there, I'm working on some custom sheet based on d6 and took default d6 script proposed by Aaron. I'm working on displaying the dice rolled but I'm facing a little issue where the dice are not taking the color of whomever is rolling. I guess my problem is formating the "speakingas" argument of sendChat which is described here :&nbsp; <a href="https://wiki.roll20.net/API:Chat" rel="nofollow">https://wiki.roll20.net/API:Chat</a> &nbsp; So to post here, I just changed a bit the example given in that article to display 3d dice and here is what I get : <a href="https://puu.sh/DE8MI/7718a75039.png" rel="nofollow">https://puu.sh/DE8MI/7718a75039.png</a> Here is the script I used : &nbsp; &nbsp; &nbsp; &nbsp; on("chat:message", function(msg) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //This allows players to enter !sr &lt;number&gt; to roll a number of d6 dice with a target of 4. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(msg.type == "api" &amp;&amp; msg.content.indexOf("!sr ") !== -1) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var numdice = msg.content.replace("!sr ", ""); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat(msg.who, "/roll " + numdice + "d6&gt;4", null, {use3d:true}); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; log(msg.who); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; }); I tried getting the actual display name + adding the ID (msg.playerid) as the article is suggesting but none of my tests worked so far. I am probably looking into something that is not possible and maybe I'm losing my time investigating how to make it work so here I am... :) Best regards, Mesti
1560182756

Edited 1560182767
GiGs
Pro
Sheet Author
API Scripter
I havent used 3d dice, so dont know if this will work, but if you are trying to show the player's avatar, you need to to use msg.playerid not msg.who, like this sendChat("player|" + msg.playerid, "/roll " + numdice + "d6&gt;4", null, {use3d:true});
1560184720

Edited 1560184776
LOL, I figured out I misinterpreted the "player" part and I was mistakenly replacing it by the name of the player... So I was basically trying to do something like : msg.who + "|" + msg.playerid instead of "player|" + msg.playerid Works like a charm with "player|" + msg.playerid.&nbsp; Thank's GiGs, this is resolved (but can't edit the title, sorry, it's kind of the first time I'm posting here :) )
1560185730
GiGs
Pro
Sheet Author
API Scripter
You're welcome - it's an easy mistake to make :)