View previous topic :: View next topic |
Author |
Message |
Skipper Warlock
Joined: 31 Mar 2007 Posts: 10
|
Posted: Sat Mar 31, 2007 10:38 Post subject: Need Help adding and editing commands in SimTools |
|
|
Just a little background, I've spent the past week attempting to set up my own admin system much like shrubbot in wolfenstein enemy territory. If you have never played ET, the system basicly just allows you to set any player playing to a level defiined in your shrubbot.cfg, if you have the proper admin to do this, and they are allowed to use the commands appropriate for that level. I decided I would try and do this with SimTools because it already has most of the commands I wanted set up anyway. In ET, all you have to do to set a level is say !setlevel <name> <level>. I wanted to be able to set the admin in tell, which didn't seem to be a problem until I actually tried to do it, lol. But basicly, I wanted to be able to send a tell that said !setlevel 1 and it give them a level 1 token, allowing for the commands to just check and see if they have that token. I also wanted to be able to have their admin level show up in the !playerinfo command. I went through every script line by line and changed everything it looked like I needed to for adding a command and for editing what the playerinfo box displayed, and ended up making absolutely no progress because I wouldn't even recognize my command as valid. So if I someone could at least point me in the right direction on how to do this, it would be much appriciated.
note: if I need to elaborate a bit more I can, just let me know |
|
Back to top |
|
|
FunkySwerve
Joined: 02 Jun 2005 Posts: 377
|
Posted: Sun Apr 01, 2007 20:17 Post subject: |
|
|
Did you compile the scripts after saving them? You may need the prc or torlack compiler, as the bioware compiler likes to choke on large numbers of consts. Adding a command is reletively easy, once you understand the structure of the script. There is a master switch that assigns a number to each letter than any command starts with, using FindSubString. Commands starting with that letter fgo in that case, otherwise they will return invald commands. If you have commands that start with a letter not in the case, you need to add a case, and by inserting the letter in the FindSubString and incresing the numbers of the cases in the switch that follow the added case. Here's an example of a switch with some additional starting letters added (from the upcoming version 3.0):
Code: | sSort = GetStringLeft(sCText, 1);
nText = FindSubString("a d h i l m p s t u w", sSort);
switch (nText) //0 2 4 6 8 101214161820
{
case -1: CommandRedirect(oCPC, 1); break;
/*a*/ case 0:
if (sCText == "anon")
{
SetLocalInt(oCPC, "FKY_CHAT_ANON", 1);
SendMessageToPC(oCPC, COLOR_RED+ANON+COLOR_END);
}
else if (GetStringLeft(sCText, 2) == "an") CommandRedirect(oCPC, 2);
else CommandRedirect(oCPC, 1);
break;
/*d*/ case 2:
if (GetStringLeft(sCText, 6) == "delete")
{
nCount = GetLocalInt(oCTarget, "FKY_CHAT_DELETE_CONFIRM");
if (nCount == 1)
{
if (!GetIsObjectValid(oCTarget))//target verification - do they need to use the command targeter?
{
|
This is the standard commands, not dm commands switch. Note the new help command is in a new letter case, h:
Code: | /*h*/ case 4:
if (sCText == "help") ListHelp(oCPC);
else CommandRedirect(oCPC, 6);
break;
/*i*/ case 6:
if (sCText == "ignore")
{ |
the case for i, and each on after it, had to be bumped down in the FindSubString and the switch to make room. Make sense?
If you need more help I hagve a forum set up:
http://highergroundpoa.proboards3.com/index.cgi?board=simtools
Funky
Funky |
|
Back to top |
|
|
Skipper Warlock
Joined: 31 Mar 2007 Posts: 10
|
Posted: Mon Apr 02, 2007 5:52 Post subject: |
|
|
Thanks a ton, this is exactly what I needed
just a small question. How would I go about adding things to the !plyerinfo command? I found it in the fky_chat_inc script but apparantly what I did was wrong. here it is. basicly, I'm tryin to get it to look for the item on the PC by the tag and echo that item's name to the player and naming the item to correspond with the admin. Idealy I think I need to have it set to say a number based on the item but I'm a scripting noob and not sure how to do this :/ but if there is a script I am missing or something please let me know. I did change some stuff in the fky_chat_const to correspond with what I have in the combine
Code: |
void ShowInfo(object oPlayer, object oGetInfoFrom)
{
//collect info
string sName = GetName(oGetInfoFrom);
string sPlayername = GetPCPlayerName(oGetInfoFrom);
string sKey = GetPCPublicCDKey(oGetInfoFrom);
string sIP = GetPCIPAddress(oGetInfoFrom);
//line I added
string sAdmin = GetName(GetItemPossessedBy(oPC, "level_1"));
//end
int nClass1 = GetClassByPosition(1, oGetInfoFrom);
int nClass2 = GetClassByPosition(2, oGetInfoFrom);
int nClass3 = GetClassByPosition(3, oGetInfoFrom);
int nClassLevel1 = GetLevelByClass(nClass1, oGetInfoFrom);
int nClassLevel2 = GetLevelByClass(nClass2, oGetInfoFrom);
int nClassLevel3 = GetLevelByClass(nClass3, oGetInfoFrom);
int nControlClass = nClass1;
if ((nClassLevel1 > nClassLevel2) && (nClassLevel1 > nClassLevel3)) nControlClass = nClass1;
else if ((nClassLevel2 > nClassLevel1) && (nClassLevel2 > nClassLevel3)) nControlClass = nClass2;
else if ((nClassLevel3 > nClassLevel1) && (nClassLevel3 > nClassLevel2)) nControlClass = nClass3;
else if (nClassLevel1 == nClassLevel2) nControlClass = nClass1;
else if (nClassLevel1 == nClassLevel3) nControlClass = nClass1;
else if (nClassLevel2 == nClassLevel3) nControlClass = nClass2;
int nLevel = GetHitDice(oGetInfoFrom);
int nLL = GetNumberOfLegendaryLevels(oGetInfoFrom);
int nTotal = nLevel + nLL;
string sClasses = COLOR_LT_BLUE2+GetClassName(nClass1)+COLOR_END+COLOR_WHITE+": "+IntToString(nClassLevel1)+COLOR_END;
if (nClass2 != CLASS_TYPE_INVALID) sClasses += COLOR_WHITE+", "+COLOR_END+COLOR_LT_BLUE2+GetClassName(nClass2)+COLOR_END+COLOR_WHITE+": "+IntToString(nClassLevel2)+COLOR_END;
if (nClass3 != CLASS_TYPE_INVALID) sClasses += COLOR_WHITE+", "+COLOR_END+COLOR_LT_BLUE2+GetClassName(nClass3)+COLOR_END+COLOR_WHITE+": "+IntToString(nClassLevel3)+COLOR_END;
if (nLL) sClasses += COLOR_WHITE+", "+COLOR_END+COLOR_LT_BLUE2+LEGLEVEL+COLOR_END+COLOR_LT_BLUE+"["+GetClassName(nControlClass)+"]"+COLOR_END+COLOR_WHITE+": "+IntToString(nLL)+COLOR_END;
if ((nClass2 != CLASS_TYPE_INVALID) || (nLL)) sClasses += COLOR_WHITE+", "+COLOR_END+COLOR_BLUE+NFOHD+COLOR_END+COLOR_WHITE+": "+IntToString(nTotal)+COLOR_END;
string sDeity = GetDeity(oGetInfoFrom);
if (sDeity == "") sDeity = NONE;
int nGold = GetGold(oGetInfoFrom);
int nGoldTotal, nValue, nX;
object oItem = GetFirstItemInInventory(oGetInfoFrom);
while (GetIsObjectValid(oItem))
{
nValue = GetGoldPieceValue(oItem);
nGoldTotal += nValue;
oItem = GetNextItemInInventory(oGetInfoFrom);
}
for (nX = 0; nX < 14; nX++)
{
oItem = GetItemInSlot(nX, oGetInfoFrom);
nValue = GetGoldPieceValue(oItem);
nGoldTotal += nValue;
}
nGoldTotal += nGold;
string sSubrace = GetSubRace(oGetInfoFrom);
if (sSubrace == "") sSubrace = NONE;
int nXP = GetXP(oGetInfoFrom);
int nNextXP = (( nLevel * ( nLevel + 1 )) / 2 * 1000 );
int nXPForNextLevel = nNextXP - nXP;
if (nLevel == 40) nXPForNextLevel = 0;
string sArea = GetName(GetArea(oGetInfoFrom));
string sFactionMembers = "";
object oLeader = GetFactionLeader(oGetInfoFrom);
object oMember = GetFirstFactionMember(oGetInfoFrom);
while (GetIsObjectValid(oMember))
{
if (oMember == oLeader) sFactionMembers = COLOR_WHITE+GetName(oMember)+COLOR_END+COLOR_BLUE+" ["+LFG1+IntToString(GetNumberOfLegendaryLevels(oMember) + GetHitDice(oMember))+"] "+COLOR_END+COLOR_ORANGE+LEADER+COLOR_END+NEWLINE+sFactionMembers;
else sFactionMembers = sFactionMembers+COLOR_WHITE+GetName(oMember)+COLOR_END+COLOR_BLUE+" ["+LFG1+IntToString(GetNumberOfLegendaryLevels(oMember) + GetHitDice(oMember))+"] "+COLOR_END+NEWLINE;
oMember = GetNextFactionMember(oGetInfoFrom);
}
//combine
string sMessage = COLOR_PURPLE+NFOHEADER+COLOR_END+NEWLINE;
sMessage += COLOR_PURPLE+NFO1+COLOR_END+COLOR_WHITE+sName+COLOR_END+NEWLINE;
sMessage += COLOR_PURPLE+NFO2+COLOR_END+COLOR_WHITE+sPlayername+COLOR_END+NEWLINE;
sMessage += COLOR_PURPLE+NFO3+COLOR_END+COLOR_WHITE+sKey+COLOR_END+NEWLINE;
//line I added
sMessage += COLOR_PURPLE+NFO15+COLOR_END+COLOR_WHITE+sAdmin+COLOR_END+NEWLINE;
//end
if (VerifyDMKey(oPlayer) || VerifyAdminKey(oPlayer) || (oPlayer == oGetInfoFrom)) sMessage += COLOR_PURPLE+NFO4+COLOR_END+COLOR_WHITE+sIP+COLOR_END+NEWLINE;
if (VerifyDMKey(oPlayer) || VerifyAdminKey(oPlayer) || (oPlayer == oGetInfoFrom) || (!GetLocalInt(oGetInfoFrom, "FKY_CHAT_ANON"))) sMessage += COLOR_PURPLE+NFO5+COLOR_END+sClasses+NEWLINE;
if (VerifyDMKey(oPlayer) || VerifyAdminKey(oPlayer) || (oPlayer == oGetInfoFrom) || (!GetLocalInt(oGetInfoFrom, "FKY_CHAT_ANON"))) sMessage += COLOR_PURPLE+NFO6+COLOR_END+COLOR_YELLOW+IntToString(nXP)+COLOR_END+NEWLINE;
if (VerifyDMKey(oPlayer) || VerifyAdminKey(oPlayer) || (oPlayer == oGetInfoFrom) || (!GetLocalInt(oGetInfoFrom, "FKY_CHAT_ANON"))) sMessage += COLOR_PURPLE+NFO7+COLOR_END+COLOR_RED+IntToString(nXPForNextLevel)+COLOR_END+NEWLINE;
if (VerifyDMKey(oPlayer) || VerifyAdminKey(oPlayer) || (oPlayer == oGetInfoFrom) || (!GetLocalInt(oGetInfoFrom, "FKY_CHAT_ANON"))) sMessage += COLOR_PURPLE+NFO8+COLOR_END+COLOR_GREEN+sArea+COLOR_END+NEWLINE;
if (VerifyDMKey(oPlayer) || VerifyAdminKey(oPlayer) || (oPlayer == oGetInfoFrom) || (!GetLocalInt(oGetInfoFrom, "FKY_CHAT_ANON"))) sMessage += COLOR_PURPLE+NFO9+COLOR_END+sFactionMembers;
if (VerifyDMKey(oPlayer) || VerifyAdminKey(oPlayer) || (oPlayer == oGetInfoFrom)) sMessage += COLOR_PURPLE+NFO10+COLOR_END+COLOR_LT_BLUE+sDeity+COLOR_END+NEWLINE;
if (VerifyDMKey(oPlayer) || VerifyAdminKey(oPlayer) || (oPlayer == oGetInfoFrom)) sMessage += COLOR_PURPLE+NFO11+COLOR_END+COLOR_LT_BLUE+sSubrace+COLOR_END+NEWLINE;
if (VerifyDMKey(oPlayer) || VerifyAdminKey(oPlayer) || (oPlayer == oGetInfoFrom)) sMessage += COLOR_PURPLE+NFO12+COLOR_END+COLOR_GOLD+IntToString(nGold)+COLOR_END+NEWLINE;
if (VerifyDMKey(oPlayer) || VerifyAdminKey(oPlayer) || (oPlayer == oGetInfoFrom)) sMessage += COLOR_PURPLE+NFO13+COLOR_END+COLOR_GOLD+IntToString(nGoldTotal)+COLOR_END+NEWLINE;
SendMessageToPC(oPlayer, sMessage);
}
|
Also, what exactly do I need to do to add cases? I tried and still failed, but I tried by adding in f in the alphabetical order then making it case 18
Code: |
sNormalCase = GetStringRight(sCText, GetStringLength(sCText) - 1); //preserve caps for setname command
sCText = GetStringLowerCase(sNormalCase); //case insensitive
sSort = GetStringLeft(sCText, 1);
nText = FindSubString("a d f i l m p s u w", sSort);
switch (nText) //0 2 184 6 8 10121416
{
case -1: FloatingTextStringOnCreature(COLOR_RED+BADCOMMAND+COLOR_END, oCPC, FALSE); break;//no match - suppress speech to avoid circumventing shout ban
/*a*/ case 0:
if (sCText == "anon")
{
SetLocalInt(oCPC, "FKY_CHAT_ANON", 1);
SendMessageToPC(oCPC, COLOR_RED+ANON+COLOR_END);
}
break;
/*d*/ case 2:
nText = FindSubString("d4 d6 d8 d10 d12 d20 d100", sCText);
switch (nText) //0 3 6 9 13 17 21
{
case -1: FloatingTextStringOnCreature(COLOR_RED+BADCOMMAND+COLOR_END, oCPC, FALSE); break;//no match - suppress speech to avoid circumventing shout ban
case 0: RollDie(oCPC, 4); break;
case 3: RollDie(oCPC, 6); break;
case 6: RollDie(oCPC, 8); break;
case 9: RollDie(oCPC, 10); break;
case 13: RollDie(oCPC, 12); break;
case 17: RollDie(oCPC, 20); break;
case 21: RollDie(oCPC, 100); break;
}
break;
case 18:
if (sCText == "finger")
{
if ((nCChannel == 4) || (nCChannel == 20))
{
CheckAdmin(oCPC, oCTarget);
}
else FloatingTextStringOnCreature(COLOR_RED+NFO14+COLOR_END, oCPC, FALSE);
}
//end adding admin
|
I'm gonna play with this a bit, will let you know how it turns out |
|
Back to top |
|
|
FunkySwerve
Joined: 02 Jun 2005 Posts: 377
|
Posted: Mon Apr 02, 2007 18:23 Post subject: |
|
|
That's not how FindSubString works. Take a look at the lexicon to understand what it's doing, and the example I gave you above. As you have it there, neither that letter nor any of those after it have the right case number. To fix it remove the f and the space before it and place them at the end as case 18. As for non-system related scripting, your best bet is the bioware forums.
Corrected version of the switch:
Code: | nText = FindSubString("a d i l m p s u w f", sSort);
//0 2 4 6 8 1012141618 |
The numbers under the FindSubString switch just indicated the position of the letter in the string - they are commented out and don't actually do anything other than provide a visual cue. Here, f is in the 18th spot in that string. Try counting up from zero, you'll see (spaces count too).
Funky[/code] |
|
Back to top |
|
|
Skipper Warlock
Joined: 31 Mar 2007 Posts: 10
|
Posted: Mon Apr 02, 2007 20:21 Post subject: |
|
|
O wow, I feel stupid now :/ Thanks again for your help
Ok, I changed that and it still says invalid command :/ I tried PRC and it didn't change my results |
|
Back to top |
|
|
FunkySwerve
Joined: 02 Jun 2005 Posts: 377
|
Posted: Mon Apr 02, 2007 22:44 Post subject: |
|
|
When you are using the PRC compiler to compile, make sure you save the mod BEFORE as well as after you use the compiler, otherwise it'll compile the old versions. LMK If that was the problem. ALSO make sure you have a break after your case, otherwise the next case will fire as well, and the text will be compared, which will always Invalid Command you becuase the strings in that case don't (and could never) match the correct input from another case.
Funky |
|
Back to top |
|
|
Skipper Warlock
Joined: 31 Mar 2007 Posts: 10
|
Posted: Tue Apr 03, 2007 3:56 Post subject: |
|
|
I made sure I was compiling after a save and I do have a break after tha case, here it is
Code: |
/*f*/ break;
case 18:
if (sCText == "finger")
{
if ((nCChannel == 4) || (nCChannel == 20))
{
CheckAdmin(oCPC, oCTarget);
}
else FloatingTextStringOnCreature(COLOR_RED+NFO14+COLOR_END, oCPC, FALSE);
}
//end adding admin
break;
/*i*/ case 4:
|
Thanks again for your help |
|
Back to top |
|
|
Skipper Warlock
Joined: 31 Mar 2007 Posts: 10
|
Posted: Tue Apr 03, 2007 22:33 Post subject: |
|
|
Ok, works now, was a prob with my script. Thanks a ton man |
|
Back to top |
|
|
Skipper Warlock
Joined: 31 Mar 2007 Posts: 10
|
Posted: Wed Apr 04, 2007 5:15 Post subject: |
|
|
wow, I must have the worst luck ever I had the command working, but when I tried to make it only work if they had x item, it quite and I didn't have a backup and now I can't get anything to work at all
double: stupid mistake, all I had to do was build the module. I have the admin system up completely now, with many commands I'm quite pleased with Thanks for all your help |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|