-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScript.h
43 lines (31 loc) · 1.3 KB
/
Script.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2012 Las Venturas Playground. All rights reserved.
// Use of this source code is governed by the GPLv2 license, a copy of which can
// be found in the LICENSE file.
#pragma once
typedef struct tagAMX AMX;
class Script {
public:
explicit Script(AMX* runtime)
: runtime_(runtime)
, OnConnectionAttempt_index_(0)
, OnQueryError_index_(0)
{
}
// Allows to Script objects to be compared with each other.
inline bool operator==(Script& script) {
return runtime_ == script.runtime_;
}
public:
// forward OnConnectionAttempt(connectionId, bool: succeeded, server[], username[], errno, error[]);
int OnConnectionAttempt(unsigned int connectionId, bool succeeded, const char* server, const char* username, int error_number, const char* error);
// forward OnQueryError(connectionId, query[], callback[], errno, error[]);
int OnQueryError(unsigned int connectionId, const char* query, const char* callback, int error_number, const char* error);
// forward MyCallback(resultId, dataId);
int Callback(const char* callbackName, int resultId, int dataId);
private:
// Maintain the position of the callbacks inside the scripts -- this is initialized lazily.
int OnConnectionAttempt_index_;
int OnQueryError_index_;
// Store the actual script that we're dealing with as well.
AMX* runtime_;
};