Hi any idea why do we do this?
#1

Hello!

im wondering from quite long why do we destroy textdraws OnGameModeExit while the textdraws will destroy themself when gamemode shuts.

About more i asked in scripting help. didnt got any satisfying reply. consider reading this too thanks!

https://sampforum.blast.hk/showthread.php?tid=577707
Reply
#2

So you can restart gamemode with rcon command gmx, without recreating same textdraws on top of the old ones.

EDIT: nvm, it's not true, I just tested it, and indeed global textdraws are destroyed automatically when gamemode exists, not when server closes.
Reply
#3

Oh thanks for your efforts mate
Reply
#4

bump ._.
Reply
#5

I destroy those textdraws so they don't bug when I restart the server (for me).
Reply
#6

How will they even bug? when the gamemode exit arent they suppose to destroy themself? and when the gamemode intialises again they ll re create themself?
Reply
#7

its common practice to run "clean up" code when exiting any app.

its simple if you dont want to destroy them then dont...
if the abstract machine("server") gets shut down surly everything will be closed/destroyed.

I still will destroy mine.
Reply
#8

What makes the difference if i destroy or not tho? (im not taunting or trolling)

I just need to make sure my coding practices are as optimized as they can be.
Reply
#9

Quote:
Originally Posted by [ND]xXZeusXx.
View Post
What makes the difference if i destroy or not tho? (im not taunting or trolling)

ill start up with an rpg script soon this year which will have lot of textdraws... so i want it to be completely optimized and stuff like that.
Okay, say you have 10 textdraws. For some reason, your server crashes, shuts down, restarts, whatever - and for some reason, only 4 textdraws get destroyed. When your mode starts up again, it's going to create all 10, this leads to either a) misplaced textdraw ID's or b) multiple textdraws for one ID. Either of these options aren't good, and should be prevented, which destroying them on exit does. As stated above, in programming a common practice is to run clean up code after an operation is finished.
Reply
#10

Quote:
Originally Posted by 2KY
View Post
Okay, say you have 10 textdraws. For some reason, your server crashes, shuts down, restarts, whatever - and for some reason, only 4 textdraws get destroyed. When your mode starts up again, it's going to create all 10, this leads to either a) misplaced textdraw ID's or b) multiple textdraws for one ID. Either of these options aren't good, and should be prevented, which destroying them on exit does. As stated above, in programming a common practice is to run clean up code after an operation is finished.
Afaik theres no way to restart the gamemode in the same server process after a fatal crash. If the gamemode doesnt shut down properly (deleting all the textdraws) it also wont start up again, unless the server is restarted.

I guess its some placebo code, or a code artefact. There shouldnt be a scenario in which you need to "clean up" the textdraws manually on gamemode exit.
Different story for filterscripts though. Properly deleting textdraws in filterscripts is important, especially for filterscripts that are supposed to be stopped/restarted frequently, else it will create the same textdraws again and again.
So deleting textdraws in gamemodes probably comes from that. People just copied over some filterscript textdraws, and also added the cleanup part without further thinking about why they are doing it. Others might then have learned from those gamemodes, and took over that "scripting technique" for textdraws in gamemodes. Not because they need to do it, but because many other people did so before.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)