Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*********************************************************************
- Written by Dethia - 10/27/2010
- This script is part of the Faction vs. Faction system. It should be added
- to the "OnUse" event of the bell that must be activated to conquer a territory.
- It will set the faction owner equal to the faction of the player that used
- the bell.
- *********************************************************************/
- #include "nwnx_sql"
- #include "tl_factions_functions"
- void main()
- {
- object oBell = OBJECT_SELF;
- object oPC = GetLastUsedBy();
- //Get the town linked to the Bell
- string sTown = GetLocalString(GetLocalObject(oBell, "ParentSpawn"), "sTown");
- SendMessageToPC(oPC, "Town name is: " + sTown);
- if(GetIsDM(oPC) && GetLocalInt(oBell, "ACTIVATED"))
- {//If a DM clicks on an activated bell, deactivate it
- SetLocalInt(oBell, "ACTIVATED", FALSE);
- SendMessageToPC(oPC, "You have deactivated the bell.");
- return;
- }
- else if(GetIsDM(oPC) && !GetLocalInt(oBell, "ACTIVATED"))
- {//If a DM clicks on a deactivated bell, activate it for 10 minutes
- SetLocalInt(oBell, "ACTIVATED", TRUE);
- DelayCommand(600.0f, DeleteLocalInt(oBell, "ACTIVATED"));
- SendMessageToPC(oPC, "You have activated the bell.");
- return;
- }
- if(GetIsPC(oPC) && !GetIsDM(oPC) && GetLocalInt(oBell, "ACTIVATED"))
- {//If a player clicks on an activated bell give their faction control of territory
- object oLeader = GetFactionLeader(oPC); //Get the party leader
- string sPCFaction = IntToString(TL_GetPCFaction(oLeader)); //Get the faction
- string sAreaTag = GetTag(GetArea(oBell)); //Get the tag of the area
- //Give the party leader the tax key for that particular town
- object oKey = CreateItemOnObject("tax_chest_key_" +
- GetStringLowerCase(sTown), oLeader);
- //Inform the party leader that they have gained control of the area
- SendMessageToPC(oLeader, "You have gained control of this area.");
- //Update the tax chest table with the new information
- SQLExecDirect("select * from tax_chests where town = '" + sTown + "';");
- if(SQLFetch())
- {//If we have an entry for this town, update its data
- SQLExecDirect("update tax_chests set " +
- "faction_id = " + sPCFaction + ", " +
- "area_tag = '" + sAreaTag + "' where " +
- "town = '" + sTown + "';");
- }
- else //If there are no existing entries for this town, add 1
- {
- SQLExecDirect("insert into tax_chests (town, faction_id, area_tag) values " +
- "('" + sTown + "', " + sPCFaction + ", '" + sAreaTag + "');");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement