View Single Post
  #1  
Old 05-28-2011, 02:57 PM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Item Creation Script

This is a little script ive been working on, not much... Also, not completed yet so expect updates but this system allows you to create weapons to fight with people! It works with melee atm.
But you will have to script the hurting etc.
Here ya go

Weapon Creation Code:
PHP Code:
function onActionServerSide()
  {
  if (
params[0] == "Generate")
    {
    echo(
"[ITEM GENERATOR]: "@params[5]@" Created "@params[1]@" Which Does "@params[2]@" Damage, Gani = "@params[3]@"!");
    
findplayer(params[5]).clientr.weps.add(params[1]);
    
savelog2("logs/Items",params[5]@" Created "@params[1]@" That does "@params[2]@" Damage, with the Gani "@params[3]@" and a freeze of "@params[4]@"!");
    
ItemDB.GenerateItem(params[1], params[2], params[3], params[4], params[5]);
    }
  }
//#CLIENTSIDE
function onPlayerChats()
  {
  if (
player.chat == "/items")
    {
    
openGenerator();
    
player.chat "";
    }
  }
function 
openGenerator() {
  new 
GuiWindowCtrl("Generator_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "320,130";

    
canmove true;
    
canresize false;
    
closequery false;
    
canmaximize false;
    
canminimize false;
    
destroyonhide false;
    
text "Item Generator";
    
mousescreenx;
    
mousescreeny;

    new 
GuiTextEditCtrl("Generator_TextEdit1") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 80;
      
18;
      
19;
    }
    new 
GuiTextCtrl("Generator_Text1") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Name";
      
width 27;
      
42;
      
35;
    }
    new 
GuiTextEditCtrl("Generator_TextEdit2") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 80;
      
115;
      
19;
    }
    new 
GuiTextCtrl("Generator_Text2") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Damage";
      
width 39;
      
135;
      
34;
    }
    new 
GuiTextEditCtrl("Generator_TextEdit3") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 80;
      
216;
      
20;
    }
    new 
GuiTextEditCtrl("Generator_TextEdit4") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 80;
      
19;
      
55;
    }
    new 
GuiTextCtrl("Generator_Text4") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Freeze Time";
      
width 100;
      
28;
      
75;
    }
    new 
GuiTextCtrl("Generator_Text3") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Gani (without .gani)";
      
width 100;
      
210;
      
35;
    }
    new 
GuiButtonCtrl("Generator_Button1") {
      
profile GuiBlueButtonProfile;
      
height 34;
      
text "Generate Weapon";
      
width 320;
      
96;
    }
    
Generator_Window1.show();
  }
}

