Suggestion for old functions to be replaced with new ones?
#1

This is mostly a scripting help topic, but also belongs in discusion..

Anyway, on topic.
I am coding the script with old functions like for example:
Код:
for(new i = 0; i < MAX_PLAYERS; i++)
or
Код:
strcmp(cmd, "/mycommand", true) == 0)
Is there any topic or etc that has alot of new functions that are faster then the stock ones?
Any much of the pawn and around it.

Including any old stock functions like strcmp, for, format and more.
Reply
#2

for the first one, you can use foreach. for the second one, use zcmd, it's the fastest way to create commands.

(if i understood correctly)
Reply
#3

It's just examples, is there any general topic or should we at least make one that gives other users a way to make their gamemode faster by replacing old stock functions with new ones.

Also my question is what other stock functions we have that need to be/can be replaced with newer ones that have been tested to be faster.
Reply
#4

First of all, they are not old functions. They are pretty useful for what they were meant to do. Well, it's obvious that comparing strings for commands is not the best way and I don't recommend either, but that does not mean that strcmp is totally crap.

You can always see some modes which are written by skilled people and have a look on what they use; for example, the most use ZCMD or y_commands. For saving/loading, the most use MySQL, SQLite or y_ini (ignore those newbies with dini and all those outdated). Forum can provide what you want - the only thing you've to do is search.
Reply
#5

Quote:
Originally Posted by BullseyeHawk
Посмотреть сообщение
It's just examples, is there any general topic or should we at least make one that gives other users a way to make their gamemode faster by replacing old stock functions with new ones.

Also my question is what other stock functions we have that need to be/can be replaced with newer ones that have been tested to be faster.
Eh, I think you can use the Useful functions topic, (people always compete to come up with the fastest posted function there). Or you can check ******'s Code optimizations thread. or just use search.
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
Clearly you haven't understood as currently the fastest command processor is y_commands.

Check the Code Optimisations topic, it's currently at the top of Scripting Discussion forum. However, I do see you point about there not being a simple list.
y_commands is indeed faster, altought I don't really like the way they are just placed randomly trought the script insted of inside OnPlayerCommandText or in a function.

Code Optimisations topic is very intersting, especialy the one about strings, I never looked into the RAM and requierments it takes, for using like 20 chars in a 128 string. Currently following the whole description over there and reducing any of my strings to act proparly. Also, just an idea that we should make another topic of 'code optimisation' but about functions, users suggest new functions over old ones, for example:
Quote:

for(new i = 0; i < MAX_PLAYERS; i++)
slower then, foreach(Player, i).

PAWN-CODE here of example how much ms for each code.

Reply
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
Clearly you haven't understood as currently the fastest command processor is y_commands.
No... y_commands is only faster if you have over 100 commands; unless you sped it up in YSI 4.0...
Reply
#8

Quote:
Originally Posted by BullseyeHawk
Посмотреть сообщение
y_commands is indeed faster, altought I don't really like the way they are just placed randomly trought the script insted of inside OnPlayerCommandText or in a function.

Code Optimisations topic is very intersting, especialy the one about strings, I never looked into the RAM and requierments it takes, for using like 20 chars in a 128 string. Currently following the whole description over there and reducing any of my strings to act proparly. Also, just an idea that we should make another topic of 'code optimisation' but about functions, users suggest new functions over old ones, for example:
Anyways if you would place them below OnPlayerCommandText, you might place them randomly as well, therefore it doesn't matter.
Reply
#9

Quote:
Originally Posted by ******
Посмотреть сообщение
I'm always improving things.
I should know that by now... haha
Reply
#10

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
Anyways if you would place them below OnPlayerCommandText, you might place them randomly as well, therefore it doesn't matter.
You didn't understand by what I mean 'randomly'.
y_commands can be placed along the whole script, at the top or even at the bottom. I ment I don't like it because it's outside a function. if y_commands were fast and inside a function like OnPlayerCommandText that was replaced with ALS, then it'd been more easy for me to find stuff inside that function only, but insted they are placed outside /any/ function and can be found at the bottom of the script like a stock or at the top after all of the includes.

But as ****** points it out, placing the commands near the systems themselves is actually not a bad idea and a great way to find the commands more easier.
>>
Quote:
Originally Posted by ******
Посмотреть сообщение
I'm always improving things.



Then don't place them randomly! Keep the commands for your user system with the user system, keep the commands for your vehicle system with the code for your vehicle system, etc...
I might use that idea as it's actually logical to find all of the stuff in the system more easly and it's a way to keep each part of a systems code in one paragrph of the script.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)