Warning System Script


#21

its to late i think i should go sleep :laughing:


#22

Hey me again :joy:
now i want to test if db entry exist and if not i want to create it.
How can i check if an db entry exist (Number)?
I tried:

if ($.getSetIniDbNumber('my_db_table', 'test') == undefined){
	$.say("I have it");
}

#23

Describes all of the API calls for the INIDB, including what they do and what they return.


#24

i asked nothing :zipper_mouth_face:


#25

I spent a while on that particular page, is why I referenced it :slight_smile:

The $.getSetIniDBNumber() you are calling retrieves a value or sets it if it doesn’t exist. That would probably do what you want, but if you want to check to see if it was set prior (for displaying in chat I suppose) you would use:

boolean $.inidb.exists(String table_name, String key)
Returns true is the key exists in table_name.

You do need an additional parameter though for:
int $.getSetIniDbNumber(String table_name, String key, int defaultValue)

The above is what we use in many instances when setting initial values in the database in modules.


#26

Many thanks @IllusionaryOne that you spent your time on that. :smiley:

Maybe you can answer my last question.

The last thing i not know how to do that.
I want to reset the keys when the streamer went offline.
I know that i can ask if the streamer is offline but that didn’t help i think or can i solve it some this way ?

Or do i can use any change event to check if “variable” changed ?


#27

I want to perform an value search for an int value.
I tried:

  • At first
    if (command.equalsIgnoreCase('delwarnall')){
    var warnsys_test = $.inidb.searchByValue('warnSystem', 1);
    $.say(warnsys_test);
    }
    
    The error:
    [07-26-2017 @ 01:39:00.107 GMT] [ERROR] [init.js:318] (hook.call, command, ./custom/warnSys.js) InternalError: Java class "[Ljava.lang.String;" has no public instance field or method named "startsWith". (misc.js#116)
    

  • And after that:
    if (command.equalsIgnoreCase('delwarnall')){
    	var warnsys_test = $.inidb.searchByValue('warnSystem', '1');
    	$.say(warnsys_test);
    }
    
    With this error:
    [07-26-2017 @ 01:40:41.761 GMT] [ERROR] [init.js:318] (hook.call, command, ./custom/warnSys.js) InternalError: Java class "[Ljava.lang.String;" has no public instance field or method named "startsWith". (misc.js#116)
    

What am i doing wrong ?


#28

You’re not sending a string to $.say, you’re sending an array. Please read more about the functions that you are using and Rhino.

As stated in the docs, $.inidb.searchByValue() returns a string array (String[]).


#29

Is this finished ?? Id love this system on my bot


#30

Not completely I still didn’t build in that when the streamer went offline it automatically clear the Database.
And the Language files I didn’t managed to build in