Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 20th November 2011
Darkc0der Darkc0der is offline
Ceriwiser
 
Join Date: Nov 2011
Posts: 598
Rep Power: 14
Darkc0der mempunyai hidup yang Normal
Default SCRIPT Untuk Server Pokemon Online :D

Quote:






Quote:






Quote:






Quote:





({

afterLogIn : function(source) {

sys.sendMessage(source, "Bot: Hello, " + sys.name(source) + "!");

}



,



beforeLogOut : function(source) {

sys.sendMessage(source, "Bot: Bye, " + sys.name(source) + "!");

}



,



serverStartUp : function() {

this.init();

}

,



init : function() {

key = function(a,b) {

return a + "*" + sys.name(b);

}



hasBan = function(id, poke) {

return clauses[id].indexOf("*" + poke + "*") != -1;

}



if (typeof (clauses) == "undefined") {

clauses = [];

}



if (typeof (clauseOn) == "undefined") {

clauseOn = [];

}



if (typeof(impersonation) == "undefined") {

sys.setPA ("impersonation");

}



if (typeof(muted) == "undefined") {

sys.setPA ("muted");

}



if (typeof(maxPlayersOnline) == "undefined") {

maxPlayersOnline = 0;

}



/* For little cup */

if (typeof(lilCupLevels) == "undefined")

lilCupLevels = [];

}



,





,



afterLogIn : function(src) {

sys.sendMessage(src, "+CommandBot: Use !commands to see the commands!");



if (sys.getVal("muted*" + sys.ip(src)) == "true")

muted[src] = true;



if (sys.numPlayers() > maxPlayersOnline) {

maxPlayersOnline = sys.numPlayers();

}



if (maxPlayersOnline > sys.getVal("MaxPlayersOnline")) {

sys.saveVal("MaxPlayersOnline", maxPlayersOnline);

}



sys.sendMessage(src, "+CountBot: Max number of players online was " + sys.getVal("MaxPlayersOnline") + ".");

sys.sendMessage(src, "");



this.afterChangeTeam(src);

}



,





afterChangeTeam : function(src)

{

clauseOn[src] = sys.getVal("clauseOn*" + sys.name(src)) == "true";

clauses[src] = sys.getVal("clauses*" + sys.name(src));

}



,

beforeChatMessage: function(src, message) {

if (sys.auth(src) < 2 && muted[src] == true) {

sys.stopEvent();

sys.sendMessage(src, "Bot: you are muted!");

return;

}

if ((message[0] == '/' || message[0] == '!') && message.length > 1) {

print("Command -- " + sys.name(src) + ": " + message);

sys.stopEvent();

var command;

var commandData;

var pos = message.indexOf(' ');



if (pos != -1) {

command = message.substring(1, pos).toLowerCase();

commandData = message.substr(pos+1);

} else {

command = message.substr(1).toLowerCase();

}

var tar = sys.id(commandData);



if (command == "commands" || command == "command") {

sys.sendMessage(src, "");

sys.sendMessage(src, "*** Commands ***");

sys.sendMessage(src, "/me [message]: to speak with *** before its name");

sys.sendMessage(src, "/players: to get the number of players online");

if (clauseOn[src])

sys.sendMessage(src, "*** You have pokemon clausing on ***");

else

sys.sendMessage(src, "*** You have pokemon clausing off ***");

sys.sendMessage(src, "/on: to turn on your pokemon clausing");

sys.sendMessage(src, "/off: to turn off your pokemon clausing");

sys.sendMessage(src, "/no [pokemon]: to clause that pokemon");

sys.sendMessage(src, "/allow [pokemon]: to allow that pokemon");

sys.sendMessage(src, "/list: to list the pokemons you ban");

sys.sendMessage(src, "/clear: to clear the list of your pokemon bans");

if (sys.auth(src) < 1)

return;



if (sys.auth(src) < 2)

return;

sys.sendMessage(src, "*** Admin Commands ***");

sys.sendMessage(src, "/reset: to reset the server variables (useful when you add a new script)");

sys.sendMessage(src, "/masskick: to clean up the server");

sys.sendMessage(src, "/changeAuth [auth] [person]: to play the mega admin");

sys.sendMessage(src, "/setPA paname: to add a new pa, use with scripting caution");

return;

}

if (command == "me") {

sys.sendAll("*** " + sys.name(src) + " " + commandData);

return;

}

if (command == "players") {

sys.sendMessage(src, "CountBot: There are " + sys.numPlayers() + " players online.");

return;

}

if (command == "off") {

sys.sendMessage(src, "ClauseBot: You don't ban any pok�mons anymore!");

sys.saveVal(key("clauseOn",src), false);

clauseOn[src] = false;

return;

}

if (command == "on") {

sys.sendMessage(src, "ClauseBot: You turned the pok�mon bans on!");

sys.saveVal(key("clauseOn",src), true);

clauseOn[src] = true;

return;

}

if (command == "no") {

pokenum = sys.pokeNum(commandData);

if (pokenum == undefined) {

sys.sendMessage(src, "ClauseBot: -" + commandData + "- doesn't exist as a pok�mon.");

return;

}

if (hasBan(src, pokenum)) {

sys.sendMessage(src, "ClauseBot: you already ban " + commandData + ".");

return;

}

clauses[src] += "*" + pokenum + "*";

sys.saveVal(key("clauses", src), clauses[src]);

sys.sendMessage(src, "ClauseBot: you now ban " + commandData);

return;

}

if (command == "allow") {

var pokenum = sys.pokeNum(commandData);

if (pokenum == undefined) {

sys.sendMessage(src, "ClauseBot: -" + commandData + "- doesn't exist as a pok�mon.");

return;

}

if (!hasBan(src, pokenum)) {

sys.sendMessage(src, "ClauseBot: you already don't ban " + commandData + ".");

return;

}

var pos = clauses[src].indexOf("*"+pokenum+"*");

clauses[src] = clauses[src].substring(0, pos) + clauses[src].substr(pos+("*"+pokenum+"*").length);

sys.saveVal(key("clauses", src), clauses[src]);

sys.sendMessage(src, "ClauseBot: you now allow " + commandData);

return;

}

if (command == "clear")

{

clauses[src] = "";

sys.sendMessage(src, "ClauseBot: Your ban list was cleared!");

return;

}

if (command == "list") {

sys.sendMessage(src, "");

sys.sendMessage(src, "ClauseBot: Here is what you ban: ");

for (var i = 1; i + 2 < clauses[src].length ; ) {

var pos = clauses[src].indexOf('*',i);

if (pos == -1)

break;



sys.sendMessage(src, "Pok�mon: " + sys.pokemon(clauses[src].substring(i, pos)));

i = pos+2;

}

return;

}

if (command == "debug") {

sys.sendMessage(src, clauses[src]);

return;

}

/** Moderator Commands **/

if (sys.auth(src) < 1) {

sys.sendMessage(src, "CommandBot: The command " + command + " doesn't exist");

return;

}

if (command == "imp") {

impersonation[src] = commandData;

sys.sendMessage(src, "Bot: Now you are " + impersonation[src] + "!");

return;

}

if (command == "impoff") {

delete impersonation[src];

sys.sendMessage(src, "Bot: Now you are yourself!");

return;

}

if (command == "sendall") {

sys.sendAll(commandData);

return;

}

if (command == "k") {

if (tar == undefined) {

return;

}

sys.sendAll("Bot: " + commandData + " was mysteriously kicked by " + sys.name(src) + "!");

sys.kick(tar);

return;

}

if (command == "mute") {

if (tar == undefined) {

return;

}

if (sys.auth(tar) >= sys.auth(src)) {

sys.sendMessage("Bot: you dont have sufficient auth to mute " + commandData + ".");

return;

}

sys.sendAll("Bot: " + commandData + " was muted by " + sys.name(src) + "!");

muted[tar] = true;

return

}

if (command == "unmute") {

if (tar == undefined) {

return;

}

sys.sendAll("Bot: " + commandData + " was unmuted by " + sys.name(src) + "!");

muted[tar] = false;

return;

}

if (sys.auth(src) < 2) {

return;

}

/** Admin Commands **/

if (command == "reset") {

this.serverStartUp();

sys.sendAll("+Server: The server script variables were reset.");

return;

}

if (command == "masskick") {

for (var i = 1; i < 200 && sys.numPlayers() > 0; i++) {

if (sys.loggedIn(i)) {

sys.kick(i);

}

}

return;

}

if (command == "setpa") {

sys.setPA(commandData);

sys.sendMessage(src, "Bot: -" + commandData + "- was set!");

return;

}

if (command == "changeauth") {

var pos = commandData.indexOf(' ');

if (pos == -1) {

return;

}

var newauth = commandData.substring(0, pos);

var tar = sys.id(commandData.substr(pos+1));

sys.changeAuth(tar, newauth);

sys.sendAll("Bot: " + sys.name(src) + " changed auth of " + sys.name(tar) + " to " + newauth);

return;

}

return;

}



}

}



,



beforeBattleMatchup : function(src,dest,clauses)

{

if (clauseOn[dest] == true) {

for (var i = 0; i < 6; i++) {

if (hasBan(dest, sys.teamPoke(src,i))) {

sys.stopEvent();

return;

}

}

}

if (clauseOn[src] == true) {

for (var i = 0; i < 6; i++) {

if (hasBan(src, sys.teamPoke(dest,i))) {

sys.stopEvent();

return;

}

}

}



/* Regular tier checks that can't be made using the built-in server tier system */

if (sys.tier(src) == "LittleCup" && sys.tier(dest) == "LittleCup") {

if (sys.hasTeamMove(src, sys.moveNum("SonicBoom")) || sys.hasTeamMove(src, sys.moveNum("Dragon Rage"))) {

sys.stopEvent();

}

if (sys.hasTeamMove(dest, sys.moveNum("SonicBoom")) || sys.hasTeamMove(dest, sys.moveNum("Dragon Rage"))) {

sys.stopEvent();

}

if (sys.hasTeamItem(src, sys.itemNum("Berry Juice"))) {

sys.stopEvent();

}

if (sys.hasTeamItem(dest, sys.itemNum("Berry Juice"))) {

sys.stopEvent();

}

}

}



,



}

}



,



beforeLogOut : function (src) {

if (muted[src] == true) {

sys.saveVal("muted*" + sys.ip(src), "true");

} else {

sys.removeVal("muted*" + sys.ip(src));

}

}



})



























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


 


All times are GMT +7. The time now is 06:34 PM.


no new posts