Things to make my script more efficient -
Luis- - 10.12.2011
I've looked at most of the tutorials but I feel as though there is more to do with my script to actually make me function better, any ideas or tips? Thanks!
Re: Things to make my script more efficient -
Phanto90 - 10.12.2011
Well there are few general suggestion:
- Not to create useless variables: Create as less variables as you can and manage them in an intelligent way.
- Efficient control of loops: foreach is a good alternative to not-continuous groups (for example players or vechiles)
- Efficient control of array: Do not create arrays with useless cells
- Use packed strings: Packed strings are a good way to save spaces and resources. These are not well known
- Using automata: Sometimes automata permits to save space
Anyway you should create codes that:
-Run codes that take less time to execute as possibile (run few test if you are not sure of a code efficienty)
-Try to code in an intelligent way obviously
Good work.
Re: Things to make my script more efficient -
Luis- - 10.12.2011
Thanks for the tips, i'll try them now.
Re: Things to make my script more efficient -
Luis- - 11.12.2011
Anymore ideas / tips?
Re: Things to make my script more efficient -
THE_KNOWN - 11.12.2011
https://sampforum.blast.hk/showthread.php?tid=57018
Re: Things to make my script more efficient -
Finn - 11.12.2011
lol man you will never get the answer for that. I have rewritten my most advanced functions and systems millions of times and still they're not perfect.
Just make things work as good as you can with your current knowledge, then improve as you go.
Re: Things to make my script more efficient -
PlayHard - 11.12.2011
For admin ranks or some ranks you can define them
#define AdminLevel1 "Trial Admin" for example ^^
Re: Things to make my script more efficient -
Finn - 11.12.2011
Quote:
Originally Posted by PlayHard
For admin ranks or some ranks you can define them
#define AdminLevel1 "Trial Admin" for example ^^
|
You do realize that doesn't make the script any more efficient, just easier for the scripter to modify later on?
Re: Things to make my script more efficient -
grand.Theft.Otto - 11.12.2011
Use a stock to get players name:
pawn Код:
stock pName(playerid)
{
new name[24];
GetPlayerName(playerid, name, 24));
return name;
}
Then, in a command or something which gets a players name, instead of doing:
pawn Код:
if(!strcmp(cmdtext, "/hello", true, 4))
{
new string[128], name[24];
GetPlayerName(playerid,name,24);
format(string,128,"Hello %s !",name);
SendClientMessage(playerid,-1,string);
}
You could do:
pawn Код:
if(!strcmp(cmdtext, "/hello", true, 4))
{
new string[128];
format(string,128,"Hello %s !",pName);
SendClientMessage(playerid,-1,string);
}