|
Since its a scripting thread, I need help with the variable commands, for example the ec system, I wanted to make it add on each time I want.
I added this on another NPC :
Thanks...
|
Are you trying to give players EC? You'll find it won't work if you're giving NPCs the EC using
this.ec instead of
player.clientr.ec. This is because
this. refers to the NPC, and
player.clientr. refers to the player's clientr flags. Save the EC to the player's flags to give the player EC.
PHP Code:
player.clientr.ec ++;
//OR
player.clientr.ec += 10;
Just a note, clientr flags can only be changed on the serverside, but can be read from both the clientside and the serverside, so you'll have to add the EC on the serverside. Also, use php tags to show coding instead of quotes ;)
I doubt you'll be able to understand how to load/save from text files this early on in learning GS2, so here's an example of how to save and load your NPC's configuration to/from a text file. Firstly, you'll have to give your NPC-Server the following right.
HTML Code:
rw objects/statues/*.txt
After that, simply add this code to a class and join it to the NPC you wish to make a statue. After that, simply call the loadStatueConfig(); function to load the statue and the saveStatueConfig(); function to save the statue.
PHP Code:
function onCreated() {
showCharacter();
loadStatueConfig();
}
function loadStatueConfig() {
this.loadfrom = "objects/statues/statue_" @ this.id @ ".txt";
temp.config.loadlines(this.loadfrom);
for (lines : temp.config) {
this.head = lines[0];
this.body = lines[1];
this.shield = lines[2];
this.sword = lines[3];
this.colors[0] = lines[4];
this.colors[1] = lines[5];
this.colors[2] = lines[6];
this.colors[3] = lines[7];
this.colors[4] = lines[8];
}
}
function saveStatueConfig() {
this.saveto = "objects/statues/statue_" @ this.id @ ".txt";
temp.config = {
this.head,
this.body,
this.shield,
this.sword,
this.colors[0],
this.colors[1],
this.colors[2],
this.colors[3],
this.colors[4]
};
temp.config.savelines(this.saveto, false);
}
I hope that helped!