Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-15-2007, 07:41 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
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.
Reply With Quote
  #2  
Old 01-15-2007, 07:47 PM
Ducati_Link Ducati_Link is offline
Banned
Ducati_Link's Avatar
Join Date: Oct 2001
Location: Perth, Australia
Posts: 415
Ducati_Link is on a distinguished road
Send a message via MSN to Ducati_Link
Thanks alot, Twinny
Reply With Quote
  #3  
Old 01-17-2007, 04:03 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
quite close to what mine is to mine :P
Mine just has extra functions and stuff
__________________
Deep into the Darkness peering...
Reply With Quote
  #4  
Old 01-17-2007, 06:30 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Going to share or just state?
Reply With Quote
  #5  
Old 01-17-2007, 07:04 AM
maximus_asinus maximus_asinus is offline
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,746
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
Quote:
Originally Posted by Angel_Light View Post
quite close to what mine is to mine :P
Mine just has extra functions and stuff
Mine, mine, mine.
__________________
Save Classic!
Reply With Quote
  #6  
Old 01-17-2007, 08:17 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Quote:
Originally Posted by Twinny View Post
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!!!
__________________
Deep into the Darkness peering...
Reply With Quote
  #7  
Old 06-04-2007, 10:36 PM
bscharff bscharff is offline
Bloo
bscharff's Avatar
Join Date: Sep 2006
Location: San Antonio, Texas
Posts: 185
bscharff has a little shameless behaviour in the past
Send a message via AIM to bscharff Send a message via MSN to bscharff Send a message via Yahoo to bscharff
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 _______)
Reply With Quote
  #8  
Old 06-04-2007, 10:41 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
for key names I used
PHP Code:
function onKeyPressed() {
chat params0SPC "-" SPC params1]'

this will display KeyCode - KeyName
__________________
Deep into the Darkness peering...
Reply With Quote
  #9  
Old 06-04-2007, 10:54 PM
bscharff bscharff is offline
Bloo
bscharff's Avatar
Join Date: Sep 2006
Location: San Antonio, Texas
Posts: 185
bscharff has a little shameless behaviour in the past
Send a message via AIM to bscharff Send a message via MSN to bscharff Send a message via Yahoo to bscharff
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
Reply With Quote
  #10  
Old 06-05-2007, 12:45 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
No prob, all blocks do the same thing just different images, I'll go into detail when I have more time later tonight
__________________
Deep into the Darkness peering...
Reply With Quote
  #11  
Old 06-05-2007, 12:47 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by bscharff View Post
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;

Reply With Quote
  #12  
Old 06-12-2007, 10:27 AM
Pimmeh Pimmeh is offline
Rgesitreed Uesr
Pimmeh's Avatar
Join Date: May 2007
Location: Utrecht, the Netherlands
Posts: 1,586
Pimmeh has a spectacular aura about
Send a message via AIM to Pimmeh Send a message via MSN to Pimmeh
Im not sure....could you set in an account restriction?
So that the NPC is less likely to be abused?
__________________
Oh, Death,
No wealth, no ruin, no silver, no gold
Nothing satisfies me but your soul
Reply With Quote
  #13  
Old 06-12-2007, 11:39 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
that's easy enough to add..one example
PHP Code:
  temp.accounts = {"Twinny","Skyld","Stefan"};
  if (
temp.accounts.index(player.account) == -1)
    return; 

Last edited by Twinny; 06-12-2007 at 12:03 PM..
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:45 PM.


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