Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Shooting Glitch (https://forums.graalonline.com/forums/showthread.php?t=65261)

lordspawn 04-08-2006 11:23 PM

Shooting Glitch
 
Ok, this script is shooting the bullet then switching to a different NPC that you have, were not sure if its the shoot command like has it changed or if there is something else in the script thats bugging it to do this, so if anyone that knows whats happening please post your input >_<

PHP Code:

//#CLIENTSIDE
function onCreated(){
  
setani("idle""");
  
replaceani("idle""idle");
  
replaceani("walk""walk");
  
this.inuse "0";
}
function 
onWeaponfired(){
  if (!
this.inuse==1) {
    
setani("cross_pistol-idle""");
    
replaceani("idle""cross_pistol-idle");
    
replaceani("walk""cross_pistol-walk");
    
this.inuse=1;
  }
  if (
this.inuse==1) {
    
setani("cross_pistol-fire""");
    
this.angle "#v(getangle(vecx(playerdir),vecy(playerdir)))";
    
this.bulletangle "-.2";
    
this.random "random(this.bulletangle,abs(this.bulletangle))";
    
shoot ("playerx,playery,,this.angle+this.random,,,cross_pistol-bullets,");
    
freezeplayer(0.3);
    
sleep(0.7);
    
setani("cross_pistol-idle""");
  }
}
function 
onKeypressed(){
  if (
strequals(#p(1),a)&&this.inuse==1) {
    
setani("idle""");
    
replaceani("idle""idle");
    
replaceani("walk""walk");
    
this.inuse=0;
  }



Yen 04-09-2006 12:15 AM

You can't leave parameters blank.
Put in "", 0, or NULL for a blank parameter.

Yen 04-09-2006 12:17 AM

Oh, and I just noticed this:
this.angle = "#v(getangle(vecx(playerdir),vecy(playerdir))) ";

First of all, #v() is never used in GS2. NEVER.
Second, "" tells the script that something is text. That won't make this.angle the angle, it'll make this.angle the text that's there. Take out the #v() and the "". Same with this.random.

gamer4lifebitach 04-09-2006 12:26 AM

It still changes weapons.... (and i work with him)

PHP Code:

//#CLIENTSIDE
function onCreated(){
  
setani("idle""");
  
replaceani("idle""idle");
  
replaceani("walk""walk");
  
this.inuse "0";
}
function 
onWeaponfired(){
  if (!
this.inuse==1) {
    
setani("cross_pistol-idle""");
    
replaceani("idle""cross_pistol-idle");
    
replaceani("walk""cross_pistol-walk");
    
this.inuse=1;
  }
  if (
this.inuse==1) {
    
setani("cross_pistol-fire""");
    
this.angle getangle(vecx(playerdir),vecy(playerdir));
    
this.bulletangle = -.2;
    
shoot(playerx,playerx,0,this.angle+random(this.bulletangle,abs(this.bulletangle)),0,0,cross_pistol-bullets,0);
    
freezeplayer(0.3);
    
sleep(0.7);
    
setani("cross_pistol-idle""");
  }
}
function 
onKeypressed(){
  if (
strequals(#p(1),a)&&this.inuse==1) {
    
setani("idle""");
    
replaceani("idle""idle");
    
replaceani("walk""walk");
    
this.inuse=0;
  }



napo_p2p 04-09-2006 12:31 AM

I do not believe that this script has anything to do with your weapons changing...

I think that there is another script somewhere that is causing that.

gamer4lifebitach 04-09-2006 12:34 AM

but when i remove the shoot command from that script or put // infront it doesnt switch the items anymore :/

Yen 04-09-2006 12:57 AM

PHP Code:

  if (strequals(#p(1),a)&&this.inuse==1) { 
    
setani("idle"""); 
    
replaceani("idle""idle"); 
    
replaceani("walk""walk"); 
    
this.inuse=0
  } 

This could possibly be causing it.

Change the ' if (strequals(#p(1),a)&&this.inuse==1) { ' to 'if (params[1] == "a" && this.inuse == 1) {'

A+D will change weapons. It's possible that it's returning strequals(#p(1),a) as always being true?

gamer4lifebitach 04-09-2006 01:14 AM

it still dont work...

PHP Code:

//#CLIENTSIDE
function onCreated(){
  
setani("idle""");
  
replaceani("idle""idle");
  
replaceani("walk""walk");
  
this.inuse "0";
}
function 
onWeaponfired(){
  if (!
this.inuse==1) {
    
setani("cross_pistol-idle""");
    
replaceani("idle""cross_pistol-idle");
    
replaceani("walk""cross_pistol-walk");
    
this.inuse=1;
  }
  if (
this.inuse==1) {
    
setani("cross_pistol-fire""");
    
this.angle getangle(vecx(playerdir),vecy(playerdir));
    
this.bulletangle = -.2;
    
shoot(playerx,playerx,0,this.angle+random(this.bulletangle,abs(this.bulletangle)),0,0,cross_pistol-bullets,0);
    
freezeplayer(0.3);
    
sleep(0.7);
    
setani("cross_pistol-idle""");
  }
}
function 
onKeypressed(){
  if (
keydown2(keycode(a),false)&&this.inuse==1) {
    
replaceani("idle""idle");
    
replaceani("walk""walk");
    
this.inuse=0;
  }



ApothiX 04-11-2006 02:23 PM

Quote:

Originally Posted by Yen
A+D will change weapons. It's possible that it's returning strequals(#p(1),a) as always being true?

I don't think that's why it's returning true, but it is why it's switching weapons. take a look at what he's checking for:
PHP Code:

function onKeypressed(){ 
  if (
keydown2(keycode(a),false)&&this.inuse==1) { 

He's checking for D and A :P


All times are GMT +2. The time now is 12:22 AM.

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