Go Back   Smogon Community > Contributions & Corrections > Projects
Register FAQ Social Groups Calendar Search Today's Posts Mark Forums Read

Reply
Categories: HTML, Programming, Other
 
Thread Tools
Old Sep 30th, 2011, 7:20:49 PM   #1
XCookie
 
XCookie's Avatar
 
Join Date: Sep 2011
Posts: 12
Smogon Server
Post Scripting Tutorial

Scripting Lesson!:

(Made by supertrunks);

Functions:

Source = src
Target = tar
stopEvent(); = stops the Message/Event. Like log in or beforeChatMessage this can be used. Some Functions will ignore stopEvent and let them post it. (Only for the one's that un-stopable event).

Note: Each function has to start with 'sys.' or a error will appear, unless var and/or print.
xxxx: Also use "); at the end of each function.

EX:

/Eval sys.sendAll(" Test. ");

*** Or in a Command or Eval JavaScript Code.

It will send 'Test' in Main Chat to everyone with out the '.

Messages:

sendAll("message"); - sends a message to everyone that is in main channel.
sendMessage(src, "message"); - sends a message to the Source (src).
sendHtmlAll("message"); - sends a message to everyone that is in main channel, but with HTML.
sendHtmlMessage(src, "message"); - sends a message to the Source (src), but with HTML.
print("var1, var2"); - to send a message to the Server Window.

Player Events:

changeAuth(tar, authlevel); - to change someone's Server Auth Level. (Use the Auth Chat Below to know the Auth Levels.)
ip(src) - to get the players current IP Address.
ban(playerId); - prevents that playerId from entering the Server.
unban(playerId); - lets the playerId to enter the Server.
kick(playerId); - disconnects the playerId from the Server.
eval(eval); - to enter a eval code. * Please use with caution. *

Info Events:

dbRegistered(playerId) - to see if that person is registered.
getColor(playerId); - to get someone's name color. (If any.)
avatar(avatarnumber) - to change your avatar, until you leave. (If not 1-263, it will be invisible.)


Command Events:

PHP Code:
if(command == "COMMAND NAME HERE") {
// Add function(s) here.//
// Also add any messages, ect.//
//If ban or kick add sys.kick(tar); or sys.ban(tar); here.//
return;

Note: When i said "COMMAND NAME HERE" it won't allow you to type in CAPS or spaces. Please use no spaces and NO CAPS. ~ Thanks.


Chat Events:

Html:

<timestamp/> - to add the time, if using sendHtmlAll or sendHtmlMessage.
x: If you are not using HTML, it already has a timestamp sent.

<ping/> - to make that players Pokemon Online client flash.
x: Good if they are AFK with a tourney or something important.

Vocab:

"+sys.name(src)+" = The Source or the shorter way 'src'.

"+sys.name(tar)+" = The Target or the shorter way 'tar'.

"+commandData+" = The data. (If any.) For reasons like /me, "+commandData+" is what they said.

"+message+" = the playerId's message, useful when you use sys.print();

Note: You can space out "+ to " + it will still work. Doesn't matter which way you do it. I choose no space because it's quicker.

Other Events:

serverStartUp() - this should be in your script, when the server starts..
serverShutDown() - this should be in your script, when the server shuts down.
afterLogIn() - after the src logs in the server.
beforeLogOut() - before the src logs out the server.
beforeChatMessage() - before the src talks, useful when they are muted.

Auth Only:


Code:
}
if (sys.auth(src) < 1) {
return;
If you put that before the command, it only lets Moderators and +up use it.

Note: You can change 1 to 1,2,3, or 4.

--------------------------------------

Current PO Auth Chat:

0; User

1; Moderator

2; Administrator

3; Owner

4-6; Invisible

-------------------------------------

Log Events:

LogIn(src) - when the source logs in the server.
LogOut(src) - when the source logs out the server.

[Var] Lesson:

You can use a var if you.. for ex. like a boarder:

You would put this before your commands:

PHP Code:
var b"»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»"
And you can just use:

sys.sendMessage(src, " "+b+" ");

And it would show: »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»

That is how var works in JavaScripts.

Big Note: I hope to add on a lot more Java Functions soon.

Note: Credit to Sephira for helping with Var. (Thanks bro.)

Remember, feel free to comment!
-------------------------------------------------------------

Last edited by Setsuna; Oct 1st, 2011 at 2:42:46 PM. Reason: Those long lines would stretch people's page out.
XCookie is offline   Reply With Quote
Reply Smogon Community > Contributions & Corrections > Projects

« Previous Thread | Next Thread »
Thread Tools

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 -4. The time now is 12:57:49 AM.