Author Topic: VIP script not working  (Read 1573 times)

/title

When I say something in the chat when I have VIP, 1 tag gets added. Also, I'm my dedicated server.

Link: https://www.dropbox.com/s/lmxj82lskdutb6g/Script_VIP.zip?dl=1


  %t=%c.clanSuffix;
      if($canVIP[%c.bl_id])
         %c.clanSuffix=%t@"\c6[\c4VIP\c6]";
      parent::servercmdMessageSent(%c,%m);
      %c.clanSuffix=%t;


Every time you chat it's setting your clantag to your previous one in addition to the tag.

not much of a coder, so how could I fix that?

Replace:

  %t=%c.clanSuffix;
      if($canVIP[%c.bl_id])
         %c.clanSuffix=%t@"\c6[\c4VIP\c6]";
      parent::servercmdMessageSent(%c,%m);
      %c.clanSuffix=%t;

With:
Code: [Select]
  %t=%c.clanSuffix;
      if(!getSubStr(StripMLControlChars(%t),"[VIP]")
      {
         if($canVIP[%c.bl_id])
            %c.clanSuffix=%t@"\c6[\c4VIP\c6]";
      }
      parent::servercmdMessageSent(%c,%m);
      %c.clanSuffix=%t;
This will check if you already have "[VIP]" in your clan prefix, if not then it will add the tag, if your clan suffix contains VIP already then it will not add the tag.


noedit:

it's not working anymore

new link

Glad you caught my message about my mistake.
Code: [Select]
package VIPTag
{
   function servercmdMessageSent(%c,%m)
   {
       %t=%c.clanSuffix;
      if(!StrStr(StripMLControlChars(%t),"[VIP]")
      {
         if($canVIP[%c.bl_id])
            %c.clanSuffix=%t@"\c6[\c4VIP\c6]";
      }
      parent::servercmdMessageSent(%c,%m);
      %c.clanSuffix=%t;
   }
};
Code in question.
Upon further investigation I got:
==>echo(StrStr(StripMLControlChars("\c6[\c4VIP\c6]"),"[VIP]"));
0

Which doesn't make much sense to me when I got this:
==>echo(isFunction(stripmlcontrolchars));
1
==>echo(stripmlcontrolchars("\c6[\c4VIP\c6]"));
[VIP]
==>echo("\c6[\c4VIP\c6]");
[VIP]


You'll need a better coder than I, I guess.

Should note the console has characters that will not display on the forums in the last echo.

Considering it does not save then you could just set the tag when you set the player.

First of all, there's a syntax error on line 6.

Even if there was no syntax error, it'll constantly be applying the [VIP] tag because of your check on line 6.
Code: [Select]
if(!StrStr(StripMLControlChars(%t),"[VIP]"))
strStr(sourceString, searchString) returns where it found searchString in sourceString, NOT a boolean. In your check, it's always returning 0 after the first time it's applied the tags, because the first instance of [VIP] it finds, starts at character 0. So instead you should change it to:
Code: [Select]
if(strStr(stripMLControlChars(%t), "[VIP]") == -1)

Considering it does not save then you could just set the tag when you set the player.
No true. It exports the variables when someone gets VIP or has it removed and it executes the variables when the add-on is loaded.

Something I just saw.
Put this at the bottom of the script.
Code: [Select]
function isInt(%string)
{
   return (%string $= mFloatLength(%string, 0));
}
isInt is used in your script, but it's not included in it and it's not a default function. It's an RTB function, so if you don't have RTB there will be a lot of console errors and some of the script will break.

thanks, it works perfectly!