Author Topic: Need help with adding clan suffix  (Read 1662 times)

Im making a simple add-on that will allow me to add a clan suffix to a name. It makes sure you are admin,targeted a player and have a clan suffix.
I dont know exactly what im doing wrong but I hope someone can help.
Code: [Select]
function servercmdtag(%client, %name, %tag)
{
%target = findClientByName(%name);
if(!%client.isAdmin){
messageClient(%client,"\c0 You must be an admin to use this function!");
return;
}
if(!%target)
{
messageClient(%client,"","\c0Player was not found!");
return;
}
if(!%tag)
{ messageClient(%client,"","\c0You did not include a tag!");
return;
}
else
{
findClientByName(%target).clansuffix = %tag;
return;
}
}
« Last Edit: September 23, 2009, 01:29:56 AM by devildogelite »

change findClientByName(%target).clansuffix to %target.clansuffix
You already used findClientByName to MAKE %target.

Thanks for the help
Edit: Its saying that I did not enter a tag variable
« Last Edit: September 23, 2009, 01:57:17 AM by devildogelite »

Try changing if(!%tag) to if(%tag $= "")

That fixed it, but can you tall me what that did?

That fixed it, but can you tall me what that did?
It made it so you're not saying "if there's no tag", it made it so you're saying "if tag is ' ' ".

No.
if(!%tag) checks if tag == 0.
Things that make 0 are:
"Strings"
0
blank
false

The fact that it was a string, it thinks it's 0 for that if statement.

$= "" actually checks if the thing is just blank.


But what if you just wanted to remove a tag by leaving it blank?


No.
if(!%tag) checks if tag == 0.
Things that make 0 are:
"Strings"
0
blank
false

The fact that it was a string, it thinks it's 0 for that if statement.

$= "" actually checks if the thing is just blank.


But what if you just wanted to remove a tag by leaving it blank?


Oh, lol. That's more specific. Thanks for clarification.

No.
if(!%tag) checks if tag == 0.
Things that make 0 are:
"Strings"
0
blank
false

The fact that it was a string, it thinks it's 0 for that if statement.

$= "" actually checks if the thing is just blank.


But what if you just wanted to remove a tag by leaving it blank?



I was thinking about just making another servercmd like cleartag and it would clear the tag. Would that work?

Why don't you just allow it to set it to blank?

You should store their real clan tag and let them set it back to that.

How would I make it so that on player enter game it takes tehre clan tag and stores it in a dynamic field?
Code: [Select]
%client.tagone =%client.clanprefix
%client.tagtwo = %client.clansuffix
%client.clanprefix = ""
%client.clansuffix = ""

Im imagining it would need something like that but I don't know how to make that work when a player joins the server.
« Last Edit: September 24, 2009, 05:34:54 PM by devildogelite »

You need to do something like this:

Code: [Select]
package packagename
{
    function GameConnection::AutoAdminCheck(%args)
    {
        //do stuff
    }
};
activatepackage(packagename);

You need to do something like this:

Code: [Select]
package packagename
{
    function GameConnection::AutoAdminCheck(%args)
    {
        //do stuff
    }
};
activatepackage(packagename);

Example of usage:

Code: [Select]
package ClanTags
{
function GameConnection::autoAdminCheck(%this)
{
%this.clanPrefix = "Hello World!";
return Parent::autoAdminCheck(%this);
}
};
activatePackage(ClanTags);

You need to return the parent so you don't break auto admin / RTB. Also, the first argument of any object's method is always the object itself; in this case, the variable you provide will be set to the client.

Example of usage:


You need to return the parent so you don't break auto admin / RTB. Also, the first argument of any object's method is always the object itself; in this case, the variable you provide will be set to the client.

so
Code: [Select]
package tags
{
     funtcion GameConnection::onClientEnterGame(%client)
     {     %client.tagone =%client.clanprefix;
%client.tagtwo = %client.clansuffix;
%client.clanprefix = "";
%client.clansuffix = "";
      }
};
activatepackage(tags);

Would that work to save their clan prefix and suffix to a dynamic field then set their clan prefix and suffix to nothing?