mirror of
https://bitbucket.org/seefoe/dsrc.git
synced 2026-07-31 01:15:55 -04:00
165 lines
3.8 KiB
Plaintext
165 lines
3.8 KiB
Plaintext
include library.utils;
|
|
include library.badge;
|
|
include java.util.StringTokenizer;
|
|
|
|
const string[] HELP_TEXT = { "------------------------------------",
|
|
"USAGE: \"areabadge <RANGE> <BADGENUMBER>\"",
|
|
"<RANGE>: Valid values are between 1 and 256",
|
|
"<BADGENUMBER>: Valid badges are between 1 and 124",
|
|
"------------------------------------"
|
|
};
|
|
|
|
trigger OnAttach()
|
|
{
|
|
|
|
if(!isPlayer(self))
|
|
detachScript(self, "event.area_badge");
|
|
|
|
if(!isGod(self))
|
|
{
|
|
detachScript(self, "event.area_badge");
|
|
sendSystemMessage(self, "You must be in God Mode for this script to take hold.", null);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(isGod(self))
|
|
{
|
|
int godLevel = getGodLevel(self);
|
|
if(godLevel < 5)
|
|
{
|
|
detachScript(self, "event.area_badge");
|
|
sendSystemMessage(self, "You do not have the appropriate access level to use this script.", null);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
sendSystemMessage(self, "USAGE: \"areabadge <RANGE> <BADGENUMBER>\". Say \"Help\" for usage and options.", null);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnLogin()
|
|
{
|
|
|
|
if(!isGod(self))
|
|
{
|
|
detachScript(self, "event.area_badge");
|
|
sendSystemMessage(self, "You must be in God Mode to use this script.", null);
|
|
}
|
|
|
|
if(isGod(self))
|
|
{
|
|
int godLevel = getGodLevel(self);
|
|
if(godLevel < 5)
|
|
{
|
|
detachScript(self, "event.area_badge");
|
|
sendSystemMessage(self, "You do not have the appropriate access level to use this script.", null);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
trigger OnHearSpeech(obj_id objSpeaker, string strText)
|
|
{
|
|
|
|
if(objSpeaker!=self)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(isGod(self))
|
|
{
|
|
int godLevel = getGodLevel(self);
|
|
if(godLevel < 5)
|
|
{
|
|
detachScript(self, "event.area_badge");
|
|
sendSystemMessage(self, "You do not have the appropriate access level to use this script.", null);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
if(!isGod(self))
|
|
{
|
|
detachScript(self, "event.area_badge");
|
|
sendSystemMessage(self, "You must be in God Mode to use this script.", null);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(toLower(strText).startsWith("areabadge"))
|
|
{
|
|
|
|
float badgeRange;
|
|
int badgeNumber;
|
|
|
|
StringTokenizer st = new StringTokenizer(strText);
|
|
|
|
if(st.countTokens() == 3)
|
|
{
|
|
|
|
string command = st.nextToken();
|
|
string badgeRangeStr = st.nextToken();
|
|
string badgeNumberStr = st.nextToken();
|
|
|
|
int badgeRangeInt = utils.stringToInt(badgeRangeStr);
|
|
badgeNumber = utils.stringToInt(badgeNumberStr);
|
|
badgeRange = (float)badgeRangeInt;
|
|
|
|
if(badgeRange > 256 || badgeRange < 1)
|
|
{
|
|
sendSystemMessage(self, "Error: Specify a range between 1 and 256.", null);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(badgeNumber < 1 || badgeNumber > 124)
|
|
{
|
|
sendSystemMessage(self, "Error: Please specify a valid badge number between 1 and 124.", null);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
string badgeName = getCollectionSlotName(badgeNumber);
|
|
if((badgeName == null) || (badgeName.length() == 0))
|
|
{
|
|
sendSystemMessage(self, "Error: badge number " + badgeNumber + " is not a valid badge.", null);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
obj_id[] objPlayers = getPlayerCreaturesInRange(self, badgeRange);
|
|
|
|
if (objPlayers != null && objPlayers.length>0)
|
|
{
|
|
for(int i = 0; i < objPlayers.length; i++)
|
|
{
|
|
if(objPlayers[i] != self)
|
|
{
|
|
badge.grantBadge(objPlayers[i], badgeName);
|
|
string playerName = getName(objPlayers[i]);
|
|
sendSystemMessage(self, "Granting badge " + badgeNumber + " to player " + playerName, null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if(toLower(strText).equals("detach"))
|
|
{
|
|
detachScript(self, "event.area_badge");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(toLower(strText).equals("help"))
|
|
{
|
|
|
|
for(int i = 0; i < HELP_TEXT.length; i++)
|
|
{
|
|
sendSystemMessage(self, HELP_TEXT[i], null);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}// onHearSpeech |