Things to make my script more efficient
#1

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!
Reply
#2

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.
Reply
#3

Thanks for the tips, i'll try them now.
Reply
#4

Anymore ideas / tips?
Reply
#5

https://sampforum.blast.hk/showthread.php?tid=57018
Reply
#6

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.
Reply
#7

For admin ranks or some ranks you can define them

#define AdminLevel1 "Trial Admin" for example ^^
Reply
#8

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?
Reply
#9

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);
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)