logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
OOC on enter scripting

 
Post new topic   Reply to topic    nwnx.org Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
wvannice



Joined: 11 Nov 2006
Posts: 5
Location: Stow, Ohio

PostPosted: Sun Nov 12, 2006 18:59    Post subject: OOC on enter scripting Reply with quote

I have the following script that I want to use in my PW mod. I am using NWNX and SQLite. Aside from the obvious need to include the APS_Include file I am not sure how to get this to work.

/////////////////////////////////////////////////////////////////////////////
//Put this script OnEnter
#include "nw_i0_tool"


void RegisterPC( object oPC)
{ string sUniqueID = GetName( oPC) +GetPCPlayerName( oPC);
SetCampaignInt( "PWRegistry", sUniqueID, TRUE);
}


int GetIsANewPlayer( object oPC)
{ string sUniqueID = GetName( oPC) +GetPCPlayerName( oPC);
return GetCampaignInt( "PWRegistry", sUniqueID);
}


void main()
{ object oPC = GetEnteringObject();
if( !GetIsPC( oPC)) return;
if( GetIsANewPlayer( oPC))
{ RegisterPC( oPC);
SetXP( oPC, 10000);
GiveGoldToCreature( oPC, 25000 -GetGold( oPC));
}

if( !GetIsObjectValid( GetItemPossessedBy( oPC, "mr_emote_wand"))) CreateItemOnObject( "mr_emote_wand", oPC);
}

///////////////////////////////////////////////////////////////

I am learning scripting and can do some things but using the database is kind of new to me. Any help would be greatly appreciated.
_________________
Phour Phaser Phred
Back to top
View user's profile Send private message
Rami_Ahmed



Joined: 07 Dec 2005
Posts: 37
Location: Denmark

PostPosted: Sun Nov 12, 2006 19:21    Post subject: Reply with quote

You need to do one of your checks the other way round. Look.
Code:
int GetIsANewPlayer( object oPC)
{ string sUniqueID = GetName( oPC) +GetPCPlayerName( oPC);
return GetCampaignInt( "PWRegistry", sUniqueID);
}

You should call this function "GetIsAnOldPlayer", because, this will return TRUE if the Campaign int has been set. So.. you have to do like this:
Code:

/////////////////////////////////////////////////////////////////////////////
//Put this script OnEnter
#include "nw_i0_tool"


void RegisterPC( object oPC)
{ string sUniqueID = GetName( oPC) +GetPCPlayerName( oPC);
SetCampaignInt( "PWRegistry", sUniqueID, TRUE);
}


int GetIsANewPlayer( object oPC)
{ string sUniqueID = GetName( oPC) +GetPCPlayerName( oPC);
return GetCampaignInt( "PWRegistry", sUniqueID);
}


void main()
{ object oPC = GetEnteringObject();
if(!GetIsPC( oPC)) return;
if(!GetIsANewPlayer( oPC))
{ RegisterPC( oPC);
SetXP( oPC, 10000);
GiveGoldToCreature( oPC, 25000 -GetGold( oPC));
}

if( !GetIsObjectValid( GetItemPossessedBy( oPC, "mr_emote_wand"))) CreateItemOnObject( "mr_emote_wand", oPC);
}

///////////////////////////////////////////////////////////////

And if you want to use NWNx2, and want a little more neat script...
Code:
/////////////////////////////////////////////////////////////////////////////
//Put this script OnEnter
#include "aps_include"
void main()
{ object oPC = GetEnteringObject();
  if (!GetIsPC( oPC)) return;
  if (!GetPersistentInt(oPC, "PWRegistry"))
  {  SetPersistentInt(oPC, "PWRegistry", TRUE);
     SetXP(oPC, 10000);
     GiveGoldToCreature(oPC, 25000 - GetGold(oPC));
  }
  if (!GetIsObjectValid(GetItemPossessedBy(oPC, "mr_emote_wand")))
  {  CreateItemOnObject("mr_emote_wand", oPC);
  }
}
/////////////////////////////////////////////////////////////////////////////

Hope it works for ya. Good luck. Mr. Green
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
wvannice



Joined: 11 Nov 2006
Posts: 5
Location: Stow, Ohio

PostPosted: Sun Nov 12, 2006 19:28    Post subject: Reply with quote

Thanks for your help on this, I was pulling out what little hair I have left trying different ways to get it to work. Embarassed
_________________
Phour Phaser Phred
Back to top
View user's profile Send private message
wvannice



Joined: 11 Nov 2006
Posts: 5
Location: Stow, Ohio

PostPosted: Sun Nov 12, 2006 23:15    Post subject: Auughh!! Reply with quote

Ok, maybe I'm not doing this right. I used your NWNx2 script and ran it on my comp using the NWNx2 and it worked "as is". When I uploaded it to the server and tried it all I got was the wand, no xp or gold. Am I missing something here? Is NWNx supposed to up on the server, if so how, should that "PWRegistry" entry be named something else? I'm really confused.

(Heh, I'm 57 years old, maybe I'm too old for this, hope not! Rolling Eyes )
_________________
Phour Phaser Phred
Back to top
View user's profile Send private message
Rami_Ahmed



Joined: 07 Dec 2005
Posts: 37
Location: Denmark

PostPosted: Mon Nov 13, 2006 17:49    Post subject: Reply with quote

You probably used the same character for testing, right? Mr. Green
Try using different characters. And remember to start NwServer with NWNx2. It should work Wink

There is a much simpler method, to use though. Why not just check, to see if the character has any XP when entering? Under normal circumstances, characters start with 0 XP. So..

Code:
//Put this script OnEnter
#include "aps_include"
void main()
{ object oPC = GetEnteringObject();
  if (!GetIsPC(oPC)) return;
  if (GetXP(oPC) <= 0)
  {  SetXP(oPC, 10000);
     GiveGoldToCreature(oPC, 25000 - GetGold(oPC));
  }
  if (!GetIsObjectValid(GetItemPossessedBy(oPC, "mr_emote_wand")))
  {  CreateItemOnObject("mr_emote_wand", oPC);
  }
}
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
wvannice



Joined: 11 Nov 2006
Posts: 5
Location: Stow, Ohio

PostPosted: Mon Nov 13, 2006 22:57    Post subject: OOC Enter Reply with quote

Believe it or not I can understand your scripts Very Happy . What I don't understand now is how to strat NWNx2 on the server's website that is hosting our game. We are using www.dungeonserver.com for our host and I am unsure of how to run NWNX on it. Any help or a pointer to right place to look will be a great help. I will check out their site to see what they say in the meantime. Thanks again in advance.
_________________
Phour Phaser Phred
Back to top
View user's profile Send private message
Rami_Ahmed



Joined: 07 Dec 2005
Posts: 37
Location: Denmark

PostPosted: Tue Nov 14, 2006 19:55    Post subject: Reply with quote

Uehm.. you would need acces to some kind of harddrive. You'd 'simply' need to download NWNx2 and the required extra stuff onto the servers computers, but I'm no geek in that kinda stuff. Embarassed
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
wvannice



Joined: 11 Nov 2006
Posts: 5
Location: Stow, Ohio

PostPosted: Wed Nov 15, 2006 15:24    Post subject: NWNX On Server Reply with quote

That kind of what I thought, Thanks.
_________________
Phour Phaser Phred
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> General Discussion All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
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