Aller au contenu

Photo

help fixing a script


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

#1
Surek

Surek
  • Members
  • 94 messages
 Looking for some help I borrowed this script from the
lexicon. For some reason it won’t compile and I keep getting an error message
saying  no right bracket on expression. Any help on this would be great

 Here is the script.



 

// The name of your database

const string 
GZ_CAMPAIGN_DATABASE = "MY_DB";

// possible values for the GTSavePlayerLocation() function

const string GT_DB_L_PLAYER_DEATH =
"GZ_PLAYER_L_LAST_DEATH";      
// last place of death

const string GT_DB_L_PLAYER_BIND =
"GZ_PLAYERL_L_LAST_BIND";       
// last savepoint used

const string GT_DB_L_PLAYER_START =
"GZ_PLAYER_L_LAST_START";      
// start location

// C O N F I G U R A T I O N

// if set to TRUE, the player can only save his last save
location at savepoints

const int GT_DB_USESAVEPOINTS = TRUE;

// cost in GP to use a savepoint

const int GT_DB_SAVEPOINT_COST = 10;

 

// toggle debug messages

const int GT_DB_DEBUGMODE = TRUE;

// Message strings

const string GZ_DB_S_SAVEPOINT_USED = "This place is
now your SavePoint where you return after dying";

const string GZ_DB_S_SAVEPOINT_OFF = "SavePoints are
not activated in this world";

const string GZ_DB_S_SAVEPOINT_NOGOLD = "You can not
afford to use this SavePoint";

const string GZ_DB_S_PORTALSCROLL_FAIL = "An invisible
force prevents you from entering the magical portal";

const string GZ_DB_S_FORCEDEATH = "Forced Death - Last
time you left this world you were dead.";

// Object Tags

const string GZ_DB_O_PORTAL = "gz_o_portaldoor";

 

// I N T E R F A C E

// returns TRUE if a location is valid

int GTGetIsLocationValid(location lLoc);

// returns a unique string for each PC

//string GTGetUniqueCharID(object oPC); //Not used anymore

// saves the current status of the player (hp, location)

void GTSavePlayerStatus(object oPC);

// returns the number of time a player has died

int GTGetPlayerDeathCount(object oPC);

// saves the location of the player into the slot defined in
sLocationID

// for easy tracking, use the GT_DB_L_* constants defined in
this library for the sLocationID

void GTSavePlayerLocation(object oPC, string sLocationID);

// returns a persistant location stored with
GTSavePlayerLocation on the player

// use with the GT_DB_L_* constants to prevent typos errors

location GTLoadPlayerLocation(object oPC, string
sLocationID);

// increase the death count of a player by one

void GTIncreasePlayerDeathCount(object oPC);

 

// reset the database

void GTResetDatabase();

 

 

// I M P L E M E N T A T I O N

int 
GTGetIsLocationValid(location lLoc)

{

    return
(GetAreaFromLocation(lLoc)!= OBJECT_INVALID);

}

string GTGetUniquePlayerID(object oPC)

{

    return  GetPCPublicCDKey(oPC) + GetName(oPC);

}

 

void 
GTIncreasePlayerDeathCount(object oPC)

{

      // Increment
death count only if death was not forced by OnEnter Event

    if
(GetLocalInt(oPC, "GZ_DB_DIE_FORCED"))

    {

       
DeleteLocalInt(oPC, "GZ_DB_DIE_FORCED");

        return;

    }

    SetLocalInt(oPC,
"GZ_DB_DIE_FORCED",TRUE);

   
SetCampaignInt(GZ_CAMPAIGN_DATABASE,"GZ_PLAYER_DEATHCOUNT",GTGetPlayerDeathCount(oPC)+1,oPC);

}

int GTGetPlayerDeathCount(object oPC)

{

    return
GetCampaignInt(GZ_CAMPAIGN_DATABASE,"GZ_PLAYER_DEATHCOUNT",oPC);

}

void GTSavePlayerLocation(object oPC, string sLocationID)

