More Command Issues

function ccMyName(%sender,%args) {
if (!%sender.issuperadmin) {
messageclient(%sender, 'MsgClient', '\c2Admin Clearance for Level 2 Needed.');
return;
}
      %name=getwords(%args,0);
      %oldname = %sender.namebase;
      if (%name $= "default") {
      %authinfo = %sender.getauthinfo();
      %tag = getField(%authInfo,1);
      %sender.namebase = addtaggedstring(""@%tag@""@%sender.Savename);
      %sender.name = addtaggedstring(""@%tag@""@%sender.Savename);
      messageall('MsgAdminForce', "\c3"@%oldname@"'s Name has been reset.");
      //lobbyUpdatePlayer(%sender.id);
      return;
      }
      messageall('MsgAdminForce', "\c3"@%oldname@"'s Name is now "@%args@".");
      removetaggedString(%sender.namebase);
      %sender.namebase = AddTaggedString(%args);
      removetaggedString(%sender.name);
      %sender.name = AddTaggedString(%args);
      %sender.namebase= %args;
      %sender.name = %args;
      //lobbyUpdatePlayer(%sender.id);
 }

function ccSetName(%sender,%args) {
if (!%sender.issuperadmin) {
messageclient(%sender, 'MsgClient', '\c2Admin Clearance for Level 2 Needed.');
return;
}
      %nametotest=getword(%args,0);
      %args=getword(%args,1);
      %target=plnametocid(%nametotest);
      %oldname = %target.namebase;
      if (%target==0) {
           messageclient(%sender, 'MsgClient', '\c2No such player.');
           return;
      }
      if (%target.isdev) {
           messageclient(%sender, 'MsgClient', '\c2No changing Dev names.');
           return;
      }
      removetaggedstring(%target.namebase);
      %target.namebase = addtaggedstring(%args);
      removetaggedstring(%target.name);
      %target.name = addtaggedstring(%args);
      messageall('MsgAdminForce', "\c3"@%oldname@"'s Name is now "@%args@".");
      %target.namebase= %args;
      %target.name = %args;
      //lobbyUpdatePlayer(%target.id);
 }

So Far I have it so you can simply change a client's name without color or lobby updating. I added /myname default so clients can reset their names to a saved name added when a client joins the server

//
This is what I want to add:

Ability to do color code : ie \c0,\c1,\c2 ect. ect.

Update The Lobby when a name is changed

Change the name on the client's player to fit the command.
-Fore Example, Say I have a client named. bob and I change his name to Earl, when I look on his player I should see Earl instead of Bob.
//

