PDA

View Full Version : Ideas to make your coding experience easier


^BuGs^
08-12-2007, 23:06
I been witnessing lots of people doing the same thing so I compiling a bunch of tips.
Before starting a project:
Decide what you are really going to do. (Game play, administration, fun, etc.)
Decide how you are going to do it.
Make sure you can handle that project.
Be sure that you are using latest versions. (MM:S, SM and API's you use.)
Always make a "To Do" list and a change log to keep your project organized.
Check to see if something your about to code in your script is already being done by another plugin with their API. (Don't reinvent the wheel.)
Reason: Less Memory Usage
Example: Repeated messages that go to all client to tell something (i.e. Type !yourtriggerhere to run me)
Possible Solution: Use the Ads API (http://forums.alliedmods.net/showthread.php?p=498638). Allows better control flow of messages. (Shameless plug)
Con: Online compiler will not work.
Your plugin provide functionally that everyone could use... create an API with the needed natives. Bouns... make it so it's optional so you don't force the person using your plugin, also have to use the secondary plugin just so they can disable it once it's running.
Highly recommend using http://sm.nican132.com/ for fast looking up of function definitions.
Do not hardcode values. Use Cvars or a configuration file.
Tell users your project's compatibilities/dependencies. (OS, mod, extensions, plugins, APIs)
Don't wait for a request to put screenshots. You can use Picasa Web (http://picasaweb.google.com/) to organize your screenshots easily.
Do not create your own "MAX CLIENTS" define. Use MAXPLAYERS. If this is going to be an array, do not forget the "+ 1". Client Index start 1 -- not 0.(Hint for people who want their plugins approved.)
Post your suggestion!

Shaman
08-13-2007, 07:26
Don't hardcode ;)

^BuGs^
08-13-2007, 07:41
:wink:that was a shamless plug lol .

Yes, but true. If half the scripts used the Ads API, people would be able to control if they wanted advertisements. For me having tons of messages show in chat is mading. Having a script that does ads + my ads plugins creates 3 to 5 lines in chat which are removed right away from other content. i.e. Someone joining or throwing a grenade.

Peoples Army
08-13-2007, 07:53
helpfull tip 4:

DO NOT use pencil and paper as a SDK. :down:

Shaman
08-13-2007, 09:25
1- Before starting a project:
Decide what you are really going to do. (Game play, administration, fun, etc.)
Decide how you are going to do it.
Make sure you can handle that project.

2- Be sure that you are using latest versions. (MM: S, SM and API's you use.)

3- Always make a "To Do" list and a change log to keep your project organized.

4- Tell users your project's compatibilities/dependencies. (OS, mod, extensions, plugins, APIs)

5- Don't wait for a request to put screenshots. You can use Picasa Web (http://picasaweb.google.com/) to organize your screenshots easily.

dubbeh
08-13-2007, 09:49
Good thing is to make use of the stack that might be a very similiar function but with a very small change

eg.


CreatePlayerListMenu (client, Handle:hMenu, const String:szMenuTitle[], MenuHandler:Handler)
{
decl String:szClientIndex[8] = "", String:szClientName[64] = "";
static iIndex = 0;

hMenu = CreateMenu (Handler);
SetMenuTitle (hMenu, szMenuTitle);

iIndex = 1;
while (iIndex <= g_iMaxClients)
{
if (IsClientConnected (iIndex) && IsClientInGame (iIndex))
{
GetClientName (iIndex, szClientName, sizeof (szClientName));
Format (szClientIndex, sizeof (szClientIndex), "%d", iIndex);
AddMenuItem (hMenu, szClientIndex, szClientName);
}

iIndex++;
}

DisplayMenu (hMenu, client, MENU_TIME_FOREVER);
}
Using this for diffrent menus like player kick/ban/mute - find it saves lots of coding time & clutter in overall code ;)

spelworm
08-14-2007, 02:59
i just cant figure out how all the commands work >< i can look at it for a long time and the only thing i know then is i need a asprine against the headache
is there some page that will explain how u write a command with a example i checked the wiki page but it just isnt very clear to me

btw why are all the posts deleted ?:P

dubbeh
08-14-2007, 07:29
Highly recommend using http://sm.nican132.com/ for fast looking up of function definitions

Love it if someone would be willing to make a searchable chm file for easy local lookup

Nican
08-14-2007, 12:40
Highly recommend using http://sm.nican132.com/ for fast looking up of function definitions

Love it if someone would be willing to make a searchable chm file for easy local lookup

Do you know how to make .chm file? If you want I can upload the MySQL database for you, or you can teach me how to make one, since SM is being update constantly...

dubbeh
08-14-2007, 13:33
Found quite a few window based ones & the SDK can be download from the MSDN

I'll keep looking around & see if i can find a php script

Nican
08-14-2007, 13:36
Thank you