Help with function library

Started by GangstaRas, Oct 15, 2017, 11:47 PM

Previous topic - Next topic

DizzasTeR

Quote from: GangstaRas on Oct 16, 2017, 07:49 PM
Quote from: aXXo on Oct 16, 2017, 06:12 PM...

Nice, this particular code though (filled out the parameters) gave me the error " trying to set 'class' "

Welcome to VCMP client side scripting. Just for a brief explanation, the client side script itself is a huge class scope, I believe SLC had already pointed this out and it was supposed to be fixed but I guess it didn't happen. Basically either declare local vars on top or declare global vars and prefix with ::

GangstaRas

Quote from: Thijn on Oct 17, 2017, 06:39 AM
Quote from: GangstaRas on Oct 16, 2017, 07:49 PM
Quote from: aXXo on Oct 16, 2017, 06:12 PMYou could use this:
http://forum.vc-mp.org/?topic=2765.0


You could also wrap your code in try {} catch() and print the error if it encounters.

function Script::ScriptLoad()
{
     try
     {
          mySprite = GUISprite("Filename.png", VectorScreen(x, y));
     }
     catch(error)
          Console.Print("Error encountered in Script::ScriptLoad() " + error );
}

Nice, this particular code though (filled out the parameters) gave me the error " trying to set 'class' "
You'd probably have to declare that mysprite somewhere. Just add local mysprite = null; to the top of your script.


Nah that still errored out, IceFlake method seemed to work instead

But thanks for the advice guys, I think this wraps it up until I get stuck again, but I should be able to make stuff now with all this info