function 
Generator_Button1.onAction() {
  
temp.w_name Generator_TextEdit1.getText();
  
temp.dmg Generator_TextEdit2.getText();
  
temp.gani Generator_TextEdit3.getText();
  
temp.freeze Generator_TextEdit4.getText();
  
triggerserver("gui",this.name,"Generate",temp.w_name,temp.dmg,temp.gani,temp.freeze,player.account);
  
Generator_Window1.hide();
  
player.chat "Generated "@temp.w_name@"!";

Weapon Inventory:
PHP Code:
join("object_inventory");
function 
onActionServerSide()
  {
  if (
params[0] == "Equip")
    {
    
clientr.equipped params[1];
    }
  if (
params[0] == "getStats")
    {
    
temp.freeze ItemDB.("Item_"@params[1]@"_Freeze");
    
temp.ani ItemDB.("Item_"@params[1]@"_Gani");
    
temp.damage ItemDB.("Item_"@params[1]@"_Damage");
    
triggerclient("gui",this.name,"getStats",temp.ani,temp.damage,temp.freeze);
    }
  }
//#CLIENTSIDE
function onCreated()
  {
  
setTimer(.0051);
  }
function 
onTimeOut(timeid)
  {
    
selectedweapon NULL;
    
setTimer(.005);
    
player.chat "Time: "@params[0]@" ID: "@id;
  }
function 
onKeyPressed(codekeyscancode)
  {
  if (
key == "q")
    {
    if (
this.open == false)
      {
      
temp.wep getItems();
      
onOpenInv(temp.wep);
      
Inventory_Window.show();
      
this.open true;
      }
    else
      {
      
this.open false;
      
Inventory_Window.hide();
      }
    }
  if (
key == "d")
    {
      if (
findweapon("Test"))
        {
        
player.chat "!!! WEAPONS WORK !!!";
        
player.clientr.equipped.trigger"onWeaponFired""" );
        }
      else
        {
    
triggerserver("gui",this.name,"getStats",clientr.equipped);
    
temp.ani ItemDB.("Item_"@item@"_Gani");
    
setAni(this.gani,NULL);
    
UseItem(clientr.equipped);
    
triggeraction(player.1.5 vecx(player.dir) * 2player.vecy(player.dir) * 2"melee",player.account,this.dmg);
    
freezeplayer(this.freeze);
    }
  }
}
function 
onOpenInv(items) {
  new 
GuiWindowCtrl("Inventory_Window") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "320,300";

    
canmove true;
    
canresize false;
    
canclose false;
    
canminimize false;
    
canmaximize false;
    
closequery false;
    
destroyonhide false;
    
text "Inventory";
    
509;
    
203;

    new 
GuiButtonCtrl("Inventory_Button1") {
      
profile GuiBlueButtonProfile;
      
text "Close";
      
width 320;
      
270;
    }
    new 
GuiButtonCtrl("Inventory_Button2") {
      
profile GuiBlueButtonProfile;
      
height 31;
      
text "Equip Item";
      
width 320;
      
209;
    }
    new 
GuiButtonCtrl("Inventory_Button3") {
      
profile GuiBlueButtonProfile;
      
text "Drop Item";
      
width 320;
      
240;
    }
       new 
GuiScrollCtrl("Inventory_TextList_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 155;
      
hscrollbar "alwaysOff";
      
vscrollbar "dynamic";
      
width 320;
      
0;
      
0;

      new 
GuiTextListCtrl("Inventory_TextList") {
        
profile GuiBlueTextListProfile;
        
height 135;
        
horizsizing "width";
        
width 295;
        
clearrows();
        for (
temp.0temp.clientr.weps.size(); temp.++)
          {
          
addrow(temp.iclientr.weps[(@temp.i)]);
          }
        for (
temp.0temp.player.weapons.size(); temp.++)
          {
          if (!(
player.weapons[(@temp.e)].name.starts("-")))
            {
            
addrow(temp.temp.eplayer.weapons[(@temp.e)].name);
            }
          }
      }
    }
    
Inventory_Window.show();
  }
}

function 
getItems()
  {
  for (
clientr.weps temp.weps)
    {
    return 
temp.weps;
    }
  }
function 
Inventory_Button1.onAction() {
  
// Button "Close" has been pressed
}

function 
Inventory_Button2.onAction() {
temp.item Inventory_TextList.getSelectedText();
  
triggerserver("gui",this.name,"Equip",temp.item);
  }

function 
Inventory_Button3.onAction() {
  
// Button "Drop Item" has been pressed
}
function 
onActionClientSide()
  {
  if (
params[0] == "getStats")
    {
    
this.gani params[1];
    
this.dmg params[2];
    
this.freeze params[3];
    }
  } 
Class object_inventory:
PHP Code:
public function UseItem(item)
  {
    
temp.gani ItemDB.("Item_"@item@"_Gani");
    
setAni(temp.gani,NULL);
    
temp.dmg ItemDB.("Item_"@item@"_Damage");
    
triggeraction(player.1.5 vecx(player.dir) * 2player.vecy(player.dir) * 2"melee",player.account,item,temp.dmg);
  } 
HAVE FUN!!!
O, Say /items to open the generator =D!
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote