Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. /*********************************************************************
  2. Written by Dethia - 10/27/2010
  3.  
  4. This script is part of the Faction vs. Faction system. It should be added
  5. to the "OnUse" event of the bell that must be activated to conquer a territory.
  6. It will set the faction owner equal to the faction of the player that used
  7. the bell.
  8. *********************************************************************/
  9. #include "nwnx_sql"
  10. #include "tl_factions_functions"
  11.  
  12. void main()
  13. {
  14. object oBell = OBJECT_SELF;
  15. object oPC = GetLastUsedBy();
  16. //Get the town linked to the Bell
  17. string sTown = GetLocalString(GetLocalObject(oBell, "ParentSpawn"), "sTown");
  18.  
  19. SendMessageToPC(oPC, "Town name is: " + sTown);
  20. if(GetIsDM(oPC) && GetLocalInt(oBell, "ACTIVATED"))
  21. {//If a DM clicks on an activated bell, deactivate it
  22. SetLocalInt(oBell, "ACTIVATED", FALSE);
  23. SendMessageToPC(oPC, "You have deactivated the bell.");
  24. return;
  25. }
  26. else if(GetIsDM(oPC) && !GetLocalInt(oBell, "ACTIVATED"))
  27. {//If a DM clicks on a deactivated bell, activate it for 10 minutes
  28. SetLocalInt(oBell, "ACTIVATED", TRUE);
  29. DelayCommand(600.0f, DeleteLocalInt(oBell, "ACTIVATED"));
  30. SendMessageToPC(oPC, "You have activated the bell.");
  31. return;
  32. }
  33.  
  34. if(GetIsPC(oPC) && !GetIsDM(oPC) && GetLocalInt(oBell, "ACTIVATED"))
  35. {//If a player clicks on an activated bell give their faction control of territory
  36. object oLeader = GetFactionLeader(oPC); //Get the party leader
  37. string sPCFaction = IntToString(TL_GetPCFaction(oLeader)); //Get the faction
  38. string sAreaTag = GetTag(GetArea(oBell)); //Get the tag of the area
  39.  
  40. //Give the party leader the tax key for that particular town
  41. object oKey = CreateItemOnObject("tax_chest_key_" +
  42. GetStringLowerCase(sTown), oLeader);
  43. //Inform the party leader that they have gained control of the area
  44. SendMessageToPC(oLeader, "You have gained control of this area.");
  45.  
  46. //Update the tax chest table with the new information
  47. SQLExecDirect("select * from tax_chests where town = '" + sTown + "';");
  48. if(SQLFetch())
  49. {//If we have an entry for this town, update its data
  50. SQLExecDirect("update tax_chests set " +
  51. "faction_id = " + sPCFaction + ", " +
  52. "area_tag = '" + sAreaTag + "' where " +
  53. "town = '" + sTown + "';");
  54. }
  55. else //If there are no existing entries for this town, add 1
  56. {
  57. SQLExecDirect("insert into tax_chests (town, faction_id, area_tag) values " +
  58. "('" + sTown + "', " + sPCFaction + ", '" + sAreaTag + "');");
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement