Author Topic: Getting a player's clan tags  (Read 3351 times)

Is there a way to get a player's original tags? Like echoing it through the console or something?

UPDATE

Wow, I'm so dumb. Here's how to do it:
Code: [Select]
echo(findClientByName("Client").clanSuffix);

For some reason I thought there might be some complications to that but I guess not.
« Last Edit: September 25, 2014, 08:22:25 AM by Radíowave »


You probably don't need this, but just because, i'll make a servercmd to check for a player's clan tags.
Code: [Select]
function serverCmdGetTags(%client,%targetname)
{
 %target=findclientbyname(%targetname);
 messageclient(%client,'',"\c6The clan tags for" SPC %player.name SPC "are \c3" @ %target.clanprefix SPC "\c6and \c3" @%target.clansuffix"\c6."); //I can use %target.clanprefix/suffix, right?
}
It's not tested and i mainly made this, because i have been a bit code-deprived lately because of school. I do have a few questions though. How again should i use isObject to check if player exists.
« Last Edit: September 25, 2014, 11:33:49 AM by Dannu »

You probably don't need this, but just because, i'll make a servercmd to check for a player's clan tags.
Code: [Select]
function serverCmdGetTags(%client,%targetname)
{
 %target=findclientbyname(%targetname);
 messageclient(%client,'',"\c6The clan tags for" SPC %player.name SPC "are \c3" @ %player.clanprefix SPC "\c6and \c3" @%player.clansuffix"\c6."); //I can use %player.clanprefix/suffix, right?
}
It's not tested and i mainly made this, because i have been a bit code-deprived lately because of school. I do have a few questions though. How again should i use isObject to check if player exists.
This won't work because %player is never defined. I also wouldn't use %player because that's usually used to refer to the person's player object, not their client.

if(isObject(%target))
To check if their client exists.

I was changing around the variable names and forgot to change %player to %target in the messageclient. Also
if(isObject(%target))
To check if their client exists.
Thanks

Is there a way to get a player's original tags? Like echoing it through the console or something?

Code: [Select]
function serverCmdFindTags(%client, %player)
{
  if(!%client.isAdmin)
     return;
   %player=findclientbyname(%player);
   %player.clanprefix = %Tag1;
   %player.clansuffix = %Tag2;
   messageclient(%client,'',"\c7" @ %Tag1 SPC "\c6" @ %player.name SPC "\c7" @ %Tag2);
}



You probably don't need this, but just because, i'll make a servercmd to check for a player's clan tags.
Code: [Select]
function serverCmdGetTags(%client,%targetname)
{
 %target=findclientbyname(%targetname);
 messageclient(%client,'',"\c6The clan tags for" SPC %player.name SPC "are \c3" @ %target.clanprefix SPC "\c6and \c3" @%target.clansuffix"\c6."); //I can use %target.clanprefix/suffix, right?
}
It's not tested and i mainly made this, because i have been a bit code-deprived lately because of school. I do have a few questions though. How again should i use isObject to check if player exists.

That won't work because the last variable isn't separated from the last string, as well as a few other things.

Code: [Select]
function serverCmdFindTags(%client, %player)
{
  if(!%client.isAdmin)
     return;
   %player=findclientbyname(%player);
   %player.clanprefix = %Tag1;
   %player.clansuffix = %Tag2;
   messageclient(%client,'',"\c7" @ %Tag1 SPC "\c6" @ %player.name SPC "\c7" @ %Tag2);
}



That won't work because the last variable isn't separated from the last string, as well as a few other things.
That won't work because you're just setting their clan tags to blank variables.

Code: [Select]
function serverCmdFindTags(%client, %player)
{
   // if(!%client.isAdmin)
   %player=findclientbyname(%player);
   if(!isObject(%player))
   {
      messageClient(%client,'',"\c6Client not found");
      return;
   }
   %prefix = %player.clanprefix;
   %suffix = %player.clansuffix;
   messageclient(%client,'',"\c7" @ %prefix SPC "\c6" @ %player.name SPC "\c7" @ %suffix);
}
ftfy. If i missed something, let me know
« Last Edit: September 27, 2014, 08:08:25 PM by Dannu »

ftfy. If i missed something, let me know
That still seems so wrong to me. Using %player for a client object is just ew.

ftfy. If i missed something, let me know
Line 6 - it's \c6, not /c6 for the white color code.
You could also define %player in the if statement (it's not necessary, but that's how I do it)


That still seems so wrong to me. Using %player for a client object is just ew.
That's what Tezuni used and i didn't go about changing everything. Also
Line 6 - it's \c6, not /c6 for the white color code.
You could also define %player in the if statement (it's not necessary, but that's how I do it)


Woops

He actually just had the variables backwards, it's not a huge deal but it does make all the difference.

Code: [Select]
function serverCmdFindTags(%client, %player)
{
  if(!%client.isAdmin)
     return;
   %player=findclientbyname(%player);
   %Tag1 = %player.clanprefix;
   %Tag2 = %player.clansuffix;
   messageclient(%client,'',"\c7" @ %Tag1 SPC "\c6" @ %player.name SPC "\c7" @ %Tag2);
}

I personally wouldn't recommend using %player to describe a client object though. It's not incorrect, it's just potentially confusing to other coders who are reading your code.

Code: [Select]
function serverCmdGetTags(%client,%targetname)
{
 %target=findclientbyname(%targetname);
 messageclient(%client,'',"\c6The clan tags for" SPC %target.name SPC "are \c3" @ %target.clanprefix SPC "\c6and \c3" @%target.clansuffix"\c6."); //I can use %target.clanprefix/suffix, right?
}
The code i made from scratch used target
« Last Edit: September 28, 2014, 03:32:34 PM by Dannu »

It's also syntactically incorrect (no concatenation operator between %target.clansuffix and "\c6") and neither provide a fallback for an incorrectly entered player name, so if %target doesn't exist the message comes out to "The clan tags for  are  and  ."