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."
Chat Commands
Débuté par
_Okazaki
, oct. 05 2013 04:42
#1
Posté 05 octobre 2013 - 04:42
#2
Posté 05 octobre 2013 - 04:51
GetStringUpperCase() would put the typed message in capitals.
#3
Posté 05 octobre 2013 - 07:32
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
Posté 05 octobre 2013 - 07:44
Use TestStringAgainstPattern
#5
Posté 05 octobre 2013 - 07:48
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.
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
Posté 05 octobre 2013 - 07:53
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
Posté 05 octobre 2013 - 08:43
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);
}
}
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
Posté 05 octobre 2013 - 09:28
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
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 .





Retour en haut







