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-18-2010, 02:39 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
Healing clientr.mudmp

Well I'm trying to heal a players MP in my server but I can only get it working when the weapon is equiped?? Heres the code


PHP Code:
function onActionServerSide() {
 if (
params[0] == "heal") {
  
clientr.mudmp += "1";
 }
}
  
//#CLIENTSIDE
function onCreated() {
  if (
clientr.mudmp <= "99") {
  
triggerserver("gui",this.name,"heal");
  
setTimer(1);
 }
}
function 
onTimeout() {
  if (
clientr.mudmp <= "99") {  
  
triggerserver("gui",this.name,"heal");
  
setTimer(1);
 }

__________________
Snk for manager




Quote:
Originally Posted by Admins View Post
Snk for manager of Era
Reply With Quote
  #2  
Old 09-18-2010, 02:44 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
PHP Code:
function onActionServerSide() {
  if (
params[0] == "heal") {
    if (
clientr.mudmp 100) {  
      
clientr.mudmp++;
    }
  }
}
  
//#CLIENTSIDE
function onCreated() {
  
setTimer(1);
}

function 
onTimeout() {
  if (
clientr.mudmp 100) {  
    
triggerserver("gui",this.name,"heal");
 }
  
setTimer(1);

__________________
Reply With Quote
  #3  
Old 09-18-2010, 02:49 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
Suggestion: put the following in a class and join in to the player

PHP Code:
function onCreated() {
  
this.setTimer(1);
}

// this should really be optimized to stop the timer if ≥100 and
// restart it when they use mana and it needs to regen
function onTimeOut() {
  if (
this.clientr.mudmp 100) {
    
this.clientr.mudmp ++;
  }
  
  
this.setTimer(1);

Not only is it much more secure, it also cuts down on wasted bandwidth (and is much simpler) . Not many people take advantage of the ability of timeouts to be used on the player object.
__________________
Reply With Quote
  #4  
Old 09-18-2010, 02:56 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
alright now last question if I fire the spell fast enough I go into negative values, how can i stop that

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

function 
onActionServerSide() {
 if (
params[0] == "removemp") {
  
clientr.mudmp -= "5";
 }
}

//#CLIENTSIDE
function GraalControl.onKeyDown(codekey) {
  if (
key == "d" && player.weapon == this && ! this.d) {
    
sleep(0.1);
    
this.onTimeOut();
    
this.true;
    
player.attr[2] = "";
  }
}

function 
onTimeOut() {
  if (
player.weapon != this) {
    return;
  }
  if (
clientr.mudmp >= "7") {
  
setshootparams("5");
  
shoot(player.vecx(player.dir), player.vecy(player.dir), playerz, (playerdir 1) * pi random( -0.20.2), NULLNULL"islayer_earthspell"2);
  
play("shock.wav");
  
triggerserver("gui",this.name,"removemp");
  }

}

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

__________________
Snk for manager




Quote:
Originally Posted by Admins View Post
Snk for manager of Era
Reply With Quote
  #5  
Old 09-18-2010, 03:38 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
Quote:
Originally Posted by iSlayer View Post
alright now last question if I fire the spell fast enough I go into negative values, how can i stop that
PHP Code:
player.clientr.mudmp max(0player.clientr.mudmp 5); 
You should check serverside before firing the spell anyway.

Also don't enclose numbers in quotes--"5" and 5 are not the same thing, although they may work interchangeably. It's bad practice.
__________________
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 09:06 AM.


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