PHP Code:
//Scripted by Joe (Les Frenchies)
function isStaff(account) {
return serveroptions.staff.tokenize(",").index(@ account) > (- 1);
}
function onActionServerSide(){
if (params[0] == "check")
{
if(!isStaff(player.account))
{
findplayer(player.account).removeweapon(this.name);
echo("StaffTools:" @ player.nick @ "(" @ player.communityname @ "(" @ player.account @ ")) tried to use Staff Tools,but his not staff.");
}
else{
//Create Tools Array
//(toolId, toolName, toolWeapon, toolHint, toolRank) -> You can add your own staff tools by creating the rights weapons
temp.arrayStaffTools = {
{0,"default","Staff/Tools","Open/Close Staff Tools",1},
{1,"boots","Staff/StaffBoots","Boots",1},
{2,"typewriter","Staff/StaffTypeWritter","TypeWriter",1},
{3,"stealth","Staff/StaffStealth","Stealth",1},
{4,"drag","Staff/StaffDrag","Drag",1},
{5,"staffstick","Staff/StaffStick","Staff Stick",1},
{6,"punish","Staff/StaffPunish","Punish",1},
{7,"leveleditor","Staff/StaffTileEditor","Tile Editor",6},
{8,"staffcmd","Staff/StaffCmd","Staff Commands",1},
{9,"staffnpceditor","Staff/StaffNPCEditor","Staff Npc Editor",8}
};
temp.getWeaponsGave = {};
for (temp.i = 0; i < temp.arrayStaffTools.size(); i++)
{
if(arrayStaffTools[i][4] =< player.clientr.staffRank){
player.addweapon(arrayStaffTools[i][2]);
temp.getWeaponsGave.add(arrayStaffTools[i][2]);
}else{
player.removeweapon(arrayStaffTools[i][2]);
}
}
echo("StaffTools:" @ player.account @ " get: " @ temp.getWeaponsGave);
}
}
if(params[0] == "setStaffParams"){
if(isStaff(player.account))
{
if(player.guild == "Events Team"){
player.ap = 100;
}
else{
if(player.clientr.staffGuild == 0){
clientr.staffGuild = "Staff";
}
player.guild = clientr.staffGuild;
player.ap = 100;
}
}
}
if(params[0] == "unsetStaffParams"){
if(player.guild == "Events Team"){
player.ap = random(1,99);
}
else{
player.guild = "";
player.ap = random(1,99);
}
}
}
//#CLIENTSIDE
function onCreated()
{
//Checking if player is Staff
triggerserver("weapon", this.name,"check");
//Basics Variables
this.equipweapon = false;
//Create Tools Array
//(toolId, toolName, toolWeapon, toolHint, toolRank)
this.buttonArray = {
{0,"default","Staff/Tools","Open/Close Staff Tools",1},
{1,"boots","Staff/StaffBoots","Boots",1},
{2,"typewriter","Staff/StaffTypeWritter","TypeWriter",1},
{3,"stealth","Staff/StaffStealth","Stealth",1},
{4,"drag","Staff/StaffDrag","Drag",1},
{5,"staffstick","Staff/Stick","Staff Stick",1},
{6,"punish","Staff/StaffPunish","Punish",1},
{7,"leveleditor","Staff/StaffTileEditor","Tile Editor",6}
};
//Create GUI
createStaffToolsWindow(this.buttonArray);
}
function createStaffToolsWindow(buttonArrayTabs){
//Basics Variables
temp.staffToolX = screenwidth - 60;
temp.staffToolY = 20;
for (temp.i = 0; i < buttonArrayTabs.size(); i++)
{
if(buttonArrayTabs[i][4] =< player.clientr.staffRank)
{
new GuiBitmapButtonCtrl("StaffToolsW_Button_" @ temp.i) {
x = temp.staffToolX;
y = temp.staffToolY;
width = height = 44;
normalbitmap = "stafftools-button-" @ buttonArrayTabs[i][1] @ "-off.png";
mouseoverbitmap = "stafftools-button-" @ buttonArrayTabs[i][1] @ "-hover.png";
pressedbitmap = "stafftools-button-" @ buttonArrayTabs[i][1] @ "-on.png";
hint = buttonArrayTabs[i][3];
alpha = .85;
this.getId = buttonArrayTabs[i][0];
this.getName = buttonArrayTabs[i][1];
this.getWeapon = buttonArrayTabs[i][2];
this.toolOpen = false;
thiso.catchevent(this, "onAction", "onStaffToolsButtonAction");
if(buttonArrayTabs[i][1] == "boots"){
new GuiMLTextCtrl("StaffTools_Button_Boots_Text") {
useownprofile = true;
profile.fontColor = "255 255 255";
profile.fontSize = 14;
x = 28;
y = 3;
text = "";
this.show();
}
}
//Hide all Button, not the first
if(temp.i > 0){
this.hide();
}
else{
this.show();
}
}
//Increment y
temp.staffToolY += 50;
}
}
}
function onKeyPressed(code,key) {
if (key == "t")
{
temp.ButtonDefault = new GuiBitmapButtonCtrl("StaffToolsW_Button_" @ this.buttonArray[0][0]);
onStaffToolsButtonAction(temp.ButtonDefault);
}
}
public function onStaffToolsButtonAction(obj)
{
for (temp.i = 0; i < this.buttonArray.size(); i++)
{
if(this.buttonArray[i][0] == obj.getID)
{
if((@ obj.getWeapon).isOpenTool()){
obj.normalbitmap = "stafftools-button-" @ obj.getName @ "-off.png";
obj.mouseoverbitmap = "stafftools-button-" @ obj.getName @ "-hover.png";
obj.pressedbitmap = "stafftools-button-" @ obj.getName @ "-on.png";
player.chat = obj.getName SPC ": Off";
if((@ obj.getWeapon) == this.name)
{
for (temp.e = 1; e < this.buttonArray.size(); e++){
temp.Window = new GuiBitmapButtonCtrl("StaffToolsW_Button_" @ temp.e);
temp.Window.hide();
}
}
(@ obj.getWeapon).closeTool();
}
else{
if(obj.getName != "punish")
{
obj.normalbitmap = "stafftools-button-" @ obj.getName @ "-on.png";
obj.mouseoverbitmap = "stafftools-button-" @ obj.getName @ "-on.png";
obj.pressedbitmap = "stafftools-button-" @ obj.getName @ "-off.png";
}
player.chat = obj.getName SPC ": On";
if((@ obj.getWeapon) == this.name)
{
for (temp.e = 1; e < this.buttonArray.size(); e++){
temp.Window = new GuiBitmapButtonCtrl("StaffToolsW_Button_" @ temp.e);
temp.Window.show();
}
}
(@ obj.getWeapon).openTool();
}
}
}
}
public function closeTool() {
this.equipweapon = false;
triggerserver("weapon", this.name,"unsetStaffParams");
//this.onCreated();
}
public function openTool() {
this.equipweapon = true;
triggerserver("weapon", this.name,"setStaffParams");
}
public function isOpenTool() {
if(this.equipweapon == true){
return true;
}
else{
return false;
}
}
Well, now to add your tools you need to create the weapons with the right toolName. For example, if I create the weapon: Staff/StaffBoots, I will also need to add few functions to make it working fine. I will have to add 3 functions on each staff tools weapon I create: