Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Equip/Unequip Weapons (https://forums.graalonline.com/forums/showthread.php?t=134260572)

iSlayer 09-19-2010 02:02 PM

Equip/Unequip Weapons
 
Nearly ready for release, but my server can't be released without the option to equip/unequip, I gave it a shot but I press D, it switchs to punch, i punch then i press S again and the player attacks with an invisible sword??

Weapons/Test D Unequip
PHP Code:

thiso.weapontabs = {"Weapons"};
this.image "pa_mud-maceofthedead.png";   

function 
onActionServerside(option) {
  if (
temp.option == "onAttack") {
  
  
player.doAttack("Sword"62player.account);
}
 if (
temp.option == "equip") {
 
clientr.mudweapon this.name;
 echo(
"Weapon Equiped");
}
 if (
temp.option == "unequip") {
 
clientr.mudweapon "+Fists/Punch";
 echo(
"Weapon Unequiped");
}
}
//#CLIENTSIDE
function GraalControl.onKeyDown(codekey) {
    if (
key == "s" && player.weapon == this && ! this.&& clientr.mudweapon != this.name) {
    
this.true;
    
player.attr[2] = "pa_mace-ofthedead.png";
    
triggerserver("gui"this.name"equip");
    }
    if (
key == "s" && player.weapon == this && ! this.&& clientr.mudweapon == this.name) {
    
this.onTimeOut();
    
this.true;
    }
    if (
key == "d" && player.weapon == this && ! this.&& clientr.mudweapon == this.name) {
     
triggerserver("gui"this.name"unequip");   
   }
  }
    
  function 
onTimeOut() {
  if (
player.weapon != this) {
    return;
  }
  
setani("pa_maceattack"""); 
  
freezeplayer(0.25); 
  
triggerserver("weapon"this.name"onAttack");
  
replaceani("pa_scythewalk","pa_macewalk");
  
replaceani("pa_scytheidle","pa_maceidle");
  
  
  if (
this.isAutomatic) {
    
this.setTimer(this.sleepTime);
  }
}

function 
GraalControl.onKeyUp(codekey) {
  if (
key == "s" && player.weapon == this && clientr.mudweapon == this.name) {
    
this.setTimer(0);
    
this.false;
  }


+Fists/Punch
PHP Code:

function onActionServerside(option) {
  if (
temp.option != "onAttack") return;
  
  
player.doAttack("Punch"11);
}

//#CLIENTSIDE

function GraalControl.onKeyDown(codekey) {
  if (
key == "s" && ! this.&& clientr.mudweapon == this) {
    
this.onTimeOut();
    
this.true;
    
player.attr[2] = "";
  }
}

function 
onTimeOut() {
  
setani("pa_punch"""); 
  
freezeplayer(0.25); 
  
triggerserver("weapon"this.name"onAttack");
  
  
  if (
this.isAutomatic) {
    
this.setTimer(this.sleepTime);
  }
}

function 
GraalControl.onKeyUp(codekey) {
  if (
key == "s" && clientr.mudweapon == this) {
    
this.setTimer(0);
    
this.false;
  }



Cubical 09-20-2010 12:21 AM

Not that it makes much difference but using a switch would be much cleaner. Zero(Zokemon) made a post about it a while back. I'm browsing from my phone or I'd find the post for you.

fowlplay4 09-20-2010 04:23 AM

That sucks that your script doesn't work properly maybe you should try and debug it.

or

Re-design your script to use 1 Weapon-NPC to handle shooting + fists, and have other weapons store configuration/statistical information and call generic methods in the weapon system like equip, unequip, and attack and use player.selectedweapon to process the actions accordingly.

iSlayer 09-20-2010 05:34 AM

i HOPE ive found the problem, it never changes player.weapon how can i do that?

iSlayer 09-20-2010 05:39 AM

selectedweapon = str; clientside?

fowlplay4 09-20-2010 05:39 AM

Quote:

Originally Posted by iSlayer (Post 1601589)
selectedweapon = str; clientside?

Script help for 'selectedweapon':
Clientside:
selectedweapon - integer

selectedweapon = player.weapons.index(findweapon("WeaponName"));

iSlayer 09-20-2010 05:46 AM

err this is why i liked commands.rtf, is it like selectedweapon = "bomb"; ?

iSlayer 09-20-2010 07:02 AM

Got it XD

PHP Code:

thiso.weapontabs = {"Weapons"};
this.image "pa_mud-maceofthedead.png";   

function 
onActionServerside(option) {
  if (
temp.option == "onAttack") {
  
  
player.doAttack("Sword"62player.account);
}
  if (
temp.option == "Punch") {
   
player.doAttack("Punch"31player.account);
 }
}
//#CLIENTSIDE
function GraalControl.onKeyDown(codekey) {
    if (
key == "d" && this.equip == false && player.weapon == this.name) {
    
this.equip true;
    
player.attr[2] = "pa_mace-ofthedead.png";
    
replaceani("pa_scythewalk","pa_macewalk");
    
replaceani("pa_scytheidle","pa_maceidle");
    return;
    }
    if (
key == "s" && this.equip == true && player.weapon == this.name) {
    
this.onTimeout();
    return;
   }
    if (
key == "d" && this.equip == true && player.weapon == this) {
     
player.attr[2] = "";
     
this.equip false;
     return;
      }  
    if (
key == "s" && this.equip == false && player.weapon == this) {
    
triggerserver("weapon"this.name"onPunch");
    
setani("pa_punch""");
    
freezeplayer(0.25);
    
triggerserver("weapon"this.name"onPunch");
    }
   } 
    
  function 
onTimeOut() {
  if (
player.weapon != this) {
    return;
  }
  
setani("pa_maceattack"""); 
  
freezeplayer(0.25); 
  
triggerserver("weapon"this.name"onAttack");




All times are GMT +2. The time now is 05:24 AM.

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