1. Like cyan said, with classes you don't need to copy and paste the same function all the time for every script, meaning if you got a bug and you fix it inside a class, that will do the change to every script being joined to that class -> you don't need to find all the weapons/npcs and update them manually.
2. DB NPCs are used to store information. Lets say you got something like:
PHP Code:
function onPlayerTouchsMe() {
if (!(player.account in this.playersThatTouchedMe)) {
this.playersThatTouchedMe.add(player.account);
}
}
Inside a normal NPCs, the
this.playersThatTouchedMe array would reset everytime you update/edit the level. with a DB NPC this would still be saved as a flag.
3. To change a players hat, you need to change the players attr[1] (
player.attr[1] = "hat image file";) and for the players head, you need to set the
player.head = "head image file"; (for trial users its limited to head0.png to head15.png, maybe even just head10.png).
4. Using && will get you the option to see if the 2nd statement is
also true, while using || will check if either one of the statements is true
The
or check:
PHP Code:
function onPlayerTouchsMe() {
//check if 'player.account' is either 'Stefan' or 'Unixmad'
if (player.account == "Stefan" || player.account == "Unixmad") {
player.chat = "Hey I'm Stefan or Unixmad";
}
}
Basically the same as
PHP Code:
function onPlayerTouchsMe() {
if (player.account == "Stefan") {
player.chat = "Hey I'm Stefan or Unixmad";
}
else if (player.account == "Unixmad") {
player.chat = "Hey I'm Stefan or Unixmad";
}
}
The
and check:
PHP Code:
function onPlayerTouchsMe() {
//check if 'player.account' is 'Stefan' and if he is wearing the 'head0.png' head
if (player.account == "Stefan" && player.head == "head0.png") {
player.chat = "Hey I'm Stefan wearing the head0.png!!";
}
}
Basically the same as:
PHP Code:
function onPlayerTouchsMe() {
//check if 'player.account' is 'Stefan' and if he is wearing the 'head0.png' head
if (player.account == "Stefan") {
if (player.head == "head0.png") {
player.chat = "Hey I'm Stefan wearing the head0.png!!";
}
}
}