Author Topic: Getting the BL_ID from someone in a server (with client)  (Read 2439 times)

Hi. I'm trying to get the BL_ID of someone in a server, but I want to do this by a clientside script. How would I do that?

I think this was sort of already made. (F2)
So then it should be possible, but I'm not so
sure how to do it.
« Last Edit: July 07, 2013, 11:30:05 PM by Radíowave »

This is from a small client side script I made a while back that fetches everyone in the server to your location

Code: [Select]
function fetchall(%x)
{
if(!%x)
return;

for(%a=0; %a<npl_list.rowcount(); %a++)
commandtoserver('fetch', getfield(npl_list.getrowtext(%a), 1));
}
$remapdivision[$remapcount] = "Random Stuff";
$remapname[$remapcount] = "Fetch All Players";
$remapcmd[$remapcount] = "fetchall";
$remapcount++;

Basically what you want to do is look at the gui object called npl_list and search through its fields
For example, doing npl_list.getrowtext(%a) will return all the text on the line %a of that gui, with each element divided by tabs.

You can then use getfield(%text, %index) to divide that line into the tabbed elements.

I believe index 0 is admin state, 1 is name, 2 is score, 3 is the BL_ID (if enabled), and 4 is the trust level.
To match a name with a BL_ID, you will need to loop through this GUI

Compensating for whether or not showing BL_IDs in the player list is enabled is something you will need to work out yourself.

Using Nexus' information, I made a function that works properly.
Code: [Select]
function getblid(%person) //type in your client console this: getblid("aPlayer'sNameHere");
{
for(%a=0; %a<npl_list.rowcount(); %a++)
{
if(getfield(npl_list.getrowtext(%a), 1) $= %person) //Basically saying "If you type this in, then I will do what the below says"
{
newchatso.addline(getfield(npl_list.getrowtext(%a), 3)); //Sends you the player's BL_ID
}
}
}
To be honest, I never really knew exactly what "for" ment in TorqueScript. Can someone explain?
Note: newchatso.addline is just a way to message yourself without anyone else seeing.
« Last Edit: July 08, 2013, 12:57:23 AM by Radíowave »

Using Nexus' information, I made a function that works properly.
Code: [Select]
function getblid(%person) //type in your client console this: getblid("aPlayer'sNameHere");
{
for(%a=0; %a<npl_list.rowcount(); %a++)
{
if(getfield(npl_list.getrowtext(%a), 1) $= %person) //Basically saying "If you type this in, then I will do what the below says"
{
newchatso.addline(getfield(npl_list.getrowtext(%a), 3)); //Sends you the player's BL_ID
}
}
}
To be honest, I never really knew exactly what "for" ment in TorqueScript. Can someone explain?
Note: newchatso.addline is just a way to message yourself without anyone else seeing.

for is the same for every other coding language
it loops until the conditions are no longer met

Code: [Select]
for(%i=0;%i<10;%i++)
{
    Echo(%i);
}
this will echo 0-10

the first part is what the variable starts at, the second part is the conditions it must satisfy and the last part is what it changes with every loop

this will echo 0-10
At the 10th iterator, %i will not be less than 10, therefore it will echo 0-9, unless the condition is
Code: [Select]
%i<=10;

At the 10th iterator, %i will not be less than 10, therefore it will echo 0-9, unless the condition is
Code: [Select]
%i<=10;
o ya ik that lol :p

for is the same for every other coding language
that is not remotely true.
read here

that is not remotely true.
read here
He didn't say it was formatted the same as all other languages, he said it performs the same function as the others. Whether you're using lua, Python, TorqueScript, C, Ruby, Perl, Java, or whatever other language makes you happy, the for loop exists to iterate through a list.

Oh, and make sure you add this :


Add this at the very beginning of the function you are using to get someone's BL_ID
Code: [Select]
%takeAway = false;
if(!$Pref::Gui::ShowPlayerListBLIDs)
{
   %takeAway = true;
}

$Pref::Gui::ShowPlayerListBLIDs = true;


Then add this code at the very end of the function :

Code: [Select]
if(%takeAway)
{
   $Pref::Gui::ShowPlayerListBLIDs = false;
}

Since you need to show player's BL_IDs in the GUI (by default i think it is disabled) you need to add this so that :

-If they already enabled showing BLIDs in the list, nothing extra happens.
-If they have not enabled it, this will enable it, find the bl_id, then disable it back to it's original value.

%client.bl_id
???
I don't really get what you mean.

Code: [Select]
for(%i=0;%i<10;%i++)
{
    Echo(%i);
}
this will echo 0-10
Actually it only echos 0-9

Code: [Select]
for(%i=0;%i<=10;%i++)
{
    Echo(%i);
}
That would echo 0-10

%client.bl_id
???
I don't really get what you mean.

That's for the server-side, this is for when a client in a server tries to get other player's bl_ids.

That's for the server-side, this is for when a client in a server tries to get other player's bl_ids.
Ah, I see. Fetch it from the NPL?

Well the addon I'm making is for personal use, so I'm not releasing it to the public. I always have show BL_IDs enabled.