Vice City Multiplayer
VC:MP 0.4 (Beta) => Script Discussion => Topic started 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...
-
The question is: Why would you call a deleted textdraw/sprite ? :)
-
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:
<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
-
You should set null for variables that you remove to avoid crashes in the future.
Example:
if ( Timer )
{
Timer.Delete();
Timer = null;
}
-
Good idea, thanks ! :)
Topic locked.