Author Topic: help please?  (Read 324 times)

Legacy_Ryuhi2000

  • Full Member
  • ***
  • Posts: 159
  • Karma: +0/-0
help please?
« on: March 29, 2011, 07:16:08 am »


               ive been working on what i consider a intresting respawn system but i hit a road block
script editor is saying mismatched type for object oPoint in the below code when i try to compile the code below
can someone tell me how to fix this or how do what it shows im trying to do below please if it is unfixable?

also could someone clarify for me a CampaignVariable is indeed used to to make things persistent across server resets?

thanks in advance

Code:

void main()
{

    object oPC = GetLastRespawnButtonPresser();
    string sBindPoint;
    string bindpoint = GetCampaignString("bindpointdatabase", "sBindPoint", oPC);
    string bindpointdatabase;
    object oPoint = GetCampaignString("bindpointdatabase", "sBindPoint", oPC);

if (GetIsObjectValid(oPoint)== TRUE)
{
//code to run if the string exists
}

if (GetIsObjectValid(oPoint)!= TRUE)
{
//code to run if the string does not exist
}

}
               
               

               
            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
help please?
« Reply #1 on: March 29, 2011, 07:54:58 am »


               object oPoint = GetCampaignString("bindpointdatabase", "sBindPoint", oPC);
This line is your problem.  An object variable is not a string variable.  Maybe you're looking for GetCampaignObject?

Stupid forum not saving edits...


Edited to add (again):

It looks like you're trying to store and retrieve a location from the database.  I see a couple ways of handling this:

A) waypoints - if your bind points are tied to existing waypoints, you can just store the tag of the bound waypoint as a string in the database and use GetCampaignString to get that tag back

