PDA

View Full Version : Suggestion for old functions to be replaced with new ones?


BullseyeHawk
07/08/2013, 11:00 AM
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.

-Prodigy-
07/08/2013, 11:06 AM
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)

BullseyeHawk
07/08/2013, 11:16 AM
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.

Konstantinos
07/08/2013, 11:20 AM
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.

-Prodigy-
07/08/2013, 11:21 AM
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 (http://forum.sa-mp.com/showthread.php?t=57018). or just use search.

BullseyeHawk
07/08/2013, 11:35 AM
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.

I am myself one of those 'skilled people', I am building a gamemode by myself trought MySQL only. The only concern I have is that because of the 'old functions' the server would lag if it'd reach a high amount of players. The little stuff about commands/loops to improve into fast executable would really help out. Tought the functions that are always getting updated aren't being used currently (OnPlayerUpdate, etc.) would be able to create network issues if they would start handling big amount of data along with players using commands that start loops.

But, also I am replacing old functions(I never said they are useless, I use strcmp in every bit of the code) with new ones to optimize the code to prevent any network or perfomance issues later on.

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 (http://forum.sa-mp.com/showthread.php?t=57018). or just use search.

I always check those topics, altought I have no idea what to search. As I have no idea what other 'old functions' can be replaced with new faster ones.

BullseyeHawk
07/08/2013, 06:50 PM
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:
for(new i = 0; i < MAX_PLAYERS; i++)
slower then, foreach(Player, i).

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

Scenario
07/08/2013, 07:08 PM
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...

ThePhenix
07/08/2013, 07:29 PM
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.

Scenario
07/08/2013, 07:39 PM
I'm always improving things.

I should know that by now... haha

BullseyeHawk
08/08/2013, 01:56 AM
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.
>> 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.