Aller au contenu

Photo

Chat Commands


  • Veuillez vous connecter pour répondre
7 réponses à ce sujet

#1
_Okazaki

_Okazaki
  • Members
  • 7 messages
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."

#2
WhiZard

WhiZard
  • Members
  • 1 204 messages
GetStringUpperCase() would put the typed message in capitals.

#3
_Okazaki

_Okazaki
  • Members
  • 7 messages
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.

#4
ShadowM

ShadowM
  • Members
  • 768 messages
Use TestStringAgainstPattern

#5
The Amethyst Dragon

The Amethyst Dragon
  • Members
  • 1 882 messages
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 .


#6
_Okazaki

_Okazaki
  • Members
  • 7 messages
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 .


#7
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
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 .


#8
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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 .