Archives des forums MMO/MMORPG > Neverwinter Nights > NWN - Maskado > [SCRIPT] pwum_functions et pwum_flags v0.02
[SCRIPT] pwum_functions et pwum_flags v0.02
Par RAT le 16/1/2003 à 23:54:09 (#3038596)
pwum_functions:
// ******************************************** //
// FUNCTION DECLARATIONS
// ******************************************** //
// Stores current locations for all PCs set to
// save location (default=save, change with
// SetPCToNotSaveLocation())
// fTimercount indicates how many seconds to delay
// before firing again.
// 0.0 = one time shot.
void PWUMLocationTimer(float fTimerCount=0.0);
// Stores current game date.
// fTimercount indicates how many seconds to delay
// before firing again.
// 0.0 = one time shot.
void PWUMDateTimer(float fTimerCount=0.0);
// Returns number of days from 0/0/0
// iOffset = how many days to add to "today"
// (i.e. 0=today, 1=tomorrow, 7=next week)
int GetOffsetGameDate(int iOffset=0);
// Stores Integer in log (for future sessions)
// var_name = name of variable
// var_val = integer value to store
// iExpire = how many days from now this variable should
// be removed from the system.
// iToken sets whether or not this variable's expiration
// date should update every time it is used (0=yes, 1=no)
// iExtend indicates how many days this variable should
// be updated if it is to be updated.
void SetPWUMInt(string var_name, int var_val, int iExpire=121000000, int iToken=0, int iExtend=0);
// Stores String in log (for future sessions)
// var_name = name of variable
// var_val = string value to store
// iExpire = how many days from now this variable should
// be removed from the system.
// iToken sets whether or not this variable's expiration
// date should update every time it is used (0=yes, 1=no)
// iExtend indicates how many days this variable should
// be updated if it is to be updated.
void SetPWUMString(string var_name, string var_val, int iExpire=121000000, int iToken=0, int iExtend=0);
// Stores Float in log (for future sessions)
// var_name = name of variable
// var_val = float value to store
// iExpire = how many days from now this variable should
// be removed from the system.
// iToken sets whether or not this variable's expiration
// date should update every time it is used (0=yes, 1=no)
// iExtend indicates how many days this variable should
// be updated if it is to be updated.
void SetPWUMFloat(string var_name, float var_val, int iExpire=121000000, int iToken=0, int iExtend=0);
// Stores Location in log (for future sessions)
// var_name = name of variable
// Uses area tag, three-float for vector, and float for facing
// iExpire = how many days from now this variable should
// be removed from the system.
// iToken sets whether or not this variable's expiration
// date should update every time it is used (0=yes, 1=no)
// iExtend indicates how many days this variable should
// be updated if it is to be updated.
void SetPWUMLocationA(string var_name, string area_tag, float vector_x, float vector_y, float vector_z, float loc_orientation, int iExpire=121000000, int iToken=0, int iExtend=0);
// Stores Location in log (for future sessions)
// Uses area tag, vector, and float for facing
// var_name = name of variable
// iExpire = how many days from now this variable should
// be removed from the system.
// iToken sets whether or not this variable's expiration
// date should update every time it is used (0=yes, 1=no)
// iExtend indicates how many days this variable should
// be updated if it is to be updated.
void SetPWUMLocationB(string var_name, string area_tag, vector the_vector, float loc_orientation, int iExpire=121000000, int iToken=0, int iExtend=0);
// Stores Integer in log (for future sessions)
// var_name = name of variable
// var_val = location value to store
// iExpire = how many days from now this variable should
// be removed from the system.
// iToken sets whether or not this variable's expiration
// date should update every time it is used (0=yes, 1=no)
// iExtend indicates how many days this variable should
// be updated if it is to be updated.
void SetPWUMLocationC(string var_name, location the_loc, int iExpire=121000000, int iToken=0, int iExtend=0);
// Sets the game date to the value of iOffsetDate (provided
// iOffsetDate is greater than the "current" date). This
// is NOT "days from today" but a converted date using
// GetOffsetGameDate();
void SetPWUMCalendar(int iOffsetDate);
// Delete Integer from game and log (will not re-appear
// next gaming session)
void DeletePWUMInt(string var_name);
// Delete String from game and log (will not re-appear
// next gaming session)
void DeletePWUMString(string var_name);
// Delete Float from game and log (will not re-appear
// next gaming session)
void DeletePWUMFloat(string var_name);
// Delete Location from game and log (will not re-appear
// next gaming session)
void DeletePWUMLocation(string var_name);
// Retrieve Integer saved by the system.
int GetPWUMInt(string var_name);
// Retrieve String saved by the system.
string GetPWUMString(string var_name);
// Retrieve Float saved by the system.
float GetPWUMFloat(string var_name);
// Retrieve Location saved by the system.
location GetPWUMLocation(string var_name);
// Sends a PC to their last saved location
void ResumePCLocation(object oPC);
// Sets a PC to save their location during
// PWUMLocationTimer() calls. (This is the
// default state)
void SetPCToSaveLocation(object oPC);
// Sets a PC to be skipped during calls to
// save PC locations with PWUMLocationTimer().
void SetPCToNotSaveLocation(object oPC);
//fonction replace
string StrReplace(string s1, string s2, string s3);
//*************************
// Appel des nouvelles fonctions
//************************
//LES SET
void SetBanqueOr(string var_name, int var_val, int iExpire=121000000, int iToken=0, int iExtend=0);
void SetBanqueInv(string var_name, string var_val, int iExpire=121000000, int iToken=0, int iExtend=0);
//LES GET
int GetBanqueOr(string var_name);
string GetBanqueInv(string var_name);
// GESTION DES DELETE
void DeleteBanqueOr(string var_name);
void DeleteBanqueInv(string var_name);
// ******************************************** //
// UTILITIES (used by functions below)
// ******************************************** //
string StrReplace(string s1, string s2, string s3)
{
int nTemp;
int nL = GetStringLength(s3);
int nLength = GetStringLength(s1);
string sTemp;
string sR = ";
while ((nTemp = FindSubString(s3, s1)) >= 0)
{
sTemp = GetStringLeft(s3, nTemp);
s3 = GetStringRight(s3, nL - nLength - nTemp);
sR = sR + sTemp + s2;
nL = GetStringLength(s3);
}
sR+=s3;
return sR;
}
void PWUMLocationTimer(float fTimerCount=0.0)
{
object oPC = GetFirstPC();
string sPCLocation;
// Loop through each PC
while (GetIsPC(oPC))
{
// If PC is currently setup to save location
if (GetLocalInt(oPC, "nSaveStatus") == 0)
{
// store the PC location
sPCLocation = GetPCPlayerName(oPC) + GetName(oPC) + "CurrentLocation";
SetPWUMLocationC(sPCLocation, GetLocation(oPC));
SendMessageToPC(oPC, "** Votre position a ete sauvegarde **");
}
oPC = GetNextPC();
}
/* If this is not a one-shot call,
recall this script after the directed delay */
if (fTimerCount > 0.0)
DelayCommand(fTimerCount, PWUMLocationTimer(fTimerCount));
}
void PWUMDateTimer(float fTimerCount=0.0)
{
SetPWUMInt("iPWUMDate", GetOffsetGameDate());
/* If this is not a one-shot call,
recall this script after the directed delay */
if (fTimerCount > 0.0)
DelayCommand(fTimerCount, PWUMDateTimer(fTimerCount));
}
int GetOffsetGameDate(int iOffset=0)
{
/* If a negative number was given then
this variable does not automatically expire. */
if (iOffset 335)
{
iYear++;
iOffset -= 336;
}
while (iOffset > 27)
{
iMonth++;
iOffset -= 28;
}
while (iOffset > 0)
{
iDay++;
iOffset--;
}
/* Now, if we have more than 28 days, roll the
month, and if we have more than 12 months,
roll the year - due to the way the year, month,
and days were added above, it should be impossible
to have more than 24 months or 56 days. */
if (iDay > 28)
{
iDay -= 28;
iMonth++;
}
if (iMonth > 12)
{
iMonth -= 12;
iYear++;
}
return iYear*336 + iMonth*28 + iDay;
}
}
// ******************************************** //
// SET (WRITE) FUNCTIONS
// ******************************************** //
void SetPWUMInt(string var_name, int var_val, int iExpire=121000000, int iToken=0, int iExtend=0)
{
object umObject = GetLocalObject(GetModule(), "um_object");
int iDate=GetOffsetGameDate(0);
/* If this is a first-time assignment, set the date
and change the token to indicate (for the log) that
this variable has already been assigned */
if (iToken < 2 && iExpire < 121000000)
{
if (iExpire < 121000000)
iExpire=GetOffsetGameDate(iExpire);
else
iExpire=GetLocalInt(umObject, "iDefaultExpire");
iToken=iToken+2;
}
/* Only set the variable if the expiration date has
not come and gone. Otherwise skip this entirely.
This will clean out the variables coming in from
the log (and if the call sends a negative number
of days to expire). */
if (iDate < iExpire)
{
string storageBuffer = "INT#" + var_name + "#" + IntToString(var_val) + "#" + IntToString(iExpire) + "#" + IntToString(iToken) + "#" + IntToString(iExtend) + "#";
SetLocalInt(umObject, var_name, var_val);
SetLocalInt(umObject, var_name + "x", iExpire);
if (iToken==2)
SetLocalInt(umObject, var_name + "t", iExtend);
WriteTimestampedLogEntry(storageBuffer);
}
}
void SetPWUMString(string var_name, string var_val, int iExpire=121000000, int iToken=0, int iExtend=0)
{
var_val=StrReplace("\n","°°",var_val);
object umObject = GetLocalObject(GetModule(), "um_object");
int iDate=GetOffsetGameDate(0);
if (iToken < 2 && iExpire < 121000000)
{
if (iExpire < 121000000)
iExpire=GetOffsetGameDate(iExpire);
else
iExpire=GetLocalInt(umObject, "iDefaultExpire");
iToken=iToken+2;
}
/* Only set the variable if the expiration date has
not come and gone. Otherwise skip this entirely.
This will clean out the variables coming in from
the log (and if the call sends a negative number
of days to expire). */
if (iDate < iExpire)
{
string storageBuffer = "STR#" + var_name + "#" + var_val + "#" + IntToString(iExpire) + "#" + IntToString(iToken) + "#" + IntToString(iExtend) + "#";
SetLocalString(umObject, var_name, var_val);
SetLocalInt(umObject, var_name + "x", iExpire);
if (iToken==2)
SetLocalInt(umObject, var_name + "t", iExtend);
WriteTimestampedLogEntry(storageBuffer);
}
}
void SetPWUMFloat(string var_name, float var_val, int iExpire=121000000, int iToken=0, int iExtend=0)
{
object umObject = GetLocalObject(GetModule(), "um_object");
int iDate=GetOffsetGameDate(0);
if (iToken < 2 && iExpire < 121000000)
{
if (iExpire < 121000000)
iExpire=GetOffsetGameDate(iExpire);
else
iExpire=GetLocalInt(umObject, "iDefaultExpire");
iToken=iToken+2;
}
/* Only set the variable if the expiration date has
not come and gone. Otherwise skip this entirely.
This will clean out the variables coming in from
the log (and if the call sends a negative number
of days to expire). */
if (iDate < iExpire)
{
string storageBuffer = "FLT#" + var_name + "#" + FloatToString(var_val) + "#" + IntToString(iExpire) + "#" + IntToString(iToken) + "#" + IntToString(iExtend) + "#";
SetLocalFloat(umObject, var_name, var_val);
SetLocalInt(umObject, var_name + "x", iExpire);
if (iToken==2)
SetLocalInt(umObject, var_name + "t", iExtend);
WriteTimestampedLogEntry(storageBuffer);
}
}
void SetPWUMLocationA(string var_name, string area_tag, float vector_x, float vector_y, float vector_z, float loc_orientation, int iExpire=121000000, int iToken=0, int iExtend=0)
{
object umObject = GetLocalObject(GetModule(), "um_object");
vector storageVector = Vector(vector_x, vector_y, vector_z);
location storageLoc = Location(GetObjectByTag(area_tag), storageVector, loc_orientation);
int iDate=GetOffsetGameDate(0);
if (iToken < 2 && iExpire < 121000000)
{
if (iExpire < 121000000)
iExpire=GetOffsetGameDate(iExpire);
else
iExpire=GetLocalInt(umObject, "iDefaultExpire");
iToken=iToken+2;
}
/* Only set the variable if the expiration date has
not come and gone. Otherwise skip this entirely.
This will clean out the variables coming in from
the log (and if the call sends a negative number
of days to expire). */
if (iDate < iExpire)
{
string storageBuffer = "LOC#" + var_name + "#" + area_tag + "*" + FloatToString(vector_x) + "*" + FloatToString(vector_y) + "*" + FloatToString(vector_z) + "*" + FloatToString(loc_orientation) + "*#" + IntToString(iExpire) + "#" + IntToString(iToken) + "#" + IntToString(iExtend) + "#";
SetLocalLocation(umObject, var_name, storageLoc);
SetLocalInt(umObject, var_name + "x", iExpire);
if (iToken==2)
SetLocalInt(umObject, var_name + "t", iExtend);
WriteTimestampedLogEntry(storageBuffer);
}
}
void SetPWUMLocationB(string var_name, string area_tag, vector the_vector, float loc_orientation, int iExpire=121000000, int iToken=0, int iExtend=0)
{
object umObject = GetLocalObject(GetModule(), "um_object");
location storageLoc = Location(GetObjectByTag(area_tag), the_vector, loc_orientation);
int iDate=GetOffsetGameDate(0);
if (iToken < 2 && iExpire < 121000000)
{
if (iExpire < 121000000)
iExpire=GetOffsetGameDate(iExpire);
else
iExpire=GetLocalInt(umObject, "iDefaultExpire");
iToken=iToken+2;
}
/* Only set the variable if the expiration date has
not come and gone. Otherwise skip this entirely.
This will clean out the variables coming in from
the log (and if the call sends a negative number
of days to expire). */
if (iDate < iExpire)
{
string storageBuffer = "LOC#" + var_name + "#" + area_tag + "*" + FloatToString(the_vector.x) + "*" + FloatToString(the_vector.y) + "*" + FloatToString(the_vector.z) + "*" + FloatToString(loc_orientation) + "*#" + IntToString(iExpire) + "#" + IntToString(iToken) + "#" + IntToString(iExtend) + "#";
SetLocalLocation(umObject, var_name, storageLoc);
SetLocalInt(umObject, var_name + "x", iExpire);
if (iToken==2)
SetLocalInt(umObject, var_name + "t", iExtend);
WriteTimestampedLogEntry(storageBuffer);
}
}
void SetPWUMLocationC(string var_name, location the_loc, int iExpire=121000000, int iToken=0, int iExtend=0)
{
object umObject = GetLocalObject(GetModule(), "um_object");
string storageAreaTag = GetTag(GetAreaFromLocation(the_loc));
vector storageVector = GetPositionFromLocation(the_loc);
float storageFacing = GetFacingFromLocation(the_loc);
int iDate=GetOffsetGameDate(0);
if (iToken < 2 && iExpire < 121000000)
{
if (iExpire < 121000000)
iExpire=GetOffsetGameDate(iExpire);
else
iExpire=GetLocalInt(umObject, "iDefaultExpire");
iToken=iToken+2;
}
/* Only set the variable if the expiration date has
not come and gone. Otherwise skip this entirely.
This will clean out the variables coming in from
the log (and if the call sends a negative number
of days to expire). */
if (iDate < iExpire)
{
string storageBuffer = "LOC#" + var_name + "#" + storageAreaTag + "*" + FloatToString(storageVector.x) + "*" + FloatToString(storageVector.y) + "*" + FloatToString(storageVector.z) + "*" + FloatToString(storageFacing) + "*#" + IntToString(iExpire) + "#" + IntToString(iToken) + "#" + IntToString(iExtend) + "#";
SetLocalLocation(umObject, var_name, the_loc);
SetLocalInt(umObject, var_name + "x", iExpire);
if (iToken==2)
SetLocalInt(umObject, var_name + "t", iExtend);
WriteTimestampedLogEntry(storageBuffer);
}
}
void SetPWUMCalendar(int iOffsetDate)
{
int iToday=GetOffsetGameDate(0);
/* Only set the date if the saved date is after
the start of the module. */
if (iOffsetDate > iToday)
{
// Get "zero" date
int iYear=0;
int iMonth=0;
int iDay=0;
// Add to the appropriate integer until iOffset == 0
while (iOffsetDate > 335)
{
iYear++;
iOffsetDate -= 336;
}
while (iOffsetDate > 27)
{
iMonth++;
iOffsetDate -= 28;
}
while (iOffsetDate > 1)
{
iDay++;
iOffsetDate--;
}
/* Now, if we have more than 28 days, roll the
month, and if we have more than 12 months,
roll the year - due to the way the year, month,
and days were added above, it should be impossible
to have more than 24 months or 56 days. */
if (iDay > 28)
{
iDay -= 28;
iMonth++;
}
if (iMonth > 12)
{
iMonth -= 12;
iYear++;
}
SetCalendar(iYear, iMonth, iDay);
}
}
// ******************************************** //
// DELETE (REMOVE) FUNCTIONS
// ******************************************** //
void DeletePWUMInt(string var_name)
{
object umObject = GetLocalObject(GetModule(), "um_object");
DeleteLocalInt(umObject, var_name);
DeleteLocalInt(umObject, var_name + "x");
DeleteLocalInt(umObject, var_name + "t");
WriteTimestampedLogEntry("DIN#" + var_name + "#");
//WriteTimestampedLogEntry("INT#" + var_name + "#");
}
void DeletePWUMString(string var_name)
{
object umObject = GetLocalObject(GetModule(), "um_object");
DeleteLocalString(umObject, var_name);
DeleteLocalInt(umObject, var_name + "x");
DeleteLocalInt(umObject, var_name + "t");
WriteTimestampedLogEntry("DST#" + var_name + "#");
}
void DeletePWUMFloat(string var_name)
{
object umObject = GetLocalObject(GetModule(), "um_object");
DeleteLocalFloat(umObject, var_name);
DeleteLocalInt(umObject, var_name + "x");
DeleteLocalInt(umObject, var_name + "t");
WriteTimestampedLogEntry("DFL#" + var_name + "#");
}
void DeletePWUMLocation(string var_name)
{
object umObject = GetLocalObject(GetModule(), "um_object");
DeleteLocalLocation(umObject, var_name);
DeleteLocalInt(umObject, var_name + "x");
DeleteLocalInt(umObject, var_name + "t");
WriteTimestampedLogEntry("DLO#" + var_name + "#");
}
// ******************************************** //
// GET (READ) FUNCTIONS
// ******************************************** //
int GetPWUMInt(string var_name)
{
int retVal;
object umObject = GetLocalObject(GetModule(), "um_object");
int iExpire=GetLocalInt(umObject, var_name + "x");
int iDate=GetOffsetGameDate(0);
/* This statement checks to see if the variable
has expired. If so, delete it and return
zero (NWN returns zero on all invalid Int
functions) */
if (iExpire > 0 && iExpire 0)
SetPWUMInt(var_name, retVal, GetOffsetGameDate(iExtend), 2, iExtend);
return(retVal);
}
string GetPWUMString(string var_name)
{
string retVal;
object umObject = GetLocalObject(GetModule(), "um_object");
int iExpire=GetLocalInt(umObject, var_name + "x");
int iDate=GetOffsetGameDate(0);
/* This statement checks to see if the variable
has expired. If so, delete it and return
" (NWN returns " on all invalid String
functions) */
if (iExpire > 0 && iExpire 0)
SetPWUMString(var_name, retVal, GetOffsetGameDate(iExtend), 2, iExtend);
retVal=StrReplace("°°","\n",retVal);
return(retVal);
}
float GetPWUMFloat(string var_name)
{
float retVal;
object umObject = GetLocalObject(GetModule(), "um_object");
int iExpire=GetLocalInt(umObject, var_name + "x");
int iDate=GetOffsetGameDate(0);
/* This statement checks to see if the variable
has expired. If so, delete it and return
0.0 */
if (iExpire > 0 && iExpire 0)
SetPWUMFloat(var_name, retVal, GetOffsetGameDate(iExtend), 2, iExtend);
return(retVal);
}
location GetPWUMLocation(string var_name)
{
location retVal;
object umObject = GetLocalObject(GetModule(), "um_object");
int iExpire=GetLocalInt(umObject, var_name + "x");
int iDate=GetOffsetGameDate(0);
/* This statement checks to see if the variable
has expired. If so, delete it (Not sure what
NWN returns on invalid Location functions) */
if (iExpire > 0 && iExpire 0)
SetPWUMLocationC(var_name, retVal, GetOffsetGameDate(iExtend), 2, iExtend);
return(retVal);
}
// ******************************************** //
// PC LOCATION FUNCTIONS
// ******************************************** //
void ResumePCLocation(object oPC)
{
if (!GetIsPC(oPC))
{
return; //buh-bye
}
AssignCommand(oPC, ActionWait(2.0)); //2.0 is long enough to account for most network lag
// effects can be added to go with this:
string sPCLocation = GetPCPlayerName(oPC) + GetName(oPC) + "CurrentLocation";
AssignCommand(oPC, ActionJumpToLocation(GetPWUMLocation(sPCLocation)));
}
void SetPCToSaveLocation(object oPC)
{
if (!GetIsPC(oPC))
{
return; //buh-bye
}
SetLocalInt(oPC, "nSaveStatus", 0); //set to save
}
void SetPCToNotSaveLocation(object oPC)
{
if (!GetIsPC(oPC))
{
return; //buh-bye
}
SetLocalInt(oPC, "nSaveStatus", 1); //set to not save
}
dsl le code etait trop long :)
Par RAT le 16/1/2003 à 23:56:08 (#3038609)
////////////////////////////////////
// NOUVELLES FONCTIONS ////
// FAIT PAR RAT POUR PUMA ////
/////////////////////////////////
//*****************************
// FONCTIONS BANQUE
//*****************************
// GESTION DES SET
void SetBanqueOr(string var_name, int var_val, int iExpire=121000000, int iToken=0, int iExtend=0)
{
object umObject = GetLocalObject(GetModule(), "um_object");
int iDate=GetOffsetGameDate(0);
if (iToken < 2 && iExpire < 121000000)
{
if (iExpire < 121000000)
iExpire=GetOffsetGameDate(iExpire);
else
iExpire=GetLocalInt(umObject, "iDefaultExpire");
iToken=iToken+2;
}
if (iDate < iExpire)
{
string storageBuffer = "BNO#" + var_name + "#" + IntToString(var_val) + "#" + IntToString(iExpire) + "#" + IntToString(iToken) + "#" + IntToString(iExtend) + "#";
SetLocalInt(umObject,"BNO_"+ var_name, var_val);
SetLocalInt(umObject,"BNO_"+ var_name + "x", iExpire);
if (iToken==2)
SetLocalInt(umObject,"BNO_"+ var_name + "t", iExtend);
WriteTimestampedLogEntry(storageBuffer);
}
}
void SetBanqueInv(string var_name, string var_val, int iExpire=121000000, int iToken=0, int iExtend=0)
{
var_val=StrReplace("\n","°°",var_val);
object umObject = GetLocalObject(GetModule(), "um_object");
int iDate=GetOffsetGameDate(0);
if (iToken < 2 && iExpire < 121000000)
{
if (iExpire < 121000000)
iExpire=GetOffsetGameDate(iExpire);
else
iExpire=GetLocalInt(umObject, "iDefaultExpire");
iToken=iToken+2;
}
if (iDate < iExpire)
{
string storageBuffer = "BNI#" + var_name + "#" + var_val + "#" + IntToString(iExpire) + "#" + IntToString(iToken) + "#" + IntToString(iExtend) + "#";
SetLocalString(umObject,"BNI_"+ var_name, var_val);
SetLocalInt(umObject,"BNI_"+ var_name + "x", iExpire);
if (iToken==2)
SetLocalInt(umObject,"BNI_"+ var_name + "t", iExtend);
WriteTimestampedLogEntry(storageBuffer);
}
}
// GESTION DES GET
int GetBanqueOr(string var_name)
{
int retVal;
object umObject = GetLocalObject(GetModule(), "um_object");
int iExpire=GetLocalInt(umObject,"BNO_"+ var_name + "x");
int iDate=GetOffsetGameDate(0);
if (iExpire > 0 && iExpire 0)
SetBanqueOr( "BNO_"+ var_name, retVal, GetOffsetGameDate(iExtend), 2, iExtend);
return(retVal);
}
string GetBanqueInv(string var_name)
{
string retVal;
object umObject = GetLocalObject(GetModule(), "um_object");
int iExpire=GetLocalInt(umObject,"BNI_"+ var_name + "x");
int iDate=GetOffsetGameDate(0);
if (iExpire > 0 && iExpire 0)
SetBanqueInv("BNI_"+var_name, retVal, GetOffsetGameDate(iExtend), 2, iExtend);
retVal=StrReplace("°°","\n",retVal);
return(retVal);
}
// GESTION DES DELETE
void DeleteBanqueOr(string var_name)
{
object umObject = GetLocalObject(GetModule(), "um_object");
DeleteLocalInt(umObject,"BNO_"+ var_name);
DeleteLocalInt(umObject,"BNO_"+ var_name + "x");
DeleteLocalInt(umObject,"BNO_"+ var_name + "t");
WriteTimestampedLogEntry("DNO#" + var_name + "#");
//WriteTimestampedLogEntry("INT#" + var_name + "#");
}
void DeleteBanqueInv(string var_name)
{
object umObject = GetLocalObject(GetModule(), "um_object");
DeleteLocalString(umObject,"BNI_"+ var_name);
DeleteLocalInt(umObject,"BNI_"+ var_name + "x");
DeleteLocalInt(umObject,"BNI_"+ var_name + "t");
WriteTimestampedLogEntry("DNI#" + var_name + "#");
}
pwum_flags:
#include "pwum_functions"
//:: Definition des fonctions
// Fonction Althea
// Cree un debug
void Debug(object oPC, string sDebug);
// Fonction Althea
// Recupere le nom d'une variable flaguee sur un joueur
string GetFlagName(object oPlayer, string sFlag);
// Fonction Althea
// Defini le flag sFlag sur le joueur oPlayer a la valeur nValue
void SetFlagInt(object oPlayer, string sFlag, int nValue);
// Fonction Althea
// Defini le flag sFlag sur le joueur oPlayer a la valeur fValue
void SetFlagFloat(object oPlayer, string sFlag, float fValue);
// Fonction Althea
// Defini le flag sFlag sur le joueur oPlayer a la valeur sValue
void SetFlagString(object oPlayer, string sFlag, string sValue);
// Fonction Althea
// Defini le flag sFlag sur le joueur oPlayer a la valeur lValue
void SetFlagLocation(object oPlayer, string sFlag, location lValue);
// Fonction Althea
// Recupere le flag sFlag sur le joueur oPlayer
int GetFlagInt(object oPlayer, string sFlag);
// Fonction Althea
// Recupere le flag sFlag sur le joueur oPlayer
float GetFlagFloat(object oPlayer, string sFlag);
// Fonction Althea
// Recupere le flag sFlag sur le joueur oPlayer
string GetFlagString(object oPlayer, string sFlag);
// Fonction Althea
// Recupere le flag sFlag sur le joueur oPlayer
location GetFlagLocation(object oPlayer, string sFlag);
void DeleteFlagInt(object oPlayer, string sFlag);
void DeleteFlagString(object oPlayer, string sFlag) ;
void DeleteFlagFloat(object oPlayer, string sFlag);
void DeleteFlagLocation(object oPlayer, string sFlag);
string GetFlagName(object oPlayer, string sFlag)
{
//Verification des informations fournies
string sReturn;
if(GetIsPC(oPlayer) && sFlag != ")
{ //Execution du script
//Recuperation des informations du joueur
string sPlayerName = GetPCPlayerName(oPlayer);
string sName = GetName(oPlayer);
string sPublicKey = GetPCPublicCDKey(oPlayer);
//Definition de la valeur
sReturn = sPlayerName+sPublicKey+sName+sFlag;
}else{ //Retour d'une erreur
//Definition de la valeur
sReturn = "ERREUR DANS L'APPEL DE LA FONCTION GetFlagName";
}
//Renvoit de la valeur
return sReturn;
}
void SetFlagInt(object oPlayer, string sFlag, int nValue)
{
Debug(oPlayer,"Flag "+sFlag+" du personnage "+GetName(oPlayer)+" defini a "+IntToString(nValue));
SetPWUMInt(GetFlagName(oPlayer,sFlag),nValue); //Enregistrement de la variable
}
void DeleteFlagInt(object oPlayer, string sFlag)
{
DeletePWUMInt(GetFlagName(oPlayer,sFlag)); //Enregistrement de la variable
}
void SetFlagFloat(object oPlayer, string sFlag, float fValue)
{
Debug(oPlayer,"Flag "+sFlag+" du personnage "+GetName(oPlayer)+" defini a "+FloatToString(fValue));
SetPWUMFloat(GetFlagName(oPlayer,sFlag),fValue);
}
void DeleteFlagFloat(object oPlayer, string sFlag)
{
DeletePWUMFloat(GetFlagName(oPlayer,sFlag));
}
void SetFlagString(object oPlayer, string sFlag, string sValue)
{
Debug(oPlayer,"Flag "+sFlag+" du personnage "+GetName(oPlayer)+" defini a "+sValue);
SetPWUMString(GetFlagName(oPlayer,sFlag),sValue);
}
void DeleteFlagString(object oPlayer, string sFlag)
{
DeletePWUMString(GetFlagName(oPlayer,sFlag));
}
void SetFlagLocation(object oPlayer, string sFlag, location lValue)
{
Debug(oPlayer,"Flag "+sFlag+" du personnage "+GetName(oPlayer)+" modifie");
SetPWUMLocationC(GetFlagName(oPlayer,sFlag),lValue);
}
void DeleteFlagLocation(object oPlayer, string sFlag)
{
DeletePWUMLocation(GetFlagName(oPlayer,sFlag));
}
int GetFlagInt(object oPlayer, string sFlag)
{
return GetPWUMInt(GetFlagName(oPlayer,sFlag));
}
float GetFlagFloat(object oPlayer, string sFlag)
{
return GetPWUMFloat(GetFlagName(oPlayer,sFlag));
}
string GetFlagString(object oPlayer, string sFlag)
{
return GetPWUMString(GetFlagName(oPlayer,sFlag));
}
location GetFlagLocation(object oPlayer, string sFlag)
{
return GetPWUMLocation(GetFlagName(oPlayer,sFlag));
}
//:: Definition des constantes
int DEBUG_OFF = 0;
int DEBUG_PLAYER = 1;
int DEBUG_DM = 2;
int DEBUG_PLAYER_LOGS = 3;
int DEBUG_DM_LOGS = 4;
int DEBUG_TYPE = DEBUG_OFF;
//:: Definition des fonctions
void Debug(object oPC, string sDebug)
{
//Switch a qui envoyer le debug
switch(DEBUG_TYPE)
{
case 0:
//Pas de debug
break;
case 1:
case 3:
//Debug au joueur
if(GetIsPC(oPC))
{
SendMessageToPC(oPC,"DEBUG: "+sDebug);
}
break;
case 2:
case 4:
//Debug aux DMs
SendMessageToAllDMs("DEBUG: "+sDebug);
break;
default:
break;
}
//Switch pour inscription aux logs
switch(DEBUG_TYPE)
{
case 0:
case 1:
case 2:
//Pas de logs
break;
case 3:
case 4:
//Inscription aux logs
WriteTimestampedLogEntry("DEBUG: "+sDebug);
break;
default:
break;
}
}
//**********************************************
// GESTION DES FLAGS POUR LE SYSTEME DE BANQUE
// FAIT PAR RAT POUR PUMA
//**********************************************
void SetFlagOr(object oPlayer, string sFlag, int nValue)
{
Debug(oPlayer,"Flag "+sFlag+" du personnage "+GetName(oPlayer)+" defini a "+IntToString(nValue));
SetBanqueOr(GetFlagName(oPlayer,sFlag),nValue); //Enregistrement de la variable
}
void DeleteFlagOr(object oPlayer, string sFlag)
{
DeleteBanqueOr(GetFlagName(oPlayer,sFlag)); //Enregistrement de la variable
}
void SetFlagInv(object oPlayer, string sFlag, string sValue)
{
Debug(oPlayer,"Flag "+sFlag+" du personnage "+GetName(oPlayer)+" defini a "+sValue);
SetBanqueInv(GetFlagName(oPlayer,sFlag),sValue);
}
void DeleteFlagInv(object oPlayer, string sFlag)
{
DeleteBanqueInv(GetFlagName(oPlayer,sFlag));
}
int GetFlagOr(object oPlayer, string sFlag)
{
return GetBanqueOr(GetFlagName(oPlayer,sFlag));
}
string GetFlagInv(object oPlayer, string sFlag)
{
return GetBanqueInv(GetFlagName(oPlayer,sFlag));
}
Par eMRaistlin le 17/1/2003 à 0:47:17 (#3038831)
Par Iridian le 17/1/2003 à 22:41:49 (#3045222)
Dit moi RAT, tu pourrais m'expliquer ce qui va dans pwum_function et ce qui vas à la place des fonctions de gestion des flags ?
Je pense que le premier post concerne les pwum_function et le 2e les flags mais je préférerai être sur ;)
A l'avenir l'idéal pour me faciliter les mises a jour serai de mettre en ligne deux fichiers textes :)
(je sais, je suis difficile ;) )
JOL Archives 1.0.1
@ JOL / JeuxOnLine