Author Topic: Chat Commands  (Read 137 times)

Legacy__Okazaki

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
Chat Commands
« on: October 05, 2013, 05:42:22 pm »


               Hey there. I'm aware of doing simple chat commands, however this has become far too complicated for me. I'm attempting to create a simple chat command that when spoke allows the player to roll for a skill. So, what I'm trying to accomplish.. If a player speaks "#Roll Heal" it would roll a d20 + Their heal skill, and return the results to both them and all DMs online. My trouble is making the script not check for exact captilization. This being, "#ROLL HEAL" would return the same results as "#roll heal."
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Chat Commands
« Reply #1 on: October 05, 2013, 05:51:54 pm »


               GetStringUpperCase() would put the typed message in capitals.
               
               

               
            

Legacy__Okazaki

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
Chat Commands
« Reply #2 on: October 05, 2013, 08:32:59 pm »


               I want it to check for both upper case and lower case. What I'm asking is if there's any way to check for both lower and upper case without making seperate checks for GetStringUpperCase and GetStringLowerCase.
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Chat Commands
« Reply #3 on: October 05, 2013, 08:44:25 pm »


               Use TestStringAgainstPattern
               
               

               
            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
Chat Commands
« Reply #4 on: October 05, 2013, 08:48:09 pm »


               GetStringUpperCase() converts the string of text to all caps, so that your script does not have to check for every variation of "#roll heal", it just checks one.

if (GetStringUpperCase(sInput) == "#ROLL HEAL") ...

instead of...
if (sInput == "#roll heal" || sInput == "#Roll Heal" || sInput == "#ROLL HEAL" || sInput == "#roLL HeaL" || and on and on....)


You could also use GetStringLowerCase(), which converts the entire string into lowercase instead.
               
               

               


                     Modifié par The Amethyst Dragon, 05 octobre 2013 - 07:49 .
                     
                  


            

Legacy__Okazaki

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
Chat Commands
« Reply #5 on: October 05, 2013, 08:53:29 pm »


               That clears things up. Thanks! One more question. How would I script to send the results of the roll to all of the party members of the PC? I couldn't find any functions related to party members at all.
               
               

               


                     Modifié par _Okazaki, 05 octobre 2013 - 07:59 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Chat Commands
« Reply #6 on: October 05, 2013, 09:43:21 pm »


               Loop through faction members using GetFirstFactionMember and GetNextFactionMemeber.

example:

void main()
{
    object oPC = blah blah blah;
    string sString = "blah blah blah";
    object oMember = GetFirstFactionMember(oPC);
    while (GetIsObjectValid(oMember))
    {
        SendMessageToPC(oMember, sString);
        oMember = GetNextFactionMember(oPC);
    }
}
               
               

               


                     Modifié par GhostOfGod, 05 octobre 2013 - 08:48 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Chat Commands
« Reply #7 on: October 05, 2013, 10:28:50 pm »


               You could just have the PC speak the string in party chat.  

   if (GetStringUpperCase(sInput) == "#ROLL HEAL")
   {
   string sRoll = IntToString(d20()+ GetSkillRank(SKILL_HEAL,oPC));
   sRoll =  StringToRGBString (sRoll, STRING_COLOR_GREEN );

   string sMessage  =  "Rolled a "+ sRoll + " Heal check";

   AssignCommand(oPC,SpeakString(sMessage,TALKVOLUME_PARTY));
   }


The only reason for changing the roll to colored text, is to make sure the PC does not just type in there own result.  
you will need ot include x3_inc_string to use the StringToRGBString function
               
               

               


                     Modifié par Lightfoot8, 05 octobre 2013 - 09:31 .