|
|
#61 | ||
|
Beta Tester
![]() ![]() ![]() ![]() ![]() Join Date: Jun 2008
Location: 629
Posts: 13,235
Reputation: 1900
|
Quote:
Quote:
|
||
|
|
|
|
|
#62 | |
|
Gangsta
![]() ![]() ![]() ![]() Join Date: Jul 2011
Posts: 919
Reputation: 338
|
You are right about the evidence I presented being rather weak. From the first moment on, I was intrigued how weird it would be to clock a hundred if-checks against calls to format and CallLocalFunction. But eventually they would be designed to do the same thing IF I was to make the code call a function in every if statement scope. However since it is quite late, I cannot even be bothered to write something that'll generate such code for me, I only did I partially.
http://pastebin.com/eArP5Ahk (and no, this isn't the test from before, although to compensate it only a little bit, I still pass the same amount of values to the DLG_%d function) I also tested it so the dialog ID varies, going from 0 to 99. In such cases, the difference between the timings will be smaller (the second method is only ~1.7 times slower than the first one). If the test is flawed, please let me know. Quote:
Mine has been running for a few years now and during the time, the time I've spent tweaking existing code according to tips from the SA-MP community, is very long. For example, I have also implemented the code from ZCMD.inc into my gamemode's main file. Why? So I can change it to my needs and integrate it with my command system a bit more thoroughly without losing efficiency there. Zeex's approach to scripters is very user-friendly by providing a few callbacks and the overhead from calling them can be reduced by implementing it in your mode. In the position of someone who has an entirely unique idea and wants to put it into code without having to worry about "ugh, how do I most conveniently use dialogs", I would definitely use the most user-friendly library. As for the post about when to optimize, I entirely agree! |
|
|
|
|
|
|
#63 |
|
Gangsta
![]() ![]() ![]() ![]() Join Date: Jan 2012
Location: The Arab Republic of Egypt
Posts: 668
Reputation: 105
|
You've been given good methods for defining dialogs and they work efficiently, I'll give you one more method which I prefer though. Hmm what about writing an special include file for dialogs? Let me explain:
Open up notepad and put something like this: pawn Code:
Save as .inc (Include File) then put this file into your pawno include folder. After that open up your a_samp include file then include the dialogs inc file there: pawn Code:
So as soon as you include a_samp, the dialogs inc file will be included as well. So, whenever you want to add/remove a dialog, you'll just have to go to the dialogs inc file and define/un-define it there. Now you can easily use your dialogs in any script that includes the a_samp we modified above: pawn Code:
The same can be done with virtual worlds and such things. |
|
|
|
|
|
#64 |
|
Beta Tester
![]() ![]() ![]() ![]() ![]() Join Date: Jun 2008
Location: 629
Posts: 13,235
Reputation: 1900
|
You shouldn't modify the original includes.
|
|
|
|
|
|
#65 |
|
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Jan 2010
Location: England
Posts: 2,104
Reputation: 157
|
HellSphinX comes in with the left hook, but Y_Less takes him down with a right!
Sorry... anyway @HellSphinX It would be better if you put that in a new include. That way you don't 'lose' the defines when the server version updates, and it makes sure that you don't break original includes. |
|
|
|
|
|
#66 | |
|
Gangsta
![]() ![]() ![]() ![]() Join Date: Feb 2011
Location: Amsterdam, Holland
Posts: 563
Reputation: 61
|
Quote:
BTW changing MAX_PLAYERS to MP doesn't make any sence. |
|
|
|
|
|
|
#67 |
|
Beta Tester
![]() ![]() ![]() ![]() ![]() Join Date: Jun 2008
Location: 629
Posts: 13,235
Reputation: 1900
|
|
|
|
|
|
|
#68 | |
|
Gangsta
![]() ![]() ![]() ![]() Join Date: Jan 2012
Location: The Arab Republic of Egypt
Posts: 668
Reputation: 105
|
Would you mind telling me what could happen (or what issue could it cause)?
It's done to make it simpler, so you just include a_samp (which is needed in any script except npcs) instead of including dialogs (or any special include file you ever made) in every script you want to use those dialogs in. Edit: Quote:
Well, waiting for Y_Less' reply to know if it's illegal or something. |
|
|
|
|
|
|
#69 |
|
Beta Tester
![]() ![]() ![]() ![]() ![]() Join Date: Jun 2008
Location: 629
Posts: 13,235
Reputation: 1900
|
Its not illegal, its just not generally done. Those are provided for you to write your own scripts with and can change without warning, meaning you will loose all your custom code. Why not do it the other way round? Include a_samp from your include and then only ever include your include instead.
Also, if you ever release your mode it won't compile for other people as they won't modify their a_samp. |
|
|
|
|
|
#70 | |
|
Gangsta
![]() ![]() ![]() ![]() Join Date: Jan 2012
Location: The Arab Republic of Egypt
Posts: 668
Reputation: 105
|
Quote:
I personally never had a problem with it being included from the a_samp include though. Edit: Or you can use #tryinclude. Last edited by [KHK]Khalid; 03/08/2012 at 06:15 PM. |
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| BRAUCHE SCRIPTING HILFE / NEED SCRIPTING HELP | Killer_Slowly | Archive | 6 | 03/05/2012 11:21 AM |
| Scripting | Luis- | Everything and Nothing | 27 | 08/12/2011 09:58 AM |
| Scripting help | santiclaws | Help Archive | 5 | 18/01/2010 03:41 PM |
| Help!- not for scripting | Darkly_Face | Help Archive | 3 | 13/01/2010 01:27 PM |
| Scripting Help for New server, moved to scripting disscussion | Guardian | Help Archive | 2 | 03/06/2009 06:29 AM |