At the moment i have 4 scripts that give me a Error: Too Many Instructions, how can i solve that problem? here is the first one that gives the error (also the one in Comments at the beggining it says something about hc_on_cli_enter" that one gives me TMI error too:
/*----------------------------------------------------------------------------
File : nd_pc_idcheck
Updated : 11.10.2005 (Dray)
Description : Makes sure the player has his unique id item
Used to separate characters with the same user and name
Comments : Called from hc_on_cli_enter
----------------------------------------------------------------------------*/
#include "aps_include"
// Creates the ID card on the player
void nd_CreateIdOnPlayer (object oPlayer);
void main()
{
object oPlayer = OBJECT_SELF;
if (!GetIsObjectValid(oPlayer))
return;
// Make sure the player gets his id papers
if (GetItemPossessedBy(oPlayer,"IdentificationPaper") == OBJECT_INVALID)
nd_CreateIdOnPlayer(oPlayer);
}
void nd_CreateIdOnPlayer (object oPlayer)
{
if (!GetIsObjectValid(oPlayer))
return;
string sUser = GetPCPlayerName(oPlayer);
string sName = GetName(oPlayer);
string sRnd = IntToString(Random(10))+
IntToString(Random(10))+
IntToString(Random(10))+
IntToString(Random(10));
string sTemp = sUser + sName + sRnd;
string sId = GetMD5Hash(sTemp);
if (sId == "")
{
SendMessageToAllDMs("Warning: Failed to create id papers for player :"+sName);
return;
}
object oItem = CreateItemOnObject("identificationpa",oPlayer);
// Store the characters unique id on the item object
SetLocalString(oItem,"ND_PC_ID",sId);
// Make sure the character is saved
ExportSingleCharacter(oPlayer);
}
ERROR TMI Help needed
Débuté par
G0000fy
, juil. 28 2011 08:13
#1
Posté 28 juillet 2011 - 08:13
#2
Posté 28 juillet 2011 - 08:47
check your include resources for a infinite loop.
#3
Posté 28 juillet 2011 - 08:56
string sId = GetMD5Hash(sTemp);
this is causing that, so can you send full definition of this function?
this is causing that, so can you send full definition of this function?
#4
Posté 29 juillet 2011 - 02:32
// Returns a MD5 hash of sString
string GetMD5Hash(string sString)
thats all...not sure what its for..
string GetMD5Hash(string sString)
thats all...not sure what its for..
#5
Posté 29 juillet 2011 - 03:36
that's not all. you must find the function and see what it does. it's either in "aps_include" or in a file that file includes
#6
Posté 29 juillet 2011 - 03:49
Im in aps_include now, found this:
string GetMD5Hash(string sString)
{
string sResult;
// Get rid of possible single quotes
sString = SQLEncodeSpecialChars(sString);
string sQ = "SELECT MD5('"+sString+"')";
string GetMD5Hash(string sString)
{
string sResult;
// Get rid of possible single quotes
sString = SQLEncodeSpecialChars(sString);
string sQ = "SELECT MD5('"+sString+"')";
#7
Posté 29 juillet 2011 - 08:55
continue down into this function: SQLEncodeSpecialChars(sString);
#8
Posté 30 juillet 2011 - 12:03
// (private function) Replace special character ' with ~
string SQLEncodeSpecialChars(string sString);
Further down it says:
// These functions are responsible for transporting the various data types back
// and forth to the database.
void SetPersistentString(object oObject, string sVarName, string sValue, int iExpiration=0, string sTable="pwdata")
{
string sPlayer;
string sTag;
if (GetIsPC(oObject))
{
sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oObject));
sTag = SQLEncodeSpecialChars(GetName(oObject));
}
else
{
sPlayer = "~";
sTag = GetTag(oObject);
}
sVarName = SQLEncodeSpecialChars(sVarName);
sValue = SQLEncodeSpecialChars(sValue);
string sSQL = "SELECT player FROM " + sTable + " WHERE player='" + sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
if (SQLFetch() == SQL_SUCCESS)
{
string SQLEncodeSpecialChars(string sString);
Further down it says:
// These functions are responsible for transporting the various data types back
// and forth to the database.
void SetPersistentString(object oObject, string sVarName, string sValue, int iExpiration=0, string sTable="pwdata")
{
string sPlayer;
string sTag;
if (GetIsPC(oObject))
{
sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oObject));
sTag = SQLEncodeSpecialChars(GetName(oObject));
}
else
{
sPlayer = "~";
sTag = GetTag(oObject);
}
sVarName = SQLEncodeSpecialChars(sVarName);
sValue = SQLEncodeSpecialChars(sValue);
string sSQL = "SELECT player FROM " + sTable + " WHERE player='" + sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
if (SQLFetch() == SQL_SUCCESS)
{
#9
Posté 30 juillet 2011 - 12:05
and conutes with this
// row exists
sSQL = "UPDATE " + sTable + " SET val='" + sValue +
"',expire=" + IntToString(iExpiration) + " WHERE player='"+ sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
}
else
{
// row doesn't exist
sSQL = "INSERT INTO " + sTable + " (player,tag,name,val,expire) VALUES" +
"('" + sPlayer + "','" + sTag + "','" + sVarName + "','" +
sValue + "'," + IntToString(iExpiration) + ")";
SQLExecDirect(sSQL);
}
}
string GetPersistentString(object oObject, string sVarName, string sTable="pwdata")
{
string sPlayer;
string sTag;
if (GetIsPC(oObject))
{
sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oObject));
sTag = SQLEncodeSpecialChars(GetName(oObject));
}
else
{
sPlayer = "~";
sTag = GetTag(oObject);
}
sVarName = SQLEncodeSpecialChars(sVarName);
string sSQL = "SELECT val FROM " + sTable + " WHERE player='" + sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
if (SQLFetch() == SQL_SUCCESS)
return SQLDecodeSpecialChars(SQLGetData(1));
else
{
return "";
// row exists
sSQL = "UPDATE " + sTable + " SET val='" + sValue +
"',expire=" + IntToString(iExpiration) + " WHERE player='"+ sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
}
else
{
// row doesn't exist
sSQL = "INSERT INTO " + sTable + " (player,tag,name,val,expire) VALUES" +
"('" + sPlayer + "','" + sTag + "','" + sVarName + "','" +
sValue + "'," + IntToString(iExpiration) + ")";
SQLExecDirect(sSQL);
}
}
string GetPersistentString(object oObject, string sVarName, string sTable="pwdata")
{
string sPlayer;
string sTag;
if (GetIsPC(oObject))
{
sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oObject));
sTag = SQLEncodeSpecialChars(GetName(oObject));
}
else
{
sPlayer = "~";
sTag = GetTag(oObject);
}
sVarName = SQLEncodeSpecialChars(sVarName);
string sSQL = "SELECT val FROM " + sTable + " WHERE player='" + sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
if (SQLFetch() == SQL_SUCCESS)
return SQLDecodeSpecialChars(SQLGetData(1));
else
{
return "";
#10
Posté 30 juillet 2011 - 02:29
those are not the right functions. you only list the prototype not the function body.
#11
Posté 30 juillet 2011 - 03:52
How about this
}
void SetPersistentInt(object oObject, string sVarName, int iValue, int iExpiration=0, string sTable="pwdata")
{
SetPersistentString(oObject, sVarName, IntToString(iValue), iExpiration, sTable);
}
int GetPersistentInt(object oObject, string sVarName, string sTable="pwdata")
{
return StringToInt(GetPersistentString(oObject, sVarName, sTable));
}
void SetPersistentFloat(object oObject, string sVarName, float fValue, int iExpiration=0, string sTable="pwdata")
{
SetPersistentString(oObject, sVarName, FloatToString(fValue), iExpiration, sTable);
}
float GetPersistentFloat(object oObject, string sVarName, string sTable="pwdata")
{
return StringToFloat(GetPersistentString(oObject, sVarName, sTable));
}
void SetPersistentLocation(object oObject, string sVarName, location lLocation, int iExpiration=0, string sTable="pwdata")
{
SetPersistentString(oObject, sVarName, LocationToString(lLocation), iExpiration, sTable);
}
location GetPersistentLocation(object oObject, string sVarName, string sTable="pwdata")
{
return StringToLocation(GetPersistentString(oObject, sVarName, sTable));
}
void SetPersistentVector(object oObject, string sVarName, vector vVector, int iExpiration=0, string sTable ="pwdata")
{
SetPersistentString(oObject, sVarName, VectorToString(vVector), iExpiration, sTable);
}
vector GetPersistentVector(object oObject, string sVarName, string sTable = "pwdata")
{
return StringToVector(GetPersistentString(oObject, sVarName, sTable));
}
void DeletePersistentVariable(object oObject, string sVarName, string sTable="pwdata")
{
string sPlayer;
string sTag;
if (GetIsPC(oObject))
{
sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oObject));
sTag = SQLEncodeSpecialChars(GetName(oObject));
}
else
{
sPlayer = "~";
sTag = GetTag(oObject);
}
sVarName = SQLEncodeSpecialChars(sVarName);
string sSQL = "DELETE FROM " + sTable + " WHERE player='" + sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
}
// Problems can arise with SQL commands if variables or values have single quotes
// in their names. These functions are a replace these quote with the tilde character
string SQLEncodeSpecialChars(string sString)
{
if (FindSubString(sString, "'") == -1) // not found
return sString;
int i;
string sReturn = "";
string sChar;
// Loop over every character and replace special characters
for (i = 0; i < GetStringLength(sString); i++)
{
sChar = GetSubString(sString, i, 1);
if (sChar == "'")
sReturn += "~";
else
sReturn += sChar;
}
return sReturn;
}
string SQLDecodeSpecialChars(string sString)
{
if (FindSubString(sString, "~") == -1) // not found
return sString;
int i;
string sReturn = "";
string sChar;
// Loop over every character and replace special characters
for (i = 0; i < GetStringLength(sString); i++)
{
sChar = GetSubString(sString, i, 1);
if (sChar == "~")
sReturn += "'";
else
sReturn += sChar;
}
return sReturn;
}
}
void SetPersistentInt(object oObject, string sVarName, int iValue, int iExpiration=0, string sTable="pwdata")
{
SetPersistentString(oObject, sVarName, IntToString(iValue), iExpiration, sTable);
}
int GetPersistentInt(object oObject, string sVarName, string sTable="pwdata")
{
return StringToInt(GetPersistentString(oObject, sVarName, sTable));
}
void SetPersistentFloat(object oObject, string sVarName, float fValue, int iExpiration=0, string sTable="pwdata")
{
SetPersistentString(oObject, sVarName, FloatToString(fValue), iExpiration, sTable);
}
float GetPersistentFloat(object oObject, string sVarName, string sTable="pwdata")
{
return StringToFloat(GetPersistentString(oObject, sVarName, sTable));
}
void SetPersistentLocation(object oObject, string sVarName, location lLocation, int iExpiration=0, string sTable="pwdata")
{
SetPersistentString(oObject, sVarName, LocationToString(lLocation), iExpiration, sTable);
}
location GetPersistentLocation(object oObject, string sVarName, string sTable="pwdata")
{
return StringToLocation(GetPersistentString(oObject, sVarName, sTable));
}
void SetPersistentVector(object oObject, string sVarName, vector vVector, int iExpiration=0, string sTable ="pwdata")
{
SetPersistentString(oObject, sVarName, VectorToString(vVector), iExpiration, sTable);
}
vector GetPersistentVector(object oObject, string sVarName, string sTable = "pwdata")
{
return StringToVector(GetPersistentString(oObject, sVarName, sTable));
}
void DeletePersistentVariable(object oObject, string sVarName, string sTable="pwdata")
{
string sPlayer;
string sTag;
if (GetIsPC(oObject))
{
sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oObject));
sTag = SQLEncodeSpecialChars(GetName(oObject));
}
else
{
sPlayer = "~";
sTag = GetTag(oObject);
}
sVarName = SQLEncodeSpecialChars(sVarName);
string sSQL = "DELETE FROM " + sTable + " WHERE player='" + sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
}
// Problems can arise with SQL commands if variables or values have single quotes
// in their names. These functions are a replace these quote with the tilde character
string SQLEncodeSpecialChars(string sString)
{
if (FindSubString(sString, "'") == -1) // not found
return sString;
int i;
string sReturn = "";
string sChar;
// Loop over every character and replace special characters
for (i = 0; i < GetStringLength(sString); i++)
{
sChar = GetSubString(sString, i, 1);
if (sChar == "'")
sReturn += "~";
else
sReturn += sChar;
}
return sReturn;
}
string SQLDecodeSpecialChars(string sString)
{
if (FindSubString(sString, "~") == -1) // not found
return sString;
int i;
string sReturn = "";
string sChar;
// Loop over every character and replace special characters
for (i = 0; i < GetStringLength(sString); i++)
{
sChar = GetSubString(sString, i, 1);
if (sChar == "~")
sReturn += "'";
else
sReturn += sChar;
}
return sReturn;
}
#12
Posté 30 juillet 2011 - 06:50
the loop is inefficent but you shouldn't hit TMI with it. there is faster ways of replace a ~ with a ' in string repeated use of FindSubString.and you will cut up the string faster. unless the string has a majority of special chars in that case this will be faster. Which is a unlikley scenerio.
#13
Posté 01 août 2011 - 07:48
ok so i should try to replace all these in the strings: ~ inte these '?
for example it should be like this: sChar = GetSubString(sString, i, 1);
if (sChar == "'")
instead of sChar = GetSubString(sString, i, 1);
if (sChar == "~")
?
for example it should be like this: sChar = GetSubString(sString, i, 1);
if (sChar == "'")
instead of sChar = GetSubString(sString, i, 1);
if (sChar == "~")
?
#14
Posté 01 août 2011 - 03:31
No there is nothing wrong with the script it's a bit inefficent in design. It should work and unless you knwo what your doing it's better to leave it as it is.
#15
Posté 03 août 2011 - 12:25
If the script looks ok, how then do i get the TMI Error...dont get that one..
#16
Posté 03 août 2011 - 01:35
I went through the functions again and you didn't post the end of "GetMD5Hash" there must be more to it then the MD5 loop. it's just not big enough to cause TMI. You would need a hugh string for it.
a faster loop would look like this:
string SQLEncodeSpecialChars(string sString)
{
int i, len;
string sReturn = "";
string sRemains = sString;
int nPos = FindSubString(sString, "~");
while(nPos != -1)
{
sReturn += GetStringLeft(sRemains,nPos);
sReturn += "'";
len = GetStringLength(sRemains);
sRemains = GetStringRight(sRemains,len - nPos - 1);
nPos = FindSubString(sRemains, "~");
}
sReturn += sRemains;
return sReturn;
}
I haven't tested it but it should work. you do a simialr loop for decode.
a faster loop would look like this:
string SQLEncodeSpecialChars(string sString)
{
int i, len;
string sReturn = "";
string sRemains = sString;
int nPos = FindSubString(sString, "~");
while(nPos != -1)
{
sReturn += GetStringLeft(sRemains,nPos);
sReturn += "'";
len = GetStringLength(sRemains);
sRemains = GetStringRight(sRemains,len - nPos - 1);
nPos = FindSubString(sRemains, "~");
}
sReturn += sRemains;
return sReturn;
}
I haven't tested it but it should work. you do a simialr loop for decode.
#17
Posté 04 août 2011 - 02:45
Are you running NWNX2 correctly with the MySQL / SQLite database? I've run into TMI errors when I accidentally run my module in single player mode (I.E: Without NWNX2 running)
If you haven't changed anything in aps_include I'd check on your installation of NWNX2 because that code is just fine.
If you haven't changed anything in aps_include I'd check on your installation of NWNX2 because that code is just fine.
#18
Posté 05 août 2011 - 03:27
ive tried running the server both with and without NWNX2 but same errors either way. Ill look into that..
And CID, I should try testing your script that u posted, shall i just delete the old "string" and replace it with that then?
And CID, I should try testing your script that u posted, shall i just delete the old "string" and replace it with that then?
#19
Posté 05 août 2011 - 03:37
It'd help if you posted your NWNX2.ini file. Make sure you delete any confidential information such as your database password though. It's possible there's a setting that's messed up in there.
Which database are you using? MySQL, SQLite, or something else?
Which database are you using? MySQL, SQLite, or something else?
#20
Posté 05 août 2011 - 03:54
MySQL i think, but cant find the .ini file:S
#21
Posté 05 août 2011 - 04:05
It's in your NWN directory. If it's not there, that might be the cause of your issues.
This is an example of mine:
This is an example of mine:
; NWNX2 configuration file ; These are the default values for NWNX2. Values specified on the command ; line take precedence. [NWNX] ServerPort = 5124 ModuleName = "MyModule" WatchdogProcess = yes UpdateIntervalProcess = 5 WatchdogGamespy = no UpdateIntervalGamespy = 20 GamespyRetries = 5 OldGamespyProtocol = no RestartDelay = 5 [ODBC2] ; Log file MaxLogSize = 512 ; in KByte LogLevel = 2 ; 0=nothing, 1=only errors, 2=everything ; Use these two settings for the SQLite internal database ;source = sqlite ;file = sqlite.db ; Use these two settings for ODBC connections ;source = odbc ;dsn = nwn ; Use these five settings for MySQL connections source = mysql server = localhost user = root pwd = nwn db = nwn ; Set hookscorco to false if you want to disable hooking of ; StoreCampaignObject and RetrieveCampaignObject entirely hookscorco = true [PROFILER] MaxLogSize = 512 ; in KByte LogLevel = 1 ; 1=overall statistics, 2=full script callstack [CHAT] chat_script=fky_chat server_script=fky_chat_srv [FIXES] copy_vars = 1 # Copy local variables on stack split and on store transaction, # fire OnDisturbed when you merge a stack from a placeable compare_vars = 1 # If set to 1, items with different local vars don't stack keep_hidden_in_conversation = 0 # If set to 1, creatures don't unhide when they start a conversation hp_limit = -10 # Negative HP limit - values up to -127 are allowed hide_charlist_levels = 1 hide_charlist_dms = 1 hide_charlist_portraits = 0 [FUNCS] Last_Skill_Number=28 #Last_Skill_Number is the id of the last skill in skills.2da debugLevel=1 #debugLevel: 1 should only show basic information, 2 should include errors and 3 should log pretty much everything HOOK_CustomTrapGeometry=1 ;Hook for a new OnPlayerLeave event which runs before OnClientLeave ;Makes it possible to retrieve information about the player object as usual (GetName, GetArea, etc) ;In the onplayerleaving script, OBJECT_SELF is the player object about to leave HOOK_OnPlayerLeaving=1 OnPlayerLeavingScript=mod_on_leaving [EVENTS] event_script=nwnx_events log=1 DownloadCharacter=1 PickPocket=1 Attack=1 ExamineItem=1 ExamineCreature=1 ExaminePlaceable=1 ExamineDoor=1 ToggleMode=1 StealthMode=1 DevastatingCritical=0 UnPolymorph=0 TrapTrigger=0 EndDialog=0 RemoveSanctuary=0 [TMI] Limitlevel=4 Unlimited=0
#22
Posté 05 août 2011 - 04:07
Ah here it is:
; NWNX2 configuration file
; These are the default values for NWNX2. Values specified on the command
; line take precedence.
[NWNX]
ServerPort = 5121
ModuleName = "Epic_Nordock_V2036_RC1"
WatchdogProcess = yes
UpdateIntervalProcess = 5
WatchdogGamespy = yes
UpdateIntervalGamespy = 20
GamespyRetries = 5
OldGamespyProtocol = no
RestartDelay = 5
[ODBC2]
; Log file
MaxLogSize = 512 ; in KByte
LogLevel = 2 ; 0=nothing, 1=only errors, 2=everything
; Use these two settings for the SQLite internal database
source = sqlite
file = sqlite.db
; Use these two settings for ODBC connections
;source = odbc
;dsn = nwn
; Use these five settings for MySQL connections
;source = mysql
;server = localhost
;user = nwn
;pwd = nwn
;db = nwn
; Set hookscorco to false if you want to disable hooking of
; StoreCampaignObject and RetrieveCampaignObject entirely
hookscorco = true
[PROFILER]
MaxLogSize = 512 ; in KByte
LogLevel = 1 ; 1=overall statistics, 2=full script callstack
[TMI]
Unlimited=0
Limitlevel=8
; NWNX2 configuration file
; These are the default values for NWNX2. Values specified on the command
; line take precedence.
[NWNX]
ServerPort = 5121
ModuleName = "Epic_Nordock_V2036_RC1"
WatchdogProcess = yes
UpdateIntervalProcess = 5
WatchdogGamespy = yes
UpdateIntervalGamespy = 20
GamespyRetries = 5
OldGamespyProtocol = no
RestartDelay = 5
[ODBC2]
; Log file
MaxLogSize = 512 ; in KByte
LogLevel = 2 ; 0=nothing, 1=only errors, 2=everything
; Use these two settings for the SQLite internal database
source = sqlite
file = sqlite.db
; Use these two settings for ODBC connections
;source = odbc
;dsn = nwn
; Use these five settings for MySQL connections
;source = mysql
;server = localhost
;user = nwn
;pwd = nwn
;db = nwn
; Set hookscorco to false if you want to disable hooking of
; StoreCampaignObject and RetrieveCampaignObject entirely
hookscorco = true
[PROFILER]
MaxLogSize = 512 ; in KByte
LogLevel = 1 ; 1=overall statistics, 2=full script callstack
[TMI]
Unlimited=0
Limitlevel=8
#23
Posté 05 août 2011 - 04:15
Ok, you're set up for SQLite. But that shouldn't cause the TMI error. It looks like it's set up correctly.
Nevermind me then! It's probably something else
Nevermind me then! It's probably something else
#24
Posté 05 août 2011 - 04:22
Darn
#25
Posté 05 août 2011 - 04:23
How do i change to MySQL instead? can try if that works





Retour en haut






