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 .
×
Create a free account

playerid - unique or not and how to find

1421061872
Ziechael
Forum Champion
Sheet Author
API Scripter
Hi, i've searched the forums and can't find my answer so looking for a quick fix here. I need to find playerid's for the inventory script by John C but since i'm creating it in a new campaign as recommended will i need my players to join first to get their id's or are playerid's unique and the ones i can get from my existing campaign will be the same as when the join the 'inventory campaign'? Also, how can i get the id's, i've tried !playerid as suggested in another thread but don't get anything back from it? Thanks for any help!!
1421062171
Ziechael
Forum Champion
Sheet Author
API Scripter
that being said, i think i misread. I don't think i need the playerid for the inventory script but my questions still stand, are they unique across campaigns and how do i get them?
1421073801
Pat S.
Forum Champion
Sheet Author
This is an API question so I'm moving it to the appropiate forum.
1421074414
Ziechael
Forum Champion
Sheet Author
API Scripter
Pat S. said: This is an API question so I'm moving it to the appropiate forum. Thanks Pat, wasn't entirely sure where to put it.
1421074737
The Aaron
Roll20 Production Team
API Scripter
playerid is unique to the campaign, the same player will have a different id on each campaign they are a part of. You can access the playerid from the player object. This code will print the names and ids of all the players in a campaign on startup: on('ready',function(){ 'use strict'; var players=findObjs({_type:'player'}); _.each(players,function (obj){ log('Player '+obj.get('displayname')+' has id: '+obj.get('id')); }); });
1421075121
Ziechael
Forum Champion
Sheet Author
API Scripter
If a player changes their display name after the id is generated it won't change the id i'm assuming...? Ps. Aaron, I love you. Now to get rid of the unexpected identifier i keep getting in the inventory script :D
PS I love you too Aaron
1421077048
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Ziechael said: If a player changes their display name after the id is generated it won't change the id i'm assuming...? The ID will not change.... Only changes if you kick them or they leave and then they rejoin.
1421077608
Ziechael
Forum Champion
Sheet Author
API Scripter
perfect, i thought as much but just wanted to confirm before i go getting excited :) Thanks all!
1421081832
The Aaron
Roll20 Production Team
API Scripter
I feel the love. =D