Author Topic: Server crashes if you call a deleted sprite/textdraw  (Read 3985 times)

0 Members and 1 Guest are viewing this topic.

Offline sseebbyy

  • VC:MP Veteran
  • *****
  • Posts: 774
  • Immortal VC:MP Player
    • View Profile
    • Zombie Invasion => Server Forum [DEAD PROJECT]
Server crashes if you call a deleted sprite/textdraw
« on: September 13, 2014, 01:28:33 am »
I removed a sprite, then I tried to call it back, but the server stopped.
Shouldn't this be avoided ? To not crash the server if the sprite/textdraw doesn't exist...

Quote
Painful/Noob scripters acts like: I Am The Best Scripter Because I Announce My Releases With Big Font Size Without Giving Too Much Info' In The Hope They All Will Download And Check It. I Ignore Bad Replies, Replies That I Could Learn From, And Replies With So Much Text.



Offline heekz.shadow

  • LU testers
  • Made Man
  • *
  • Posts: 249
    • View Profile
Re: Server crashes if you call a deleted sprite/textdraw
« Reply #1 on: September 13, 2014, 02:26:35 am »
The question is: Why would you call a deleted textdraw/sprite ? :)
Code: [Select]
[20:23] <habi> later only i heard that lu chatbox is customizable. On my first visit, it appeared ugly.
[20:23] <habi> May be that also be the reason why lu has no players

Offline sseebbyy

  • VC:MP Veteran
  • *****
  • Posts: 774
  • Immortal VC:MP Player
    • View Profile
    • Zombie Invasion => Server Forum [DEAD PROJECT]
Re: Server crashes if you call a deleted sprite/textdraw
« Reply #2 on: September 13, 2014, 10:24:56 am »
The question is: Why would you call a deleted textdraw/sprite ? :)

I just tested it, but there are other cases...
You can forget that you deleted the sprite/textdraw, and just call it.

Anyway, Gudio gave me some answers:
Quote
<Gudio> its because when you do remove or delete
<Gudio> instance in squirrel lang still exists
<Gudio> but not in cpp
<Seby> ah :/
<Gudio> when you call it again after removing, cpp doesnt know what do to
<Seby> why you just don't set it = null; ?
<Gudio> it needs some error handlers or some hack to set variables automatically to null when instance is the same

Quote
Painful/Noob scripters acts like: I Am The Best Scripter Because I Announce My Releases With Big Font Size Without Giving Too Much Info' In The Hope They All Will Download And Check It. I Ignore Bad Replies, Replies That I Could Learn From, And Replies With So Much Text.



Offline Gudio

  • Street Thug
  • *
  • Posts: 22
    • View Profile
    • Gudio
Re: Server crashes if you call a deleted sprite/textdraw
« Reply #3 on: September 13, 2014, 06:16:04 pm »
You should set null for variables that you remove to avoid crashes in the future.
Example:
Code: [Select]
if ( Timer )
{
Timer.Delete();
Timer = null;
}

Offline sseebbyy

  • VC:MP Veteran
  • *****
  • Posts: 774
  • Immortal VC:MP Player
    • View Profile
    • Zombie Invasion => Server Forum [DEAD PROJECT]
Re: Server crashes if you call a deleted sprite/textdraw
« Reply #4 on: September 14, 2014, 12:39:57 am »
Good idea, thanks ! :)
Topic locked.

Quote
Painful/Noob scripters acts like: I Am The Best Scripter Because I Announce My Releases With Big Font Size Without Giving Too Much Info' In The Hope They All Will Download And Check It. I Ignore Bad Replies, Replies That I Could Learn From, And Replies With So Much Text.