Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-19-2010, 02:02 PM
iSlayer iSlayer is offline
Snk for manager
iSlayer's Avatar
Join Date: Feb 2010
Location: Room 7, Era Hotel, Era
Posts: 202
iSlayer will become famous soon enough
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;
  }

__________________
Snk for manager




Quote:
Originally Posted by Admins View Post
Snk for manager of Era
Reply With Quote
  #2  
Old 09-20-2010, 12:21 AM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
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.
Reply With Quote
  #3  
Old 09-20-2010, 04:23 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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.
__________________
Quote:
Reply With Quote
  #4  
Old 09-20-2010, 05:34 AM
iSlayer iSlayer is offline
Snk for manager
iSlayer's Avatar
Join Date: Feb 2010
Location: Room 7, Era Hotel, Era
Posts: 202
iSlayer will become famous soon enough
i HOPE ive found the problem, it never changes player.weapon how can i do that?
__________________
Snk for manager




Quote:
Originally Posted by Admins View Post
Snk for manager of Era
Reply With Quote
  #5  
Old 09-20-2010, 05:39 AM
iSlayer iSlayer is offline
Snk for manager
iSlayer's Avatar
Join Date: Feb 2010
Location: Room 7, Era Hotel, Era
Posts: 202
iSlayer will become famous soon enough
selectedweapon = str; clientside?
__________________
Snk for manager




Quote:
Originally Posted by Admins View Post
Snk for manager of Era
Reply With Quote
  #6  
Old 09-20-2010, 05:39 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by iSlayer View Post
selectedweapon = str; clientside?
Script help for 'selectedweapon':
Clientside:
selectedweapon - integer

selectedweapon = player.weapons.index(findweapon("WeaponName"));
__________________
Quote:
Reply With Quote
  #7  
Old 09-20-2010, 05:46 AM
iSlayer iSlayer is offline
Snk for manager
iSlayer's Avatar
Join Date: Feb 2010
Location: Room 7, Era Hotel, Era
Posts: 202
iSlayer will become famous soon enough
err this is why i liked commands.rtf, is it like selectedweapon = "bomb"; ?
__________________
Snk for manager




Quote:
Originally Posted by Admins View Post
Snk for manager of Era
Reply With Quote
  #8  
Old 09-20-2010, 07:02 AM
iSlayer iSlayer is offline
Snk for manager
iSlayer's Avatar
Join Date: Feb 2010
Location: Room 7, Era Hotel, Era
Posts: 202
iSlayer will become famous soon enough
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");

__________________
Snk for manager




Quote:
Originally Posted by Admins View Post
Snk for manager of Era
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 10:48 PM.


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