Vice City Multiplayer

VC:MP 0.4 (Beta) => Script Discussion => Topic started by: sseebbyy on September 13, 2014, 01:28:33 am

Title: Server crashes if you call a deleted sprite/textdraw
Post by: sseebbyy 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...
Title: Re: Server crashes if you call a deleted sprite/textdraw
Post by: heekz.shadow on September 13, 2014, 02:26:35 am
The question is: Why would you call a deleted textdraw/sprite ? :)
Title: Re: Server crashes if you call a deleted sprite/textdraw
Post by: sseebbyy 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
Title: Re: Server crashes if you call a deleted sprite/textdraw
Post by: Gudio 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;
}
Title: Re: Server crashes if you call a deleted sprite/textdraw
Post by: sseebbyy on September 14, 2014, 12:39:57 am
Good idea, thanks ! :)
Topic locked.