Welcome, Guest. Please login or register.

Login with username, password and session length

Advanced search

10 284 Posts in 5 659 Topics- by 1 216 Members - Latest Member: santini862

24 August 2019, 13:33
Select Language English | Russian ru | German
Main PageIRC Client KVIrc forumKVIrc discussionKVIrc scriptingClasses [ Solved ]
Pages: [1]
Author Topic: Classes [ Solved ]  (Read 12567 times)
0 Members and 1 Guest are viewing this topic.

Репутация: 1
Posts: 9

View Profile Email
« on: 20 August 2007, 16:15 »

Hey, I want to implement classes, since I love using OOP in PHP, but I'm having a problem.

In the manual, it says you can check whether a class exists or not by doing if(%class_identifier), however it just returns "object", whether the class exists or not, and so the if statement evaluates to true every time.

Here is the code I have so far:

class (trivia_class) {


event (OnChannelMessage, trivia) {
# Safeguard against looping
if ($my.nick == "TriviaBot") {
if ($find_in_str($3, "trivia", "start") == true) {
if (%Trivia) {
say "Trivia is already running, $0 you douchebag!";
else {
%Trivia = $new(trivia_class,0,trivia);
%Trivia->%initiated = true;
say "Trivia Started";
elseif ($find_in_str($3, "trivia", "stop") == true) {
if (%Trivia) {
delete -i %Trivia;
say "Trivia Stopped";
else {
say "Trivia isn't running, $0 you douchebag!";
elseif ($find_in_str($3, "triviabot", "gtfo") == true) {
part $target;

The if statements which are supposed to check if the object exists or not, evaluate to true every time.

I tried lowercase starting identifier for class, same result.
The 'find_in_str' function is a small piece of code I wrote for finding more than one string in another string, and is not relevant here.

Oh and, I'm using 3.2.4 on Ubuntu 7.04 (Debian Based) i636.

Solved by people on irc, solution to check whether object exists:

Special thanks to thexception Cheesy
« Last Edit: 20 August 2007, 17:06 by Starcraftmazter » Logged
Pages: [1]
Jump to:  

Theme orange-lt created by panic