View Single Post
  #9  
Old 06-08-2010, 06:13 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
Basic item system (nothing MUD-related though):

class: player_itemfunctions

PHP Code:
public function addItem(itemnameqty) {
  
// Increment quantity of the item
  
clientr.item.(@itemname) += qty;
}

public function 
takeItem(itemnameqty) {
  
// Decrement quantity of the item
  
clientr.item.(@itemname) -= qty;
  
// Check for non-existent quantity value
  // I.e: No sense having an item with a quantity of -3
  
if (clientr.item.(@itemname) <= 0) {
    
// Destroy Item Flag 
    
clientr.item.(@itemname) = "";
  }

Then in your Control-NPC:

PHP Code:
function onActionPlayerOnline() {
  
player.join("player_itemfunctions");

Now in other scripts (on the serverside) you can add items like this:

player.addItem("Amazing Sword of Doom", 1);

or

findplayer("Jiroxys7").addItem("Broken Sword of Fail", 100);

Which would add/set a flag like this in your player flags:

clientr.item.Amazing Sword of Doom=1
__________________
Quote:
Reply With Quote