'B)' locations - if bind points aren't tied to waypoints, you'll need to store the location in the database after breaking it up into separate pieces of data that will be stored persistently ("location" isn't always stored properly).  You'll need to break it up into area tag (string), x coordinate (float), y coordinate (float), z coordinate (float), and facing direction (float).  You can then use various SetCampaign_ functions to store this info.  Later, get the information from the database and use the Location function to "rebuild" the stored location from the pieces of data when you send a creature/PC there.
               
               

               


                     Modifié par The Amethyst Dragon, 29 mars 2011 - 07:05 .
                     
                  


            

Legacy_Ryuhi2000

  • Full Member
  • ***
  • Posts: 159
  • Karma: +0/-0
help please?
« Reply #2 on: March 29, 2011, 08:05:41 am »


               Edit because my internet lagged out and i did not see half of your above post:
waypoint would definitely be easier since i must say the location way sounds beyond my scripting ability.

they way i have that feature now a npc when the player speaks to him creates a waypoint and this waypoint is what i want the player to bind to persistently.

i will be relasing my respawn system on nwvault when this problem is fixed for anyone who would like to check it out
               
               

               


                     Modifié par Ryuhi2000, 29 mars 2011 - 07:13 .
                     
                  


            

Legacy_Ryuhi2000

  • Full Member
  • ***
  • Posts: 159
  • Karma: +0/-0
help please?
« Reply #3 on: March 29, 2011, 08:17:17 am »


               yes you hit on the head GetCampaignString would work for that but how do i setup the if to see if the string exists in the database tho? sorry if im just being oblivious to this

thank you very much for your help '<img'>
will be posting a link to the system when i have it completely documented as i intend to make it customizable by the end user

edit:
i was being oblivous to it i was overthinking the code i think and  here is what i came up with to fix it to do the samething as i want

if(GetCampaignString("bindpointdatabase", "sBindPoint", oPC) != "")
{
//code to run if there is abindpoint
}

if(GetCampaignString("bindpointdatabase", "sBindPoint", oPC) == "")
{
//code to run if there is no bindpoint
}
               
               

               


                     Modifié par Ryuhi2000, 29 mars 2011 - 07:29 .
                     
                  


            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
help please?
« Reply #4 on: March 29, 2011, 06:12:42 pm »


               This will also work:


if(GetCampaignString("bindpointdatabase", "sBindPoint", oPC) == "")
{
//code to run if there is no bindpoint
}

else
{
//code to run if there is abindpoint
}


However, if you plan to actually use the string in the code you'll want to define it:


string sBindPoint = GetCampaignString("bindpointdatabase", "sBindPoint", oPC);

if(sBindPoint  == "")
{
//code to run if there is no bindpoint
}

else
{
//code to run if there is abindpoint
}


-420
               
               

               


                     Modifié par 420, 29 mars 2011 - 05:13 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
help please?
« Reply #5 on: March 29, 2011, 07:32:13 pm »


               

Ryuhi2000 wrote...

they way i have that feature now a npc when the player speaks to him creates a waypoint and this waypoint is what i want the player to bind to persistently.


The WayPoint you are creating is also not persistent.  You will still have to store the location in order to recreate the waypoint after the server resets.   I myself see no reason to create the waypoint since you will still have to store the location.   Even if you did not want persistance I see no reason to create the Waypoint.  It is faster to just store the location opposed to  makeing  the module search for the waypoint every time you want to port to it.
               
               

               
            

Legacy_Ryuhi2000

  • Full Member
  • ***
  • Posts: 159
  • Karma: +0/-0
help please?
« Reply #6 on: March 29, 2011, 08:44:40 pm »


               Doh after i read both posts i edited my system so instead of the waypoint being created through a different script in the system the module builder has to place the waypoint tagged respawnpoint and that is the bindpoint now

i just uploaded my system as is to nwvault but its pending approval right now
http://nwvault.ign.c....Detail&id=3805

Edit:
here is the current code for the related to Destination function in the include:

/*
Destination function notes:
this function is modular so you can add or remove respawn locations as you want to
remember tho if you remove all respawn locations you will break the player being able to respawn
unless you have at least one respawn location setup that you created and put into the function
i would suggest keeping the unmodified functions 4th respawn location even if you change the other ones
here is the order in which the respawn locations are in use assuming you have not customized this function
1. the nearest rez shrine if the player found any rez shrines in the area
2. the players set bind point if one is set
3. the modules default respawn point if the player does not have a set bind point
4. where the player died if the module does not have a default respawn point
*/

void Destination(object oRespawner)
{
  //start the variables that can not be removed

   int foundrezshrine;

   int hasrezshrine;

   object oArea = GetArea(oRespawner);

   object oTemple = GetWaypointByTag("NW_DEATH_TEMPLE");

   string sDestTag;

  //end of variables that can not be removed

//start of rez shrine code that can be removed

if (GetLocalInt(oArea, "hasrezshrine")==1)//checks if the player found a rez shrine
   {

   if (GetLocalInt(oRespawner, "foundrezshrine")== 1)
   {

   //send them to the nearest one
   string oShrine = "GetNearestObjectByTag(rezshrine)";

   SetLocalString(oRespawner, "sDestTag", "oShrine");

   }

   }

//end of rez shrine code that can be removed

//if the player has not found the rez shrine or there are no rez shrines
if (GetLocalInt(oArea, "hasrezshrine") == 0) return TRUE;

if (GetLocalInt(oRespawner, "foundrezshrine")== 0)
  {

   string bindpoint = GetCampaignString("bindpointdatabase", "sBindPoint", oRespawner);

   string bindpointdatabase;

   string sBindPoint;

//start of bind point code that can be removed

if(GetCampaignString("bindpointdatabase", "sBindPoint", oPC) != "")

   {SetLocalString(oRespawner, "sDestTag", "bindpoint");}

//end of bind point code that can be removed

// If no bind point was found  or you are not using that feature
if(GetCampaignString("bindpointdatabase", "sBindPoint", oPC) == "") return TRUE;

//start of rez at module default location code that can be removed

if (GetIsObjectValid(oTemple)== TRUE)

{SetLocalString(oRespawner, "sDestTag", "NW_DEATH_TEMPLE");}

//end of rez at module default location code that can be removed

//if the module does not have a default respawn point
   if (GetIsObjectValid(oTemple)!= TRUE) return TRUE;

SetLocalString(oRespawner, "sDestTag", "GetLocation(oRespawner)");//rez where you are

   }
}

here is the code of the main script:

#include "respawn_include"

void main()
{

   object oRespawner = GetLastRespawnButtonPresser();

   Rez(oRespawner);//function that rezs player and figures out how much hp to heal them by

   ApplyPenalty(oRespawner);//function that determines how gold and/or xp loss

   Destination(oRespawner);//function that figures out where to send player upon respawn

   string sTag = GetLocalString(oRespawner, "sDestTag");//sets the destination tag to a string

   object oSpawnPoint = GetObjectByTag("sTag");

   //send the player to the destination
   AssignCommand(oRespawner,JumpToLocation(GetLocation(oSpawnPoint)));

}
               
               

               


                     Modifié par Ryuhi2000, 29 mars 2011 - 08:21 .