Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "nw_i0_tool"
- #include "st_inc"
- #include "aps_include"
- #include "zep_inc_craft"
- #include "check_cdkey_inc"
- void no_double_logins(int nServer, object oPC)
- {
- string sTemp;
- string sName = GetName(oPC);
- if(nServer == 1)
- {
- SQLExecDirect("SELECT val FROM pwhoserverb");
- }
- if(nServer == 2)
- {
- SQLExecDirect("SELECT val FROM pwhoservera");
- }
- if(nServer > 2)
- return;
- int nLoop = SQLFetch();
- if(nLoop == SQL_ERROR)
- {
- //The other server could be booting.
- //SendMessageToAllDMs("Error. Empty WHO SQL database!");
- return;
- }
- while(nLoop == SQL_SUCCESS)
- {
- sTemp = SQLGetData(1);
- if(sTemp == sName)
- {
- SendMessageToPC(oPC, "ERROR! You can not log into both servers with the same character. Disconnecting!");
- SendMessageToAllDMs("Player: " +GetName(oPC) +" logged into BOTH servers with account: " + GetPCPlayerName(oPC));
- DelayCommand(7.0, BootPC(oPC));
- return;
- }
- nLoop = SQLFetch();
- }
- }
- void nuke_item_props(object oPC, string sCorpse, int nServer)
- {
- string sDB = GetPCPublicCDKey(oPC)+IntToString(nServer);
- DeleteCampaignVariable(sDB, "CorpseItem"+sCorpse, oPC);
- WriteTimestampedLogEntry("Delete Bioware DB entry for: " + sDB + " slot: " + sCorpse);
- }
- void clean_slot(object oPC, string sCorpse, int nServer)
- {
- DeletePersistentVariable(oPC, "ItemAs" + sCorpse);
- DeletePersistentVariable(oPC, "ItemBs" + sCorpse);
- DeletePersistentVariable(oPC, "ItemLs" + sCorpse);
- DeletePersistentVariable(oPC, "CorpseSlot" +sCorpse);
- DeletePersistentVariable(oPC, "Serveri" +sCorpse);
- DeletePersistentVariable(oPC, "CorpseSlotTS" +sCorpse);
- DeleteLocalInt(oPC, "ExCorpsF" +sCorpse);
- nuke_item_props(oPC, sCorpse, nServer);
- }
- int generate_corpse(object oPC, int nI, int nServer)
- {
- object oMyItem;
- string sArea = GetPersistentString(oPC, "ItemAs" + IntToString(nI)); //The Area Tag where they died.
- string sCnt = IntToString(nI);
- object oArea = GetObjectByTag(sArea);
- if(!GetIsObjectValid(oArea))
- {
- WriteTimestampedLogEntry("Invalid Area Tag in On Connect gen_corpse: "+sArea);
- clean_slot(oPC, sCnt, nServer);
- return FALSE; //This should never happen but it does. Bad code, BAD Code!
- }
- string sItem = GetPersistentString(oPC, "ItemBs" + sCnt); //Item lost when they died.
- location lLoc = GetPersistentLocation(oPC, "ItemLs" + sCnt); //Location in area where they died.
- WriteTimestampedLogEntry("Restoring Item: "+sItem);
- object oNewCorpse = CreateObject(OBJECT_TYPE_PLACEABLE, "pccorpse", lLoc); //New Corpse
- if(!GetIsObjectValid(oNewCorpse))
- {
- WriteTimestampedLogEntry("WARNING! Could not regenerate player corpse: " + GetPCPlayerName(oPC) + " Number: " +sCnt);
- clean_slot(oPC, sCnt, nServer);
- return FALSE;
- }
- /*
- string sBodyLock = GetPersistentString(oPC, "PCHARNAME" + sCnt);
- if(sBodyLock == "")
- {
- string sCharName = GetName(oPC);
- WriteTimestampedLogEntry("WARNING! Character name not set for: " + sCharName + " Number: " +sCnt);
- sBodyLock = sCharName;
- }
- */
- string sBodyLock = GetName(oPC); //Replaced function above w/ a simple getname()
- SetLocalString(oNewCorpse, "sOwner", GetPCPlayerName(oPC)); //Who owns it.
- SetLocalString(oNewCorpse, "sPCName", sBodyLock); //Who owns it.
- SetLocalInt(oNewCorpse, "CorpseNumber", nI); //Corpse Number
- //We try to restore the item from NWN database first in case it has customized props. IF that fails, restore using the blueprint.
- oMyItem = RetrieveCampaignObject(GetPCPublicCDKey(oPC)+IntToString(nServer), "CorpseItem"+sCnt, GetLocation(oNewCorpse), oNewCorpse, oPC);
- if(GetIsObjectValid(oMyItem))
- {
- WriteTimestampedLogEntry("Regenerated player item: " + sItem + " for: " + GetPCPlayerName(oPC)+ " from NWN database. Slot: " +sCnt);
- return TRUE;
- }
- else
- {
- WriteTimestampedLogEntry("WARNING! Could not regenerate player item: " + sItem + " for: " + GetPCPlayerName(oPC)+ " from NWN database. Slot: " +sCnt);
- oMyItem = CreateItemOnObject(sItem, oNewCorpse);
- if(!GetIsObjectValid(oMyItem))
- {
- WriteTimestampedLogEntry("WARNING! Could not regenerate player item: " + sItem + " for: " + GetPCPlayerName(oPC)+ "from blueprint resref. Slot: " +sCnt);
- return FALSE;
- }
- else
- {
- SetIdentified(oMyItem, TRUE);
- return TRUE;
- }
- }
- return FALSE;
- }
- void do_corpse_recovery(object oPC, int nServer) //Regenerate up to a max of 6 corpses per player when they log in.
- {
- int nCnt = 1;
- while(nCnt < 7)
- {
- string sCnt = IntToString(nCnt);
- WriteTimestampedLogEntry("Checking corpse slot: "+sCnt);
- if(GetLocalInt(oPC, "ExCorpsF"+sCnt) != 1 && GetPersistentInt(oPC, "CorpseSlot" +sCnt) == 1 && GetPersistentInt(oPC, "Serveri" +sCnt) == nServer) //Found a stored corpse.
- {
- if(generate_corpse(oPC, nCnt, nServer) == FALSE)
- {
- WriteTimestampedLogEntry("Corpse create failed: "+sCnt);
- }
- else
- {
- WriteTimestampedLogEntry("Rebuilt Corpse Slot: "+sCnt);
- SetLocalInt(oPC, "ExCorpsF"+sCnt, 1);
- }
- }
- nCnt++;
- }
- }
- void main()
- {
- int STARTING_GOLD = 10000;
- object oPC = GetEnteringObject();
- object oMod = GetModule();
- object oWP = GetWaypointByTag("WP_AB_Portal69");
- int nCnt = 1;
- int nRingofDivine = 0;
- int nPlayerWand = 0;
- int nRingofUniversal = 0;
- string sTag;
- string sPCName = GetName(oPC);
- string sDBA = "pwhoservera";
- string sDBB = "pwhoserverb";
- if(!GetIsObjectValid(oWP))
- SendMessageToAllDMs("ERROR! Can't find Waypoint: WP_AB_Portal69 in The Well of Eru!");
- int nServer = GetLocalInt(oWP, "SERVER");
- if (GetXP(oPC) < 6000)
- {
- GiveXPToCreature(oPC, 6001 - GetXP(oPC));
- }
- if(GetIsPC(oPC) && !(GetIsDM(oPC)))
- {
- //Hooks to keep players from reloging to gain spells and cheating!
- st_HideCheck(oPC);
- DelayCommand(0.5,st_SpellCheck(oPC));
- //Make sure the hide is valid before we set prop strings on it.
- DelayCommand(0.1, set_hide_props(oPC));
- if(GetLocalInt(oPC, "AUTOBOOT") == 1) //If a player gets set autoboot, they can't stay connected.
- { //This is to hold off whankers until I can add them to the banned list.
- DelayCommand(3.0, BootPC(oPC));
- }
- if(GetLocalInt(oWP, GetPCPublicCDKey(oPC)+"BANNED") == TRUE)
- {
- DelayCommand(3.0, BootPC(oPC));
- }
- // SpeakString("Post Hide Props: "+sPCName, TALKVOLUME_SHOUT);
- //New security function. Don't let player "hack" other players when the master server is down.
- object oHide = GetItemInSlot(INVENTORY_SLOT_CARMOUR, oPC);
- if(GetIsObjectValid(oHide))
- {
- string sCDcheck = GetLocalString(oHide, "PERMPCKEY");
- if(sCDcheck != "")
- {
- if(sCDcheck != GetPCPublicCDKey(oPC) && checkdmcdkey(oPC) == FALSE)
- {
- SendMessageToPC(oPC, "ERROR! Your current CD key does NOT match the key set on this player. Disconnecting!");
- SendMessageToAllDMs("Player: " +GetName(oPC) +" cdkey does not match account: " + GetPCPlayerName(oPC));
- DelayCommand(5.0, BootPC(oPC));
- }
- }
- }
- // SpeakString("CD Check: "+sPCName, TALKVOLUME_SHOUT);
- DeleteLocalInt(oPC, "Tensortransf");
- // no_double_logins(nServer, oPC);
- // SpeakString("Post Double Login check disabled.", TALKVOLUME_SHOUT);
- //Log the player into the remote who database
- // if(nServer == 1)
- // SetPersistentString(oWP, GetPCPublicCDKey(oPC), GetName(oPC), 0, sDBA);
- // else if(nServer == 2)
- // SetPersistentString(oWP, GetPCPublicCDKey(oPC), GetName(oPC), 0, sDBB);
- // Giving PC its starting gold.
- if(GetGold(oPC) < STARTING_GOLD)
- GiveGoldToCreature(oPC, STARTING_GOLD - GetGold(oPC));
- // Set the Good Evil Factions
- if(GetAlignmentGoodEvil(oPC) == ALIGNMENT_GOOD)
- {
- AdjustReputation(oPC, GetObjectByTag("goodfaction"),100);
- AdjustReputation(oPC, GetObjectByTag("evilfaction"),-100);
- }
- if(GetAlignmentGoodEvil(oPC) == ALIGNMENT_EVIL)
- {
- AdjustReputation(oPC, GetObjectByTag("goodfaction"),-100);
- AdjustReputation(oPC, GetObjectByTag("evilfaction"),100);
- }
- ExecuteScript("zep_cr_nocheat", oPC);
- object oRing = GetItemInSlot(INVENTORY_SLOT_LEFTRING, oPC);
- if(GetIsObjectValid(oRing))
- {
- if(GetTag(oRing) == "RingofDevineIntervention")
- {
- nRingofDivine++;
- }
- }
- oRing = GetItemInSlot(INVENTORY_SLOT_RIGHTRING, oPC);
- if(GetIsObjectValid(oRing))
- {
- if(GetTag(oRing) == "RingofDevineIntervention")
- {
- nRingofDivine++;
- }
- if(nRingofDivine > 1)
- {
- DestroyObject(oRing);
- }
- }
- object oDeathAmulet = GetFirstItemInInventory(oPC);
- while( GetIsObjectValid(oDeathAmulet))
- {
- sTag = GetTag(oDeathAmulet);
- if(sTag == "RingofDevineIntervention")
- {
- nRingofDivine++;
- if(nRingofDivine > 1)
- DestroyObject(oDeathAmulet);
- }
- if(sTag == "EmoteWand")
- {
- nPlayerWand++;
- }
- oDeathAmulet = GetNextItemInInventory( oPC );
- }
- if(nRingofDivine == 0)
- {
- if(GetLocalString(oPC, "CHEATER") == "")
- {
- CreateItemOnObject("ringofdevineinte", oPC);
- }
- }
- if(nPlayerWand < 1)
- {
- CreateItemOnObject("Disabledemotewand", oPC, 1);
- }
- if(GetPersistentInt(oPC, "DeadOnServer"+IntToString(nServer)) == 1)
- {
- ApplyEffectToObject( DURATION_TYPE_INSTANT, EffectDeath( FALSE, FALSE ), oPC);
- }
- //Re-create any lost corpse since the last reset.
- do_corpse_recovery(oPC, nServer);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement