Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Sign drop / Staff Block (https://forums.graalonline.com/forums/showthread.php?t=71480)

Twinny 01-15-2007 07:41 PM

Sign drop / Staff Block
 
Quick weapon I made for Ducati. I figured someone might like it / use it ^^.

This goes in a weapon
PHP Code:

// Twinny's sign dropper
function onActionServerSide()
{
  if (
params[0] == "layblock")
  {
    
temp.npc putnpc2(params[1], params[2], "join(\"staffsign\");");
    
temp.npc.owner player.account;
  }
}    

//#CLIENTSIDE
function onCreated()
  
setTimer(0.05);

function 
onKeyPressed(num1codenum2)
{
  if (
code == "b")
    
this.block = !this.block;  //Toggles on and off
}

function 
onTimeout()
{
  if (
this.block)
    
showimg(1"block.png"mousexmousey);
  else
    
hideimg(1);
  
setTimer(0.05);
}

function 
onMouseDown(mode)
{
    if (
mode == "left")
    {
      if (
this.block)    
        
triggerserver("gui"this.name"layblock"mousexmousey);
    }
    else if (
mode == "double")
      
triggeraction(mousexmousey"SetMsg"player.chat);
    else if (
mode == "right")
      
triggeraction(mousexmousey"KillSign""");


and this goes in a class named staffsign
PHP Code:

function onCreated()
{
  
setimg("block.png"); //Replace with what you want
  
this.chat "Placed by "@this.owner;
  
sleep(2);
  
this.chat "";
}

function 
onActionSetMsg(msg)
  
this.chat msg;

function 
onActionKillSign()
  
destroy(); 

Pretty straight forward. To turn it on, press b. While it is on, left click somewhere to drop a sign / staffblock. To set a message, say something then double click the dropped sign/block to set its text. right click to destroy it. The weapon doesn't need to be on to set a message or destroy it.

Ducati_Link 01-15-2007 07:47 PM

Thanks alot, Twinny :)

Angel_Light 01-17-2007 04:03 AM

quite close to what mine is to mine :P
Mine just has extra functions and stuff

Twinny 01-17-2007 06:30 AM

Going to share or just state? >_<

maximus_asinus 01-17-2007 07:04 AM

Quote:

Originally Posted by Angel_Light (Post 1265712)
quite close to what mine is to mine :P
Mine just has extra functions and stuff

Mine, mine, mine.

Angel_Light 01-17-2007 08:17 AM

Quote:

Originally Posted by Twinny (Post 1265738)
Going to share or just state? >_<

sure why not.


Here's the weapon
PHP Code:

function onActionServerside()
{
  if (
params[0]=="summon")
  {
    
player.chat "Summoning!";
    
with(findplayer(@params[1])) {
      
setlevel2(params[2],params[3],params[4]);
      
player.chat "Summoned";
    }
    
player.chat "Summoned: " @params[1];
  }


  if(
params[0] == "placeblock")
  {
    
putnpc2(params[1], params[2], "join staffblock;");
    
temp.placcount player.account;
    
with(npcs[npcs.size()-1]) {
      
this.owner temp.placcount;
    }
  }

  if(
params[0] == "placeblock1")
  {
    
putnpc2(params[1], params[2], "join alertblock;");
    
temp.placcount player.account;
    
with(npcs[npcs.size()-1]) {
      
this.owner temp.placcount;
    }
  }

  if(
params[0] == "placeblock2")
  {
    
putnpc2(params[1], params[2], "join buildblock;");
    
temp.placcount player.account;
    
with(npcs[npcs.size()-1]) {
      
this.owner temp.placcount;
    }
  }

  switch(
params[0])
  {
    case 
"setnick":
      
player.nick params[1];
      break;
  }
}

//#CLIENTSIDE
function onCreated() {
  
initSTWind();
  
Staff_Powers_Main.visible false;
  
onTimeOut();
}

function 
onKeyPressed() {
  if (
params[0]=="49")
  {
    
Staff_Powers_Main.visible != Staff_Powers_Main.visible;
  }
}

function 
initSTWind() {
  new 
GuiWindowCtrl(Staff_Powers_Main) {
    
useownprofile true;
    
profile "GuiBlueWindowProfile";
    
canclose false;
    
canmove true;
    
canresize false;
    
extent = {200250};
    
canminimize true;
    
canmaximize false;
    
screenwidth-200;
    
0;
    
title true;
    
text "Staff Control";
    
profile.fontSize 14;
    
profile.fontColor "255 255 255";

    new 
GuiButtonCtrl(Staff_Powers_Close){
      
profile "GuiBlueButtonProfile";
      
text "Close";
      
extent "35 16";
      
position "7 227";
    };

    new 
GuiButtonCtrl(Staff_Powers_Block){
      
profile "GuiBlueButtonProfile";
      
text "Norm";
      
extent "32 32";
      
position "7 25";
    };

    new 
GuiButtonCtrl(Staff_Powers_Alert_Block){
      
profile "GuiBlueButtonProfile";
      
text "Alert";
      
extent "32 32";
      
position "41 25";
    };

    new 
GuiButtonCtrl(Staff_Powers_Build_Block) {
      
profile "GuiBlueButtonProfile";
      
text "Build";
      
extent "32 32";
      
position "75 25";
    };

    new 
GuiButtonCtrl(Staff_Powers_Summon){
      
profile "GuiBlueButtonProfile";
      
text "Summon";
      
extent "45 19";
      
position "7 59";
    };


    new 
GuiScrollCtrl(Staff_Powers_Scroll){
      
profile "GuiBlueScrollProfile";
      
hscrollbar "fixed";
      
vscrollbar "dynamic";
      
position "7 80";
      
extent "185 130";
      
scrollpos "2";
      
canMinimize "false";

      new 
GuiTextCtrl(Staff_Powers_Text) {
        
profile "GuiBlueTextProfile";
        
useownprofile true;
        
profile.fontSize 14;
        
profile.fontColor "255 255 255";
        
position "7 0";
        
text "~ Perform Action(s) too ~";
        
25;
        
0;
      };

      new 
GuiPopUpMenuCtrl(Staff_Powers_Acc_List) {
        
setstring"thiso.onlinelist"NULL);
        
clearrows();
        
profile "GuiBluePopUpMenuProfile";
        
textprofile "GuiBlueTextListProfile";
        
scrollprofile "GuiBlueScrollProfile";
        
text "Choose Player";
        
width 100;
        
height 24;
        
37;
        
45;
      for (
aallplayers)
        {
          if (!
a.starts("irc") && !a.starts("(npc") && player.level != 0)
          {
            
addstring"thiso.onlinelist", @a.account);
          }
        }
      for (
bthiso.onlinelist)
        {
          
Staff_Powers_Acc_List.addRow(0,b);
        }
      }
      
/*new GuiTextListCtrl("acclist"){
      setstring( "thiso.onlinelist", NULL);
      clearrows();
      profile = "GuiBlueTextListProfile";
      extent = "230 200";
      position = "5 25";
      profile.fontSize = 14;
      profile.fontColor = "0 0 0";
      for (a: allplayers){
      if (!a.starts("irc") && !a.starts("(npc") && player.level != 0){
      addstring( "thiso.onlinelist", @a.account);
    }
    }
      for (b: thiso.onlinelist){
      acclist.addRow(0,b);
    }
    }*/
    
}
  }
}

function 
Staff_Powers_Close.onAction(){
  
Staff_Powers_Main.visible false;;
}

function 
Staff_Powers_Block.onAction(){
  
effectnum 1;
  
this.block 0;
  
this.img1 "n-block.gif";
  
this.active = !this.active;
  if(
this.active)
  {
    
setTimer(0.05);
  }
}

function 
Staff_Powers_Alert_Block.onAction(){
  
effectnum 1;
  
this.block 1;
  
this.img1 "n-block2.gif";
  
this.active = !this.active;
  if(
this.active)
  {
    
setTimer(0.05);
  }
}

function 
Staff_Powers_Build_Block.onAction(){
  
effectnum 1;
  
this.block 2;
  
this.img1 "n-block3.gif";
  
this.active = !this.active;
  if(
this.active)
  {
    
setTimer(0.05);
  }
}

function 
Staff_Powers_Summon.onAction(){
  
triggerAction(0,0"serverside",this.name"summon",@ Staff_Powers_Acc_List.text,@player.level,@player.x,@player.y);
}


function 
onTimeout() {
  
setstring"thiso.onlinelist"NULL);
  
Staff_Powers_Acc_List.clearrows();
for (
aallplayers)
  {
    if (!
a.starts("irc") && !a.starts("(npc") && player.level != 0)
    {
      
addstring"thiso.onlinelist", @a.account);
    }
  }
for (
bthiso.onlinelist)
  {
    
Staff_Powers_Acc_List.addRow(0,b);
  }
  
setTimer(0.05);
  if(
this.active)
  {
    
showimg(200this.img1int(mousex), int(mousey));
    
setTimer(0.05);
  }
  else
  {
    
hideimg(200);
  }
}


