-
Notifications
You must be signed in to change notification settings - Fork 1
/
CasinoSystem.sp
145 lines (111 loc) · 3.65 KB
/
CasinoSystem.sp
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include <sourcemod>
#include <shop>
#define MAX_GAME 50
#pragma tabsize 0
Database g_hDB;
int g_iId[MAXPLAYERS + 1]; // Уникальный id игрока
int g_iChips[MAXPLAYERS + 1]; // Кол-во Фишек у игрока (Основная валюта)
bool g_bUsedConverter; // Используется ли система конвертирования
bool g_bUsedAdminSystem; // Используется ли Админ-Система
bool g_bClientIsPlaying[MAXPLAYERS + 1]; // Играет ли игрок в данный момент
//Settings
bool g_bAllowedInvite[MAXPLAYERS + 1][MAX_GAME];
ConVar sm_casino_admin_flag;
int g_iAdminFlag;
public Plugin myinfo =
{
name = "[Casino System] Core",
author = "Rostu",
description = "",
version = "1.0",
url = "https://vk.com/rostu13"
};
// --------- Статистика -------
/*
int g_iTotal[MAXPLAYERS + 1];
int g_iWin[MAXPLAYERS +1];
int g_iLost[MAXPLAYERS + 1];
*/
#include "CasinoSystem/database.sp"
#include "CasinoSystem/forwards.sp"
#include "CasinoSystem/menu.sp"
#include "CasinoSystem/menu_hndlrs.sp"
#include "CasinoSystem/natives.sp"
public APLRes AskPluginLoad2(Handle myself, bool blate, char[] sError, int err_max)
{
Casino_CreateNative();
return APLRes_Success;
}
public void OnPluginStart()
{
Casino_CreateForwards();
Casino_DBConnect();
sm_casino_admin_flag = CreateConVar("sm_casino_admin_flag", "z","Флаг для доступа к Админ меню");
RegConsoleCmd("sm_casino",Cmd_Casino);
RegConsoleCmd("sm_game",Cmd_Casino);
RegConsoleCmd("sm_games",Cmd_Casino);
RegConsoleCmd("sm_ruletka",Cmd_Casino);
LoadTranslations("casino_system.phrases");
}
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{
if (convar == sm_casino_admin_flag)
{
g_iAdminFlag = sm_casino_admin_flag.IntValue;
return;
}
}
public void OnConfigsExecuted()
{
g_bUsedConverter = false;
g_bUsedAdminSystem = false;
char sPath[200];
BuildPath(Path_SM, sPath, sizeof sPath, "plugins/CasinoConverter");
if(DirExists(sPath)) g_bUsedConverter = true;
BuildPath(Path_SM, sPath, sizeof sPath, "plugins/CasinoAdmin");
if(DirExists(sPath)) g_bUsedAdminSystem = true;
g_iAdminFlag = GetConVarAdminFlag(sm_casino_admin_flag);
}
public void OnClientPostAdminCheck(int iClient)
{
char sAuth[32];
char sQuery[128];
GetClientAuthId(iClient,AuthId_Steam2,sAuth,sizeof sAuth);
FormatEx(sQuery,sizeof sQuery,"SELECT * FROM `casino_players` WHERE auth = '%s'",sAuth);
DB_TQuery(ClientConnect_CallBack,sQuery,GetClientUserId(iClient));
}
public Action Cmd_Casino(int iClient, int args)
{
OpenMainMenu(iClient);
}
void ListPlayer (Menu menu, bool bCheckGame)
{
for(int x = 1; x<= MaxClients; x++)
{
if(IsClientInGame(x) && !IsFakeClient(x) )
{
char sName[46];
char sUserId[16];
GetClientName(x,sName,sizeof sName);
Format(sName,sizeof sName,"%s [%d]",sName,g_iChips[x]);
IntToString(GetClientUserId(x),sUserId,sizeof sUserId);
menu.AddItem(sUserId,sName,!CheckIsGame ? ITEMDRAW_DEFAULT : g_bClientIsPlaying[x] ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);
}
}
}
char[] GetBalanse (int iClient)
{
char sBuffer[128];
FormatEx(sBuffer,sizeof sBuffer,"Ваш баланс:\nФишек: %d\nКредитов: %d \n ",g_iChips[iClient],Shop_GetClientCredits(iClient));
return sBuffer;
}
// Vip by R1ko
int GetConVarAdminFlag(ConVar &hCvar)
{
char sBuffer[16];
hCvar.GetString(sBuffer,sizeof sBuffer);
return ReadFlagString(sBuffer);
}
bool CheckIsGame(int iClient)
{
}