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 11-29-2009, 08:08 PM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
Cool gunscript not doing dmg to people

NPC Code:
//#CLIENTSIDE
function onCreated() {
this.firerate = .2;
}

function onWeaponFired() {
while (keydown(4)) {
FireGun();
sleep(this.firerate);
}
}

function FireGun() {
setani("millenium_scar-fire", "");

this.spread=.053;
this.speed=5;
this.reload=50;
this.load=50;

temp.angl = getangle(vecx(player.dir), vecy(player.dir))+random(this.spread*-1,this.spread);
shoot(player.x + 0.5 + vecx(player.dir), player.y + vecy(player.dir), player.z, temp.angl, 0, 0, "mil_bullets", player.dir);
}
function onActionProjectile()
{
if (clientr.hp>=0) {
setani hurt,;
}
}




the problem is that when i shoot people they set ani hurt

but for some people nothing happens


ps

sorry about my gs1 habbits

im doing a little bit better with gs2 tho
Reply With Quote
  #2  
Old 11-29-2009, 08:12 PM
Programmer Programmer is offline
Coder
Programmer's Avatar
Join Date: Jan 2008
Location: -78.464422, 106.837328
Posts: 449
Programmer has a spectacular aura aboutProgrammer has a spectacular aura about
Send a message via AIM to Programmer Send a message via MSN to Programmer Send a message via Yahoo to Programmer
The error is that you don't have any code to decrease the player's health in the first place! :P

Try adding clientr.hp -= YOUR_DAMAGE_HERE; after setani hurt,; (which should be setani("hurt", null);) and see if it works.
__________________
- Iᴀɴ Zɪᴍᴍᴇʀᴍᴀɴ
Reply With Quote
  #3  
Old 11-29-2009, 08:14 PM
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
Whoever has that gun will be able to get hit, everyone who doesn't won't.

You need to take the actionProjectile code out of the gun and put it in it's own script called, -System/Damage or something and then make sure everyone has it.

Your gun script:

PHP Code:
//#CLIENTSIDE

function onCreated() {
  
this.firerate .2;
}

function 
onWeaponFired() {
  while (
keydown(4)) {
    
FireGun();
    
sleep(this.firerate);
  }
}

function 
FireGun() {
  
setani("millenium_scar-fire""");
  
this.spread=.053;
  
this.speed=5;
  
this.reload=50;
  
this.load=50;
  
temp.angl getangle(vecx(player.dir), vecy(player.dir))+random(this.spread*-1,this.spread);
  
shoot(player.0.5 vecx(player.dir), player.vecy(player.dir), player.ztemp.angl00"mil_bullets"player.dir);

-System/Damage:

PHP Code:
//#CLIENTSIDE
function onActionProjectile() {
  if (
clientr.hp>=0) {
    
setani("hurt""");
  } 

__________________
Quote:
Reply With Quote
  #4  
Old 11-29-2009, 08:26 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
I've already explained in other threads that you need to place the damage into another weapon, and even given you the code for the HP system:

Quote:
Originally Posted by cbk1994 View Post
PHP Code:
function onActionServerSide(cmddamage) {
  if (
cmd == "hit") {
    
this.hitPlayer(damage);
  }
}

function 
hitPlayer(damage) {
  
player.clientr.hp max (0player.clientr.hp damage); // max() chooses the largest of the two values
  
  
if (player.clientr.hp <= 0) {
    
this.playerDead();
  } else {
    
player.setAni("hurt"NULL);
  }
}

function 
playerDead() {
  
player.setAni("dead"NULL);
  
player.setlevel2("onlinestartlocal.nw"2155);
  
// now you'll need eventually to heal them
  
}
//#CLIENTSIDE
function onActionProjectile(damage) {
  
triggerServer("gui"this.name"hit"damage);

Every player has to have the system weapon. The way it works is when a player is hit with a bullet, it calls the "onActionProjectile" event in every weapon. If a weapon has the event "defined", then it will be executed. If they don't have your gun script, which is where you mistakenly put the HP checks, then it won't be called.

Take your onActionProjectile code, place it in to a weapon like "-Health", and add a line of code in the Control-NPC to add it to players on login.

EDIT: Jerret beat me to it
__________________
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 12:33 PM.


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