Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.99 KB | None | 0 0
  1. #include "nw_i0_tool"
  2. #include "st_inc"
  3. #include "aps_include"
  4. #include "zep_inc_craft"
  5. #include "check_cdkey_inc"
  6.  
  7. void no_double_logins(int nServer, object oPC)
  8. {
  9. string sTemp;
  10. string sName = GetName(oPC);
  11.  
  12. if(nServer == 1)
  13. {
  14. SQLExecDirect("SELECT val FROM pwhoserverb");
  15. }
  16.  
  17. if(nServer == 2)
  18. {
  19. SQLExecDirect("SELECT val FROM pwhoservera");
  20. }
  21.  
  22. if(nServer > 2)
  23. return;
  24.  
  25. int nLoop = SQLFetch();
  26.  
  27. if(nLoop == SQL_ERROR)
  28. {
  29. //The other server could be booting.
  30. //SendMessageToAllDMs("Error. Empty WHO SQL database!");
  31. return;
  32. }
  33.  
  34. while(nLoop == SQL_SUCCESS)
  35. {
  36. sTemp = SQLGetData(1);
  37.  
  38. if(sTemp == sName)
  39. {
  40. SendMessageToPC(oPC, "ERROR! You can not log into both servers with the same character. Disconnecting!");
  41. SendMessageToAllDMs("Player: " +GetName(oPC) +" logged into BOTH servers with account: " + GetPCPlayerName(oPC));
  42. DelayCommand(7.0, BootPC(oPC));
  43. return;
  44. }
  45.  
  46. nLoop = SQLFetch();
  47. }
  48. }
  49.  
  50. void nuke_item_props(object oPC, string sCorpse, int nServer)
  51. {
  52. string sDB = GetPCPublicCDKey(oPC)+IntToString(nServer);
  53. DeleteCampaignVariable(sDB, "CorpseItem"+sCorpse, oPC);
  54. WriteTimestampedLogEntry("Delete Bioware DB entry for: " + sDB + " slot: " + sCorpse);
  55. }
  56.  
  57. void clean_slot(object oPC, string sCorpse, int nServer)
  58. {
  59. DeletePersistentVariable(oPC, "ItemAs" + sCorpse);
  60. DeletePersistentVariable(oPC, "ItemBs" + sCorpse);
  61. DeletePersistentVariable(oPC, "ItemLs" + sCorpse);
  62. DeletePersistentVariable(oPC, "CorpseSlot" +sCorpse);
  63. DeletePersistentVariable(oPC, "Serveri" +sCorpse);
  64. DeletePersistentVariable(oPC, "CorpseSlotTS" +sCorpse);
  65. DeleteLocalInt(oPC, "ExCorpsF" +sCorpse);
  66. nuke_item_props(oPC, sCorpse, nServer);
  67. }
  68.  
  69. int generate_corpse(object oPC, int nI, int nServer)
  70. {
  71. object oMyItem;
  72. string sArea = GetPersistentString(oPC, "ItemAs" + IntToString(nI)); //The Area Tag where they died.
  73. string sCnt = IntToString(nI);
  74.  
  75. object oArea = GetObjectByTag(sArea);
  76. if(!GetIsObjectValid(oArea))
  77. {
  78. WriteTimestampedLogEntry("Invalid Area Tag in On Connect gen_corpse: "+sArea);
  79. clean_slot(oPC, sCnt, nServer);
  80. return FALSE; //This should never happen but it does. Bad code, BAD Code!
  81. }
  82.  
  83. string sItem = GetPersistentString(oPC, "ItemBs" + sCnt); //Item lost when they died.
  84. location lLoc = GetPersistentLocation(oPC, "ItemLs" + sCnt); //Location in area where they died.
  85.  
  86. WriteTimestampedLogEntry("Restoring Item: "+sItem);
  87.  
  88. object oNewCorpse = CreateObject(OBJECT_TYPE_PLACEABLE, "pccorpse", lLoc); //New Corpse
  89. if(!GetIsObjectValid(oNewCorpse))
  90. {
  91. WriteTimestampedLogEntry("WARNING! Could not regenerate player corpse: " + GetPCPlayerName(oPC) + " Number: " +sCnt);
  92. clean_slot(oPC, sCnt, nServer);
  93. return FALSE;
  94. }
  95.  
  96. /*
  97. string sBodyLock = GetPersistentString(oPC, "PCHARNAME" + sCnt);
  98. if(sBodyLock == "")
  99. {
  100. string sCharName = GetName(oPC);
  101. WriteTimestampedLogEntry("WARNING! Character name not set for: " + sCharName + " Number: " +sCnt);
  102. sBodyLock = sCharName;
  103. }
  104. */
  105. string sBodyLock = GetName(oPC); //Replaced function above w/ a simple getname()
  106.  
  107. SetLocalString(oNewCorpse, "sOwner", GetPCPlayerName(oPC)); //Who owns it.
  108. SetLocalString(oNewCorpse, "sPCName", sBodyLock); //Who owns it.
  109. SetLocalInt(oNewCorpse, "CorpseNumber", nI); //Corpse Number
  110.  
  111. //We try to restore the item from NWN database first in case it has customized props. IF that fails, restore using the blueprint.
  112. oMyItem = RetrieveCampaignObject(GetPCPublicCDKey(oPC)+IntToString(nServer), "CorpseItem"+sCnt, GetLocation(oNewCorpse), oNewCorpse, oPC);
  113. if(GetIsObjectValid(oMyItem))
  114. {
  115. WriteTimestampedLogEntry("Regenerated player item: " + sItem + " for: " + GetPCPlayerName(oPC)+ " from NWN database. Slot: " +sCnt);
  116. return TRUE;
  117. }
  118. else
  119. {
  120. WriteTimestampedLogEntry("WARNING! Could not regenerate player item: " + sItem + " for: " + GetPCPlayerName(oPC)+ " from NWN database. Slot: " +sCnt);
  121. oMyItem = CreateItemOnObject(sItem, oNewCorpse);
  122. if(!GetIsObjectValid(oMyItem))
  123. {
  124. WriteTimestampedLogEntry("WARNING! Could not regenerate player item: " + sItem + " for: " + GetPCPlayerName(oPC)+ "from blueprint resref. Slot: " +sCnt);
  125. return FALSE;
  126. }
  127. else
  128. {
  129. SetIdentified(oMyItem, TRUE);
  130. return TRUE;
  131. }
  132. }
  133. return FALSE;
  134. }
  135.  
  136. void do_corpse_recovery(object oPC, int nServer) //Regenerate up to a max of 6 corpses per player when they log in.
  137. {
  138.  
  139. int nCnt = 1;
  140.  
  141. while(nCnt < 7)
  142. {
  143. string sCnt = IntToString(nCnt);
  144. WriteTimestampedLogEntry("Checking corpse slot: "+sCnt);
  145. if(GetLocalInt(oPC, "ExCorpsF"+sCnt) != 1 && GetPersistentInt(oPC, "CorpseSlot" +sCnt) == 1 && GetPersistentInt(oPC, "Serveri" +sCnt) == nServer) //Found a stored corpse.
  146. {
  147. if(generate_corpse(oPC, nCnt, nServer) == FALSE)
  148. {
  149. WriteTimestampedLogEntry("Corpse create failed: "+sCnt);
  150. }
  151. else
  152. {
  153. WriteTimestampedLogEntry("Rebuilt Corpse Slot: "+sCnt);
  154. SetLocalInt(oPC, "ExCorpsF"+sCnt, 1);
  155. }
  156. }
  157. nCnt++;
  158. }
  159. }
  160.  
  161. void main()
  162. {
  163. int STARTING_GOLD = 10000;
  164. object oPC = GetEnteringObject();
  165. object oMod = GetModule();
  166. object oWP = GetWaypointByTag("WP_AB_Portal69");
  167. int nCnt = 1;
  168. int nRingofDivine = 0;
  169. int nPlayerWand = 0;
  170. int nRingofUniversal = 0;
  171. string sTag;
  172. string sPCName = GetName(oPC);
  173.  
  174. string sDBA = "pwhoservera";
  175. string sDBB = "pwhoserverb";
  176.  
  177. if(!GetIsObjectValid(oWP))
  178. SendMessageToAllDMs("ERROR! Can't find Waypoint: WP_AB_Portal69 in The Well of Eru!");
  179.  
  180. int nServer = GetLocalInt(oWP, "SERVER");
  181.  
  182.  
  183. if (GetXP(oPC) < 6000)
  184. {
  185. GiveXPToCreature(oPC, 6001 - GetXP(oPC));
  186. }
  187.  
  188. if(GetIsPC(oPC) && !(GetIsDM(oPC)))
  189. {
  190. //Hooks to keep players from reloging to gain spells and cheating!
  191. st_HideCheck(oPC);
  192. DelayCommand(0.5,st_SpellCheck(oPC));
  193.  
  194. //Make sure the hide is valid before we set prop strings on it.
  195. DelayCommand(0.1, set_hide_props(oPC));
  196.  
  197. if(GetLocalInt(oPC, "AUTOBOOT") == 1) //If a player gets set autoboot, they can't stay connected.
  198. { //This is to hold off whankers until I can add them to the banned list.
  199. DelayCommand(3.0, BootPC(oPC));
  200. }
  201.  
  202. if(GetLocalInt(oWP, GetPCPublicCDKey(oPC)+"BANNED") == TRUE)
  203. {
  204. DelayCommand(3.0, BootPC(oPC));
  205. }
  206.  
  207. // SpeakString("Post Hide Props: "+sPCName, TALKVOLUME_SHOUT);
  208.  
  209. //New security function. Don't let player "hack" other players when the master server is down.
  210. object oHide = GetItemInSlot(INVENTORY_SLOT_CARMOUR, oPC);
  211. if(GetIsObjectValid(oHide))
  212. {
  213. string sCDcheck = GetLocalString(oHide, "PERMPCKEY");
  214. if(sCDcheck != "")
  215. {
  216. if(sCDcheck != GetPCPublicCDKey(oPC) && checkdmcdkey(oPC) == FALSE)
  217. {
  218. SendMessageToPC(oPC, "ERROR! Your current CD key does NOT match the key set on this player. Disconnecting!");
  219. SendMessageToAllDMs("Player: " +GetName(oPC) +" cdkey does not match account: " + GetPCPlayerName(oPC));
  220. DelayCommand(5.0, BootPC(oPC));
  221. }
  222. }
  223. }
  224.  
  225. // SpeakString("CD Check: "+sPCName, TALKVOLUME_SHOUT);
  226. DeleteLocalInt(oPC, "Tensortransf");
  227.  
  228. // no_double_logins(nServer, oPC);
  229.  
  230. // SpeakString("Post Double Login check disabled.", TALKVOLUME_SHOUT);
  231.  
  232. //Log the player into the remote who database
  233. // if(nServer == 1)
  234. // SetPersistentString(oWP, GetPCPublicCDKey(oPC), GetName(oPC), 0, sDBA);
  235. // else if(nServer == 2)
  236. // SetPersistentString(oWP, GetPCPublicCDKey(oPC), GetName(oPC), 0, sDBB);
  237.  
  238. // Giving PC its starting gold.
  239. if(GetGold(oPC) < STARTING_GOLD)
  240. GiveGoldToCreature(oPC, STARTING_GOLD - GetGold(oPC));
  241.  
  242. // Set the Good Evil Factions
  243. if(GetAlignmentGoodEvil(oPC) == ALIGNMENT_GOOD)
  244. {
  245. AdjustReputation(oPC, GetObjectByTag("goodfaction"),100);
  246. AdjustReputation(oPC, GetObjectByTag("evilfaction"),-100);
  247. }
  248.  
  249. if(GetAlignmentGoodEvil(oPC) == ALIGNMENT_EVIL)
  250. {
  251. AdjustReputation(oPC, GetObjectByTag("goodfaction"),-100);
  252. AdjustReputation(oPC, GetObjectByTag("evilfaction"),100);
  253. }
  254.  
  255. ExecuteScript("zep_cr_nocheat", oPC);
  256.  
  257. object oRing = GetItemInSlot(INVENTORY_SLOT_LEFTRING, oPC);
  258. if(GetIsObjectValid(oRing))
  259. {
  260. if(GetTag(oRing) == "RingofDevineIntervention")
  261. {
  262. nRingofDivine++;
  263. }
  264. }
  265.  
  266. oRing = GetItemInSlot(INVENTORY_SLOT_RIGHTRING, oPC);
  267. if(GetIsObjectValid(oRing))
  268. {
  269. if(GetTag(oRing) == "RingofDevineIntervention")
  270. {
  271. nRingofDivine++;
  272. }
  273.  
  274. if(nRingofDivine > 1)
  275. {
  276. DestroyObject(oRing);
  277. }
  278. }
  279.  
  280. object oDeathAmulet = GetFirstItemInInventory(oPC);
  281. while( GetIsObjectValid(oDeathAmulet))
  282. {
  283. sTag = GetTag(oDeathAmulet);
  284.  
  285. if(sTag == "RingofDevineIntervention")
  286. {
  287. nRingofDivine++;
  288.  
  289. if(nRingofDivine > 1)
  290. DestroyObject(oDeathAmulet);
  291. }
  292.  
  293. if(sTag == "EmoteWand")
  294. {
  295. nPlayerWand++;
  296. }
  297.  
  298. oDeathAmulet = GetNextItemInInventory( oPC );
  299. }
  300.  
  301. if(nRingofDivine == 0)
  302. {
  303. if(GetLocalString(oPC, "CHEATER") == "")
  304. {
  305. CreateItemOnObject("ringofdevineinte", oPC);
  306. }
  307. }
  308.  
  309. if(nPlayerWand < 1)
  310. {
  311. CreateItemOnObject("Disabledemotewand", oPC, 1);
  312. }
  313.  
  314. if(GetPersistentInt(oPC, "DeadOnServer"+IntToString(nServer)) == 1)
  315. {
  316. ApplyEffectToObject( DURATION_TYPE_INSTANT, EffectDeath( FALSE, FALSE ), oPC);
  317. }
  318.  
  319. //Re-create any lost corpse since the last reset.
  320. do_corpse_recovery(oPC, nServer);
  321. }
  322. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement