Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Adding players EXP once baddy killed (https://forums.graalonline.com/forums/showthread.php?t=134260461)

iSlayer 09-07-2010 06:41 AM

Adding players EXP once baddy killed
 
Ok this is serverside and it happens once the baddy is dead

PHP Code:

if(this.hp <= 0) {
 
getnearestplayer(this.x, this.y) 

Not sure what to do next :confused:

cbk1994 09-07-2010 06:45 AM

Just keep track of the player who last hit it, no reason to use findNearestPlayers.

Cubical 09-07-2010 06:45 AM

have it send the players account as a parameter every time the player attacks as you would with damage then have it check to see if it is dead everytime it takes damage and if it is either have it join a class for player functions or join it to the player directly. then do addExp(amount); you can also do some checks to see if they are in a party and if so evenly distribute it throught the party.

cbk1994 09-07-2010 06:46 AM

Quote:

Originally Posted by Cubical (Post 1599384)
have it send the players account as a parameter every time the player attacks as you would with damage then have it check to see if it is dead everytime it takes damage and if it is either have it join a class for player functions or join it to the player directly. then do addExp(amount); you can also do some checks to see if they are in a party and if so evenly distribute it throught the party.

No reason to send the account as a parameter. The player will be in scope in triggers.

Cubical 09-07-2010 06:47 AM

Quote:

Originally Posted by cbk1994 (Post 1599385)
No reason to send the account as a parameter. The player will be in scope in triggers.

oh u rite, the other stuff still applies.

Cubical 09-07-2010 07:02 AM

class
PHP Code:

function addExp(amount){
  
clientr.exp += amount;
} 

baddy
PHP Code:

join("player_functions");
function 
onActionServerside(cmd){
  switch (
cmd){
    case 
"addexp":
      
addExp(amount);
      break;
  }
}
//#CLIENTSIDE
function onCheckDead(){
  
// do checks
  
triggerserver("gui", name, "addexp"); 
} 

However joining the player to the class on login could simplify it and make it a bit more accessible. Using the same class you can just do player.addExp(amount); anywhere serverside by doing this on login.

PHP Code:

  player.join("player_functions"); 

then your code would look like this
PHP Code:

function onActionServerside(cmd){
  switch (
cmd){
    case 
"addexp":
      
player.addExp(amount);
      break;
  }
}
//#CLIENTSIDE
function onCheckDead(){
  
// do checks
  
triggerserver("gui", name, "addexp"); 
} 


cbk1994 09-07-2010 07:13 AM

Unless your baddies are completely clientside (different for each player), there's no excuse for doing checks on clientside like that. If he's using triggers he can handle those serverside.

iSlayer 09-08-2010 06:41 AM

Quote:

Originally Posted by Cubical (Post 1599387)
class
PHP Code:

function addExp(amount){
  
clientr.exp += amount;
} 

baddy
PHP Code:

join("player_functions");
function 
onActionServerside(cmd){
  switch (
cmd){
    case 
"addexp":
      
addExp(amount);
      break;
  }
}
//#CLIENTSIDE
function onCheckDead(){
  
// do checks
  
triggerserver("gui", name, "addexp"); 
} 

However joining the player to the class on login could simplify it and make it a bit more accessible. Using the same class you can just do player.addExp(amount); anywhere serverside by doing this on login.

PHP Code:

  player.join("player_functions"); 

then your code would look like this
PHP Code:

function onActionServerside(cmd){
  switch (
cmd){
    case 
"addexp":
      
player.addExp(amount);
      break;
  }
}
//#CLIENTSIDE
function onCheckDead(){
  
// do checks
  
triggerserver("gui", name, "addexp"); 
} 


Hmm where would I put the exp because the baddy uses this.exp

Cubical 09-08-2010 07:08 AM

Quote:

Originally Posted by iSlayer (Post 1599575)
Hmm where would I put the exp because the baddy uses this.exp

PHP Code:

player.addExp(this.amount); 

or if you don't have the class joined to the player but you have it joined to the npc then do
PHP Code:

addExp(this.amount); 

or if you have it in a different weapon as a public function do
PHP Code:

(@ "Systems/PlayerFunctions").addExp(this.amount); 


iSlayer 09-08-2010 09:21 AM

But where?


All times are GMT +2. The time now is 01:14 AM.

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