Author Topic: Basic coding guide.  (Read 918 times)

---What you will learn---
1.Echo's
2.Local and global variables
3.Chat messages and centerprints
4.Commands
5.The If() statement
6.Packageing

---Echo's---
A echo simply says something to a console. Simply use this code to do it
Code: [Select]
echo("Hello world!");Lets move onto variables now

---Variables---
There is two types of variables. Global and local. The local varaibles are used for just for a specific code. Global can be used anywhere. To set a Local variable simply use
Code: [Select]
%variable = 5;%variable now equals five in this code. Now on with the globals. This varaible can be used in any case. Simply do this by useing this code
Code: [Select]
$variable = 5;This may seem like the last one,But notice how i used a $ sign instead of %. Thats how a local and global variable is identified. Lets move on to Chatmessages and centerprints.

---Messages---
There is many ways to do messages. The 4 types are messageBoxOk,Centerprint,Chatmessage,And of couse bottomprint. For now ill teach you the centerprint and chatmessage. To centerprint we wanna use this code
Code: [Select]
centerPrintAll("Hello guys!",5);That will say "Hello guys!" in the center of everyones screen.
Now,Lets do a chatmessage useing this code
Code: [Select]
messageAll(",","Hi!");This will say "Hi!" in everyones chatbox. I think its time to move onto commands.

---commands---
Ok,we now know enough to make a simple command. We will start with this.
Code: [Select]
function ServerCmdhello(%client)Now,Thats just the start. Lets make it message everyone saying "hello".
Code: [Select]
function ServerCmdhello(%client)
{
messageAll(",","Hello");
}
Now,That will say hello on everyones screen. This is a very basic command to make. Lets move on to the if statement.

---The If() statement---
The if statement is very handy for admin only things. Like commands. We will first start with the command. Ill use the previous code for the "hello" message.
Code: [Select]
function ServerCmdhello(%client)
{
messageAll(",","Hello!");
}
Now,I want only admins able to do that. So ill add the If statement
Code: [Select]
function ServerCmdhello(%client)
{
if(%client.isAdmin || %client.isSuperAdmin)
{
messageAll(",","Hello!");
}
}
There! you just made your first admin only command. Lets move on to packageing tips.

---Packageing---
Well,Packageing is important if you make a mod. To package a mod make a Zipped file. Then place the following into it
1.Description.txt
2.server.cs
In server.cs you will have your code. I hope this guide helped you guys. Have a great time coding

---Didnt see what you needed?--
If you didnt see what you needed please post a comment.
« Last Edit: April 30, 2009, 03:45:43 PM by halcynthis »

If you can't even spell coding, how does anyone expect you to make a decent guide?

This is a very poor coding guide.

Every single example of your messageAll is incorrect.

The way to messageall shown in here works perfectly. Its just how i learned to do it.



Every single example of your messageAll is incorrect.

Well, they work, but not well. All he's doing is putting a comma in quotations instead of an empty tagged string (bad practice).

Still, this guide sucks. It's short, doesn't explain well, and if I showed this to someone who didn't know how to script, they'd just be more confused.

Ephi pointed this out in another thread, but you people need to stop "helping" people if you don't know what you're doing. You're just making them confused, therefore it's harder for them to learn the right way.

Yeah this guide is pretty bad, but this one isn't =D

Well, they work, but not well. All he's doing is putting a comma in quotations instead of an empty tagged string (bad practice).

Still, this guide sucks. It's short, doesn't explain well, and if I showed this to someone who didn't know how to script, they'd just be more confused.

Ephi pointed this out in another thread, but you people need to stop "helping" people if you don't know what you're doing. You're just making them confused, therefore it's harder for them to learn the right way.
That reminds me of the piano... your brain will keep trying to play it the wrong way until you re-learn it.

The RTB guide is pretty good by the way, I really hope people will keep adding new content to it.

The RTB guide is pretty good by the way, I really hope people will keep adding new content to it.
It was last updated a year ago and the links are out of date.

It was last updated a year ago and the links are out of date.

What really? God damn.

This is a very poor coding guide.
Even mine was better and it sucked. Also:
MessageAll(' ',"message");

messageAll('', "lol");

You really don't need that extra space.

In notepad, you can see the difference between two single quotes and a double quote.

''  Two single quotes
"  One double quote