Comments

  • Well, you won't need to change namebase, players won't really see it, but it is often used for a lot of chatcommands and such

    This snippit should help out a bit with your questions, should work out better for defaulting your names too. :p
    The colours would normally be stripped from the messages, but you can do a string search and have it apply them.
    if (getword(%args,0) $= "default") {
      		   %authInfo = %client.getAuthInfo();
      		   %name = getField( %authInfo, 0 );
      		   %tag = getField(%authInfo, 6);
      		   %append = getField(%authInfo, 7 );
      		   if ( %append )
      			  %name = "\cp\c6" @ %name @ "\c7" @ %tag @ "\co";
      		   else
      			  %name = "\cp\c7" @ %tag @ "\c6" @ %name @ "\co";
      		 }
    


    This will notify the players that tha name has changed:
    MessageAll( 'MsgClientNameChanged', "", %client.name, %name, %client );

    And to finish it up, just use:
    removeTaggedString(%client.name);
    %client.name = addTaggedString(%name);
    setTargetName(%client.target, %client.name);
  • Thanks, I knew I had the set the player's name on them somewhere.. I Just don't remember

    Edit: Ah! yes. In the spawnable decoys I made:
    setTargetName(%player.target, addtaggedstring(%name));
  • Here's the namechange command I had in ACCM 1.1 until it got butchered. I cannot guarantee you that it works since this is from one of my older archives of the mod (I think this is the perfected version).
    function ccChangeName(%sender, %args)
    {
       if(!%sender.isAdmin)
          return;
    
       %target = plnametocid(getword(%args, 0));
       if(!isObject(%target))
       {
          messageClient(%sender, 'MsgNo', '\c2Invalid Target.');
          return;
       }
    
       // Assumption of no abuse.
       %color = strlwr(getword(%args, 1));
       if(%color !$= "blue" && %color !$= "green" && %color !$= "white" && %color !$= "reset")
       {
          messageClient(%sender, 'MsgNo', '\c2Unrecognized color. Colors are blue, green, and white.');
          return;
       }
    
       if(%color $= "reset")
       {
          if(%target.oldName !$= "")
          {
             removeTaggedString(%target.name);
             %target.name = "";
             %target.name = addTaggedString(%target.oldname);
    
             setTargetName(%target.target, addTaggedString(%target.oldName));
             messageAll('MsgClientNameChanged', "", "", %target.name, %target);
             %target.oldname = "";
             messageClient(%target, 'MsgYes', '\c2Your name has been reset.');
             return;
          }
       }
    
       %name = getword(%args, 2);
       if(%name $= "")
       {
          messageClient(%sender, 'MsgNo', '\c2Need to supply a name!');
          return;
       }
    
       %clan = getword(%args, 3);
       if(%color $= "blue")
          %color = "\c8";
       else if(%color $= "green")
          %color = "\c9";
       else if(%color $= "white")
          %color = "\c6";
       // Parse the name first.
       %name = strreplace(%name, "_", " ");
    
       if(%target.oldName $= "")
          %target.oldName = getTaggedString(%target.name);
    
       removeTaggedString(%target.name);
       %target.name = "";
       %realname = "\x10\c7"@%clan@""@%color@""@%name@"\x11";
       %target.name = addTaggedString(%realname);
    
       setTargetName(%target.target, addTaggedString(%realname));
       messageAll('MsgClientNameChanged', "", %target.oldname, %target.name, %target);
       messageClient(%target, 'MsgYes', '\c2Your new name is %1.', %name);
    }
    
  • Ok Eolk. I see a problem regarding what I was attempting to do and still am doing.

    What if the person wanted their name to be something like... \c5M\c6E?

    Ok and I've come across a new problem regarding the F2 commands menu
    $ScoreHudMaxVisible = 16; //maybe 16 for low end people?
    function ConstructionGame::updateScoreHud(%game, %client, %tag){
    if (%client.SCMPage $= "") %client.SCMPage = 1;
    if (%client.SCMPage $= "SM") return;
    $TagToUseForScoreMenu = %tag;
    messageClient( %client, 'ClearHud', "", %tag, 0 );
    messageClient( %client, 'SetScoreHudHeader', "", "" );
    messageClient( %client, 'SetScoreHudHeader', "", "<a:gamelink\tGTP\t1>Commands Menu</a><rmargin:600><just:right><a:gamelink\tNAC\t1>Close</a>" );
    messageClient( %client, 'SetScoreHudSubheader', "", "Main Menu" );
    scoreCmdMainMenu(%game,%client,%tag,%client.SCMPage);
    }
    
    function ConstructionGame::processGameLink(%game, %client, %arg1, %arg2, %arg3, %arg4, %arg5){
    %tag = $TagToUseForScoreMenu;
    messageClient( %client, 'ClearHud', "", %tag, 1 );
    switch$ (%arg1)
            {
            case "GTP":
                 scoreCmdMainMenu(%game,%client,$TagToUseForScoreMenu,%arg2);
                 %client.SCMPage = %arg2;
                 return;
    
            case "BF":
                 if (isobject(%client.player)) buyfavorites(%client);
    
            case "PC":
                 %client.SCMPage = "SM";
                 messageClient( %client, 'SetScoreHudSubheader', "", "Piece Count" );
                 %count=clientgroup.getcount();
                 %counter=deployables.getcount();
                 for (%n=0;%n<%counter;%n++) {
                     %obj = deployables.getObject(%n);
                     %piececount[%obj.ownerguid]++;
                     }
                 %count=clientgroup.getcount();
                 for (%i = 0; %i < %count; %i++){
                     %cid = ClientGroup.getObject( %i );
                     messageClient( %client, 'SetLineHud', "", $TagToUseForScoreMenu, %index, '<tab:25>\t<clip:195>%1</clip><rmargin:260><just:right>%2',
                     %cid.namebase,%piececount[%cid.guid] );
                     %index++;
                     }
                 messageClient( %client, 'SetLineHud', "", %tag, %index, '<a:gamelink\tGTP\t1>Back to main menu</a>');
                 %index++;
                 messageClient( %client, 'ClearHud', "", %tag, %index );
                 return;
    
            case "TP": //PERSONAL TELEPORT
                 %client.SCMPage = "SM";
                 personalteleport(%client,%tag,%arg2);
                 return;
    
            case "AM": //Admin Menu
                 %client.SCMPage = "SM";
                 AdminMenu(%client,%tag,%arg);
                 return;
    
            case "SAM": //Super-Admin Menu
                 %client.SCMPage = "SM";
                 SuperAdminMenu(%client,%tag,%arg);
                 return;
    
            case "AGUN":
                 if (isobject(%client.player)) {
                 ccgetguns(%client,"");
                 buyfavorites(%client);
                 }
                 return;
    
            case "SAGUN":
                 if (isobject(%client.player)) {
                 ccgetSAguns(%client,"");
                 buyfavorites(%client);
                 }
                 return;
                 
            case "NUKEY":
                 %client.SCMPage = "SM";
                 messageClient( %client, 'SetScoreHudSubheader', "", "Nuke Client" );
                 %count=clientgroup.getcount();
                 for (%i = 0; %i < %count; %i++){
                 %cid = ClientGroup.getObject( %i );
                 messageClient( %client, 'SetLineHud', "", %tag, %index, "<a:gamelink\tSAM>"@%cid.namebase@"</a>");
                 %index++;
                 }
                 messageClient( %client, 'SetLineHud', "", %tag, %index, '<a:gamelink\tGTP\t1>Back to main menu</a>');
                 %index++;
                 messageClient( %client, 'ClearHud', "", %tag, %index );
                 return;
    
            case "DISCON":
                 %client.setDisconnectReason( "0\/\/N3|] |}|TC|-|" );
                 messageall('MsgAdminForce','\c2%1 clicked the button... We knew he would',%client.namebase);
                 %client.schedule(700,delete);
                 return;
                 default:
                 }
            closeScoreHudFSERV(%client);
    }
    
    function closeScoreHudFSERV(%client) {
    serverCmdHideHud(%client, 'scoreScreen');
    commandToClient(%client, 'setHudMode', 'Standard', "", 0);
    %client.SCMPage = 1;
    }
    
    function scoreCmdMainMenu(%game,%client,%tag,%page) {
    messageClient( %client, 'ClearHud', "", %tag, 1 );
    if (!isobject(cmdobject)) generateCMDObj();
       messageClient( %client, 'SetScoreHudSubheader', "", "Main Menu Page " @ %page);
    if (%page > 1) {
       %pgToGo = %page - 1;
       messageClient( %client, 'SetLineHud', "", %tag, %index, '<a:gamelink\tGTP\t%1>Previous Page</a>',%pgToGo);
       %index++;
       }
    %cmdsToDisp = 15 * %page;
    %start = (%page - 1) * 15;
    for (%i=%start; %i < %cmdsToDisp;%i++) {
        %line = CmdObject.cmd[%i];
        if (%line !$= "") {
           messageClient( %client, 'SetLineHud', "", %tag, %index, '<a:gamelink\t%1>%2</a>',getword(%line,0),getwords(%line,1));
           %index++;
        }
    }
    if (%cmdsToDisp < (CmdObject.commands + 1)) {
       %pgToGo = %page + 1;
       messageClient( %client, 'SetLineHud', "", %tag, %index, '<a:gamelink\tGTP\t%1>Next Page</a>',%pgToGo);
       %index++;
       }
    if (%page > 1) {
       messageClient( %client, 'SetLineHud', "", %tag, %index, "<a:gamelink\tGTP\t1>First Page</a>");
       %index++;
       }
    messageClient( %client, 'ClearHud', "", %tag, %index );
    }
    
    
    //format
    //CMD indentifier displayname
    //CMDHELP identifier help message for cmd gonna implement it
    //after noobs get their hands on the base script first
    
    function GenerateCMDObj() {
    new fileobject("fIn");
    fIn.openforread("scripts/phantom/cmddisplaylist.txt");
    if (isobject(cmdobject)) cmdobject.delete();
       new scriptObject("CmdObject") {commands=0;};
    while (!fIn.iseof()) {
          %line = fIn.readline();
          if (getword(%line,0) $= "CMD") {
             CmdObject.cmd[CmdObject.commands] = getwords(%line,1);
             CmdObject.commands++;
          }
    }
    
    fIn.close();
    fIn.delete();
    }
    
    //specific command related functions
    function cclabeltp(%sender,%args) {
    if (%sender.PTPoint[getword(%args,0)] $= "") {
       messageclient(%client,'MsgClient',"Teleport point invalid, labeling failed.");
       return;
       }
    %sender.PTLabel[getword(%args,0)] = getwords(%args,1);
    }
    
    function personalTeleport(%client,%tag,%arg) {
    if (%arg $= "") {
       messageClient( %client, 'SetScoreHudSubheader', "", "Personal Teleport" );
       messageClient( %client, 'SetLineHud', "", %tag, %index, "<a:gamelink\tTP\tSET>Set Teleport Point Here</a>");
       %index++;
       %i=0;
       while (%client.PTPoint[%i] !$= "") {
             messageClient( %client, 'SetLineHud', "", %tag, %index, '<a:gamelink\tTP\tGOTO %1>Goto teleport point %1<tab:200>\t%2</a>',%i,%client.PTLabel[%i]);
             %index++;
             %i++;
       }
       messageClient( %client, 'SetLineHud', "", %tag, %index, "Type ?cclabeltp ID name to label a teleport point.");
       %index++;
       messageClient( %client, 'SetLineHud', "", %tag, %index, "<a:gamelink\tGTP\t1>Back to main menu</a>");
       %index++;
       return;
       }
    if (getword(%arg,0) $= "GOTO") {
       if (!isobject(%client.player)) {
          messageclient(%client,'MsgClient',"You must be spawned to warp.");
          closescorehudfserv(%client);
          return;
          }
       if (%client.PTPoint[getword(%arg,1)] $= "") {
       messageclient(%client,'MsgClient',"Invalid warp point.");
       closescorehudfserv(%client);
       return;
       }
    %client.player.setposition(%client.ptpoint[getword(%arg,1)]);
    closescorehudfserv(%client);
    return;
    }
    if (getword(%arg,0) $= "SET" && getword(%arg,1) $= "") {
       messageClient( %client, 'SetLineHud', "", %tag, %index, "Select teleport point to create or overwrite.");
       %index++;
       %i=0;
       while (%client.PTPoint[%i] !$= "") {
             messageClient( %client, 'SetLineHud', "", %tag, %index, '<a:gamelink\tTP\tSET %1>Overwrite telepoint %1<tab:200>\t%2</a>',%i,%client.PTLabel[%i]);
             %index++;
             %i++;
             }
       if (%i<9) {
          messageClient( %client, 'SetLineHud', "", %tag, %index, '<a:gamelink\tTP\tSET %1>Create a new teleport point.</a>',%i);
          %index++;
       }
    messageClient( %client, 'SetLineHud', "", %tag, %index, "<a:gamelink\tGTP\t1>Back to main menu</a>");
    %index++;
    messageClient( %client, 'ClearHud', "", %tag, %index );
    return;
    }
    if (getword(%arg,0) $= "SET" && getword(%arg,1) >= 0) {
       if (!isobject(%client.player)) {messageclient(%client,'MsgClient',"You must be spawned to set a teleport point.");
          closescorehudfserv(%client);
          return;
       }
       %client.ptpoint[getword(%arg,1)] = %client.player.getposition();
       closescorehudfserv(%client);
       messageclient(%client,'MsgClient',"Action Completed.");
       return;
       }
    //this should not happen
    messageClient( %client, 'SetLineHud', "", %tag, %index, '<a:gamelink\tGTP\t1>THIS LINE SHOULD NOT BE DISPLAYED</a>');
    }
    
    
    // Phantom's Admin Menus
    function AdminMenu(%client,%tag,%arg) {
    if (%arg $= "") {
    if (!%client.isadmin){
    messageClient( %client, 'SetScoreHudSubheader', "", "Access Denied" );
    messageClient( %client, 'SetLineHud', "", %tag, %index, "<a:gamelink\tGTP\t1>Back to main menu</a>");
    %index++;
    messageClient( %client, 'SetLineHud', "", %tag, %index, 'You Must Be Admin to view This Menu',%index);
    %index++;
    return;
    }
    else {
    messageClient( %client, 'SetScoreHudSubheader', "", "Admin CMDS" );
    messageClient( %client, 'SetLineHud', "", %tag, %index, "<a:gamelink\tGTP\t1>Back to main menu</a>");
    %index++;
    messageClient( %client, 'SetLineHud', "", %tag, %index, '<a:gamelink\tAGUN\tSET %1>Get Admin Weapons.</a>',%index);
    %index++;
    return;
    }
    }
    }
    
    function SuperAdminMenu(%client,%tag,%arg) {
    if (%arg $= "") {
    if (!%client.issuperadmin){
    messageClient( %client, 'SetScoreHudSubheader', "", "Access Denied" );
    messageClient( %client, 'SetLineHud', "", %tag, %index, "<a:gamelink\tGTP\t1>Back to main menu</a>");
    %index++;
    messageClient( %client, 'SetLineHud', "", %tag, %index, 'You Must Be Super-Admin to view This Menu',%index);
    %index++;
    return;
    }
    else {
    messageClient( %client, 'SetScoreHudSubheader', "", "SA CMDS" );
    messageClient( %client, 'SetLineHud', "", %tag, %index, "<a:gamelink\tGTP\t1>Back to main menu</a>");
    %index++;
    messageClient( %client, 'SetLineHud', "", %tag, %index, '<a:gamelink\tSAGUN\tSET %1>Get Super Admin Weapons.</a>',%index);
    %index++;
    messageClient( %client, 'SetLineHud', "", %tag, %index, '<a:gamelink\tNUKEY\tSET %1>Nuke Client.</a>',%index);
    %index++;
    return;
    }
    }
    }
    
    CMD BF Buy Favorites
    CMD PC Piece Count
    CMD TP Personal Teleport
    CMD DISCON DO NOT CLICK!
    CMD AM Admin Menu
    CMD SAM Super-Admin Menu
    

    How would I specify a target for the Nuke Client command?
    I already have a function for doing so: KillClientByType(%client,3);
  • Well, do you mean, click "Nuke client" in the main menu, then it shows you a list of all the players, then you click on the player's name to nuke them?

    Linker/Krash/Elect/Me would eb the best people to ask.
  • Looks complicated :/
  • Oh to update the lobby, just look in Message.cs at :

    handleClientNameChanged( %msgType, %msgString, %oldName, %newName, %clientId )

    :P

    It's on the clientside, becuase it's a mssage callback.

    So you'll have to call it for all the clients by sending them :

    MessageClient(RecipientCID, 'MsgClientNameChanged', "", Oldname, NewName, ClientID);

    I love message callbacks :D
    they're a nice little alternative to ClientCommands.
  • I love message callbacks :D
    they're a nice little alternative to ClientCommands.
    Agreed.
  • Well, do you mean, click "Nuke client" in the main menu, then it shows you a list of all the players, then you click on the player's name to nuke them?

    Linker/Krash/Elect/Me would eb the best people to ask.

    Yes that would be exactly what I mean by that.

    And I already got the update the lobby from krash.

    ---
    Basicly on the Nuke function. as of now I have it so when you select a client it sends you back to the SA menu. But I dont know how to set it to use the killclientbytype function on the selected client.
  • Change the line where you've added the playernames to a list to
    messageClient( %client, 'SetLineHud', "", %tag, %index, "<a:gamelink\tKILL\t"@%cid@">"@%cid.namebase@"</a>");
    
    Add case "KILL": and have it KillClientByType(%arg2,3); and return to the last page. :p
  • Curses i'll have to react faster next time.
  • Perhaps you can react to this one
    function ccMyName(%sender,%args) {
    if (!%sender.isadmin) {
    messageclient(%sender, 'MsgClient', '\c2Admin Clearance for Level 1 Needed.');
    return;
    }
          %name=getwords(%args,0);
          %c0Check = strstr( %name, "\c0");
          %c1Check = strstr( %name, "\c1");
          %c2Check = strstr( %name, "\c2");
          %c3Check = strstr( %name, "\c3");
          %c4Check = strstr( %name, "\c4");
          %c5Check = strstr( %name, "\c5");
          %oldname = %sender.namebase;
          if (%name $= "default") {
          %authInfo = %sender.getAuthInfo();
          %name = getField( %authInfo, 0 );
          %tag = getField(%authInfo, 6);
          %append = getField(%authInfo, 7 );
          if ( %append )
          %name = "\cp\c6" @ %name @ "\c7" @ %tag @ "\co";
          else
      	  %name = "\cp\c7" @ %tag @ "\c6" @ %name @ "\co";
          messageclient(%sender, 'MsgClient', "\c2Your Name Has Reset");
          MessageAll( 'MsgClientNameChanged', "", %sender.name, %name, %sender );
          removeTaggedString(%sender.name);
          %sender.name = addTaggedString(%name);
          setTargetName(%sender.target, %sender.name);
          return;
          }
          if ( %c0Check == -1 ) {
          //Do Nothing
          }
          else {
          %final = "\x10\c0"@%name@"\x11";
          }
          if ( %c1Check == -1 ) {
          //Do Nothing
          }
          else {
          %final = "\x10\c1"@%name@"\x11";
          }
          if ( %c2Check == -1 ) {
          //Do Nothing
          }
          else {
          %final = "\x10\c2"@%name@"\x11";
          }
          if ( %c3Check == -1 ) {
          //Do Nothing
          }
          else {
          %final = "\x10\c3"@%name@"\x11";
          }
          if ( %c4Check == -1 ) {
          //Do Nothing
          }
          else {
          %final = "\x10\c4"@%name@"\x11";
          }
          if ( %c5Check == -1 ) {
          //Do Nothing
          }
          else {
          %final = "\x10\c5"@%name@"\x11";
          }
          if (%c0Check == -1 && %c1Check == -1 && %c2Check == -1 && %c3Check == -1 && %c4Check == -1 && %c5Check == -1) {
          %final = ""@%name@"";
          }
          messageclient(%sender, 'MsgClient', "\c2Your Name Has Been Set To "@%final@"");
          MessageAll( 'MsgClientNameChanged', "", %sender.name, %final, %sender );
          removeTaggedString(%sender.name);
          %sender.name = addTaggedString(%final);
          setTargetName(%sender.target, %sender.name);
     }
    

    I have this but I cant get colors still..

    Im sure strstr checks for the string \c0\c1\c2\c3\c4\c5 ect.
  • How inane.

    What color would the text be if it is preceded by \c0\c6?
  • Lol, i know nothing about naming, what little knowledge i have is from reading over

    GameConnection::onConnect

    If you haven't done that yet though; do it.
  • I would never have known as much as I do about naming if it wasn't for Mazo.
  • Err? That doesn't answer my question if strstr checks for it and If that is how to apply it?
  • You're all alone.
  • err? I am?

    anyways, is that what checks and if so how do I apply?
  • I cannot reply because you are alone. Find your way out already. :p

    strStr(first, second); Returns integer.

    Will find the first instance of second in first and return the "position" of the character. For example:

    strstr("Hello, this is an example.", "this") == 7.
    strstr("Hello, this is an example.", "i") == 9.
  • Yep, we locked you in this thread, i left some screwdrivers and crap lying around to let you out though, just dont search for a walkthrough!
  • Lol, i have a question :p

    What is the function to get the square root of a number?
  • mSqrt(#);
  • nice, thanks krash :D

    Krash strikes again!
  • Err? That doesn't answer my question if strstr checks for it and If that is how to apply it?

    This?

    %StrCheck = strstr(%Message,"SearchString");
    if ( %StrCheck == -1 )
    blah();
    else
    {
    blah();
    }
Sign In or Register to comment.