View previous topic :: View next topic |
Author |
Message |
wvannice
Joined: 11 Nov 2006 Posts: 5 Location: Stow, Ohio
|
Posted: Sun Nov 12, 2006 18:59 Post subject: OOC on enter scripting |
|
|
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 |
|
|
Rami_Ahmed
Joined: 07 Dec 2005 Posts: 37 Location: Denmark
|
Posted: Sun Nov 12, 2006 19:21 Post subject: |
|
|
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. |
|
Back to top |
|
|
wvannice
Joined: 11 Nov 2006 Posts: 5 Location: Stow, Ohio
|
Posted: Sun Nov 12, 2006 19:28 Post subject: |
|
|
Thanks for your help on this, I was pulling out what little hair I have left trying different ways to get it to work. _________________ Phour Phaser Phred |
|
Back to top |
|
|
wvannice
Joined: 11 Nov 2006 Posts: 5 Location: Stow, Ohio
|
Posted: Sun Nov 12, 2006 23:15 Post subject: Auughh!! |
|
|
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! ) _________________ Phour Phaser Phred |
|
Back to top |
|
|
Rami_Ahmed
Joined: 07 Dec 2005 Posts: 37 Location: Denmark
|
Posted: Mon Nov 13, 2006 17:49 Post subject: |
|
|
You probably used the same character for testing, right?
Try using different characters. And remember to start NwServer with NWNx2. It should work
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 |
|
|
wvannice
Joined: 11 Nov 2006 Posts: 5 Location: Stow, Ohio
|
Posted: Mon Nov 13, 2006 22:57 Post subject: OOC Enter |
|
|
Believe it or not I can understand your scripts . 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 |
|
|
Rami_Ahmed
Joined: 07 Dec 2005 Posts: 37 Location: Denmark
|
Posted: Tue Nov 14, 2006 19:55 Post subject: |
|
|
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. |
|
Back to top |
|
|
wvannice
Joined: 11 Nov 2006 Posts: 5 Location: Stow, Ohio
|
Posted: Wed Nov 15, 2006 15:24 Post subject: NWNX On Server |
|
|
That kind of what I thought, Thanks. _________________ Phour Phaser Phred |
|
Back to top |
|
|
|
|
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
|