{

    if
(GTGetIsLocationValid(GetLocation(oPC)))

    {

       
SetCampaignLocation(GZ_CAMPAIGN_DATABASE, sLocationID ,
GetLocation(oPC), oPC);

    }

}

location GTLoadPlayerLocation(object oPC, string
sLocationID)

{

    return
GetCampaignLocation(GZ_CAMPAIGN_DATABASE, sLocationID, oPC);

}

void GTDebug(object oPC, string sInfo)

{

    if
(!GT_DB_DEBUGMODE)

    {

        return;

    }

   
SendMessageToPC(oPC, "**** GZ-DB Debug: " + sInfo);

   
WriteTimestampedLogEntry( "**** GZ-DB Debug: " +
GTGetUniquePlayerID(oPC) + " - " + sInfo);

}

 

void GTDie(object oPC = OBJECT_SELF)

{

      
SetLocalInt(oPC, "GZ_DB_DIE_FORCED",TRUE);

       effect eDeath =
EffectDeath();

      
ApplyEffectToObject(DURATION_TYPE_INSTANT,eDeath,oPC);

      
SendMessageToPC(oPC,GZ_DB_S_FORCEDEATH);

 

}

void GTSavePlayerStatus(object oPC)

{

    // Save current HP

   
SetCampaignInt(GZ_CAMPAIGN_DATABASE,"GZ_PLAYER_CUR_HP",GetCurrentHitPoints(oPC),
oPC);

    // Save current
state (dead/alive)

   
SetCampaignInt(GZ_CAMPAIGN_DATABASE,"GZ_PLAYER_IS_DEAD",GetIsDead(oPC),oPC);

 

    //
SendMessageToPC(oPC

    GTDebug(oPC,
"Status Saved");

}

void GTRestorePlayerStatus(object oPC)

{

    location lLoc;

    int bDead =
GetCampaignInt(GZ_CAMPAIGN_DATABASE,"GZ_PLAYER_IS_DEAD",oPC);

 

   if
(GT_DB_USESAVEPOINTS)

    {

        // load save
point

        lLoc
=GTLoadPlayerLocation(oPC, GT_DB_L_PLAYER_BIND);

    }

    else

    {

        //load last
save point

        lLoc
=GTLoadPlayerLocation(oPC,GT_DB_L_PLAYER_START );

    }

 

    if
(GTGetIsLocationValid(lLoc))

    {

       
AssignCommand(oPC, JumpToLocation (lLoc));

    }

 

    // if player was
dead on last save, revert him to that state

    if (bDead)

    {

       
AssignCommand(oPC,GTDie());

    }

    else

    {

        // if player
was damage last save, lower his hitpoints

        int nHP =
GetCampaignInt(GZ_CAMPAIGN_DATABASE,"GZ_PLAYER_CUR_HP", oPC);

        int nHPDelta =
GetCurrentHitPoints(oPC)- nHP;

        if (nHPDelta>0)       ß--------------error
message is here

        {

            effect
eDamage = EffectDamage(nHPDelta , DAMAGE_TYPE_MAGICAL,DAMAGE_POWER_PLUS_FIVE);

            eDamage =
SupernaturalEffect(eDamage);

           
ApplyEffectToObject (DURATION_TYPE_INSTANT, eDamage,oPC);

        }

    }

}

 

void GTResetDatabase()

{

   
DestroyCampaignDatabase(GZ_CAMPAIGN_DATABASE);

 

}

#2
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
First that is not a script, It has no Main function. therefore it is an include that needs to be used with a main script.

The include file will not compile by itself. If you are trying to use the functions in a main script. The problem could be in either the include or the main script. would need to see the main script to see if the problem is there.

#3
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
OK, I see where you say the error is at now. The > is an html code for the greater then sign so just replace it with >

#4
Squatting Monk

Squatting Monk
  • Members
  • 446 messages
Fixed it for you.

In the switch to the Lexicon wiki, some of the script examples didn't get properly converted from the HTML format. I'm going through the Lexicon page-by-page to make sure everything is formatted correctly. In the meantime, if you stumble on a page that is broken, you're welcome to fix it yourself. If you don't know how, PM me or leave a message on my talk page and I'll fix it for you.