View Single Post
  #1  
Old 02-22-2010, 11:21 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
Player Effects (alpha, zoom, etc)

Pretty straight forward on how to add to your playerworld-only uses one player attr; upload the gani "player-effects.gani" in to the gani directory and add this weapon code

HTML Code:
/*
  How it's used

  temp.list = {"alpha", "zoom", "red", "green", 
               "blue", "stretchx", "stretchy"};
    (Remember- if you're editing this order, modify inside
      the gani aswell, np_player-effects)

  choose an attribute from the list above  
  and call this script clientside
  
  PLEffects.onSetEffect("choice from list", value);
*/

//#CLIENTSIDE
function onCreated() {
  PLEffects = this;

    //If the player hasn't logged online before
    // lets set the right things
  if (player.attr[20] == null) {
      //Alpha, Zoom, red, green, blue, stretchx, stretchy
    temp.ani = "player-effects.gani,1,1,1,1,1,1,1";
    player.attr[20] = temp.ani;
  }
  
    //Just to check (will set the players alpha to 0.5)
  this.onSetEffect("alpha", 0.5);
}

public function onSetEffect(var, val) {
    //The list that can be modified
  temp.list = {"alpha", "zoom", "red", "green", 
               "blue", "stretchx", "stretchy"};
  
    //If it's not supported don't allow it
  if (!(temp.var in temp.list)) return false;

    //If it's not between these two values, don't allow it
  if (!(temp.val in |0, 5|)) return false;
 
    //Remove the player-effects (the gani name)
  temp.c = player.attr[20].substring(19).tokenize("");
  
    //Find the current stats
  temp.c = temp.c[0].substring(1);
  
    //Replace the values needed
  temp.c.replace(temp.list.index(temp.var), temp.val);

    //Let's set that bad boy!
  player.attr[20] = "player-effects.gani," @ temp.c;
}
Attached Files
File Type: gani player-effects.gani (526 Bytes, 261 views)
__________________
Reply With Quote