function 
onMouseDown(buttons) {
  if(
this.active)
  {
    if(
buttons == "right")
    {
      
this.active false;
    }

    else if(
buttons == "left")
    {
      if (
this.block=="0")
      {
        
triggerserver("gui"this.name"placeblock"int(mousex), int(mousey));
      }
      else if (
this.block=="1")
      {
        
triggerserver("gui"this.name"placeblock1"int(mousex), int(mousey));
      }
      else if (
this.block=="2")
      {
        
triggerserver("gui"this.name"placeblock2"int(mousex), int(mousey));
      }
    }
  }


and the classes

staff block
PHP Code:

function onCreated() {
  
setimg("n-block.gif");
  
setShape(13232);
}

function 
onPlayerChats() {
  if(
player.account == this.owner || clientr.hstaff == "1") {
    if(
player.chat.starts("-destroy")) {
      
destroy();
    }
  }
}

function 
onActionDoubleMouse() {
  if (
player.account == this.owner || clientr.hstaff == "1") {
    
destroy();
  }
}

function 
onActionRightMouse() {
  
say2("Block Placed By: " NL this.owner);


Alert block
PHP Code:

function onCreated() {
  
setimg("n-block2.gif");
  
setShape(13232);
}

function 
onPlayerChats() {
  function 
onActionLeftMouse() {
    if (
player.chat.starts("-msg") && clientr.hstaff == "1") {
      
message(player.chat.substring(7,-1).trim());
    }
  }

  if(
player.account == this.owner || clientr.hstaff == "1") {
    if(
player.chat.starts("-destroy")) {
      
destroy();
    }
  }
}

function 
onActionDoubleMouse() {
  if (
player.account == this.owner || clientr.hstaff == "1") {
    
destroy();
  }
}

function 
onActionRightMouse() {
  
say2("Block Placed By: " NL this.owner);


and finally the build block
PHP Code:

function onCreated() {
  
setimg("n-block3.gif");
  
setShape(13232);
}

function 
onPlayerChats() {
  function 
onActionLeftMouse() {
    if (
player.chat.starts("-msg") && clientr.hstaff == "1") {
      
message(player.chat.substring(7,-1).trim());
    }
    
player.chat.tokenize();
      if (
token[0]=="-pmsg") {
        
with(findplayer(token[1])) {
          
sendPM("Warpto" this.x SPC this.y SPC this.level);
       }
     }
  }

  if(
player.account == this.owner || clientr.hstaff == "1") {
    if(
player.chat.starts("-destroy")) {
      
destroy();
    }
  }
}

function 
onActionDoubleMouse() {
  if (
player.account == this.owner || clientr.hstaff == "1") {
    
destroy();
  }
}

function 
onActionRightMouse() {
  
say2("Block Placed By: " NL this.owner);


Yeah I know I could make one class and make it quite smaller but that really isnt my focus now on Niromia. Plus this script is really old and I havent updated it in awhile so I woulnt be suprise if there were errors.. Oh and yes... Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine Mine!!!

bscharff 06-04-2007 10:36 PM

How do you get the keyboard key number for
PHP Code:

if (params[0]=="49"

Is there a chart with them listed?
How does yours work? (A GUI pops up and says _______)

Angel_Light 06-04-2007 10:41 PM

for key names I used
PHP Code:

function onKeyPressed() {
chat params0SPC "-" SPC params1]'


this will display KeyCode - KeyName

bscharff 06-04-2007 10:54 PM

How does yours work?

what is pressed to do what, what the different blocks do, etc.


Sorry, just trying to learn to script better. :P

Angel_Light 06-05-2007 12:45 AM

No prob, all blocks do the same thing just different images, I'll go into detail when I have more time later tonight

Gambet 06-05-2007 12:47 AM

Quote:

Originally Posted by bscharff (Post 1315112)
How do you get the keyboard key number for
PHP Code:

if (params[0]=="49"

Is there a chart with them listed?
How does yours work? (A GUI pops up and says _______)


PHP Code:

//#CLIENTSIDE
function onKeyPressed(code,key)
{
 
player.chat code;



Pimmeh 06-12-2007 10:27 AM

Im not sure....could you set in an account restriction?
So that the NPC is less likely to be abused?

Twinny 06-12-2007 11:39 AM

that's easy enough to add..one example
PHP Code:

  temp.accounts = {"Twinny","Skyld","Stefan"};
  if (
temp.accounts.index(player.account) == -1)
    return; 



All times are GMT +2. The time now is 08:36 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.