· 6 years ago · Apr 16, 2019, 07:04 PM
1#include <a_samp>
2#include <a_mysql>
3
4main(){}
5
6native WP_Hash(buffer[], len, const str[]);
7//Forwardy
8forward bool:IsStrValid(const string[]);
9
10//Ustawienia
11#define MONEY_MONEY_START 2500
12
13//Dialogi
14#define REGISTER1_DIALOG 0
15#define LOGIN_DIALOG 1
16#define REGISTER2_DIALOG 2
17#define REGISTER3_DIALOG 3
18//Definicje
19#define SKRYPT_NAME "Najlepszy Polski Serwer"
20#define SKRYPT_VER "V1.0.0"
21#define INFO_STRING "{008080}[INFO]{C0C0C0}: "
22#define ERROR_STRING "{FF0000}[BÅÄ„D]{800000}: "
23
24#define GENDER_MALE 0
25#define GENDER_FEMALE 1
26
27
28 //textdrawy
29new Text:SkinSelector_Title;
30new Text:SkinSelector_Right;
31new Text:SkinSelector_Left;
32new Text:SkinSelector_Accept;
33
34
35
36
37//eNUMY
38enum DataPlayer
39{
40 bool:LoggedIn,
41 bool:ShowMouse,
42 Cache:Cache_ID,
43 UID,
44 Password[129],
45 Age,
46 Lvl,
47 Gender,
48 IDSkin,
49 Money,
50 AdminLV,
51
52 //Wybierałka
53 SelectedIDSkin
54};
55new Player[MAX_PLAYERS][DataPlayer];
56new MySQL:SQL_ID;
57 //Zmienne Globalne
58new Skins_Male[][] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 33, 34, 35, 36, 37, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 57, 58, 59, 60, 61, 62, 66, 67, 68, 70, 71, 72, 73, 74, 78, 79, 80, 81, 82, 83, 84, 86, 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, 132, 133, 134, 135, 136, 137, 142, 143, 144, 146, 147, 149, 153, 154, 155, 156, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 170, 171, 173, 174, 175, 176, 177, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 200, 202, 203, 204, 206, 208, 209, 210, 212, 213, 220, 221, 222, 223, 227, 228, 229, 230, 234, 235, 236, 239, 240, 241, 242, 247, 248, 249, 250, 252, 253, 254, 255, 258, 259, 260, 261, 262, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 299, 300, 301, 302, 303, 304, 305, 310, 311}; //Facety
59new Skins_Female[][] = {9, 10, 11, 12, 13, 31, 38, 39, 40, 41, 53, 54, 55, 56, 63, 64, 65,69,75, 76, 77, 85, 87, 88, 89, 90, 91, 92, 93, 129, 130, 131,138, 139, 140, 141, 145, 148, 150, 151, 152, 157, 169, 172, 178, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 201, 205, 207, 211, 214, 215, 216, 217, 218, 219, 224, 225, 226, 231, 232, 233, 237, 238, 243, 244, 245, 246, 251, 256, 257, 263, 298, 306, 307, 308, 309};
60
61
62public OnGameModeInit()
63{
64 UsePlayerPedAnims();
65
66 for(new idskinow=0; idskinow < 311; idskinow++)
67 {
68 AddPlayerClass(idskinow, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0);
69 }
70 printf("Gamemode %s %s ® by Kreto Wystartował", SKRYPT_NAME, SKRYPT_VER);
71 if(MySQL_Init())
72 {
73 //Wczytywanie
74 MySQL_SetUpTables();
75 CreateGlobalTD();
76
77 //Timer
78 SetTimer("SecondUpdate", 1000, true);
79
80
81 printf("Gamemode %s %s ® by Kreto działa\n", SKRYPT_NAME, SKRYPT_VER);
82 }
83 return 1;
84}
85
86public OnGameModeExit()
87{
88 mysql_close(SQL_ID);
89 return 1;
90}
91
92public OnPlayerRequestSpawn(playerid)
93{
94
95 return 1;
96}
97
98public OnPlayerRequestClass(playerid, classid)
99{
100 SpawnPlayer(playerid);
101 return 1;
102}
103
104public OnPlayerConnect(playerid)
105{
106 ClearPlayerChat(playerid);
107 SetSpawnInfo(playerid, NO_TEAM, 181, 1248.2993,-1563.6338,12.6017, 186.4331, 0, 0, 0, 0, 0, 0);
108 return 1;
109}
110
111
112public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
113{
114 switch(dialogid)
115 {
116 case REGISTER3_DIALOG: // Rejestracja wiek
117 {
118 if(IsNumeric(inputtext) && strlen(inputtext) == 2 && strval(inputtext) >= 13 && strval(inputtext) <= 30 )
119 {
120 Player[playerid][Age] = strval(inputtext);
121 Player[playerid][Age] = strval(inputtext);
122 SetPlayerPos(playerid, 2324.3662, -1148.7382, 1050.7101);
123 SetPlayerInterior(playerid, 12);
124 SetPlayerFacingAngle(playerid, 359.6589);
125 InterpolateCameraPos(playerid, 2324.4150, -1138.6611, 1051.4922, 2324.3513, -1144.7060, 1050.7031, 5000, CAMERA_CUT);
126 InterpolateCameraLookAt(playerid, 2324.3662, -1148.7382, 1050.7101, 2324.3513, -1144.7360, 1050.7031, 5000, CAMERA_CUT);
127 Player[playerid][SelectedIDSkin] = 0;
128 new sskin = Player[playerid][SelectedIDSkin];
129 if(Player[playerid][Gender] == GENDER_MALE)
130 {
131 SetPlayerSkin(playerid, Skins_Male[sskin][0]);
132 Player[playerid][IDSkin] = Skins_Male[sskin][0];
133 }
134 else
135 {
136 SetPlayerSkin(playerid, Skins_Female[sskin][0]);
137 Player[playerid][IDSkin] = Skins_Female[sskin][0];
138 }
139 TextDrawShowForPlayer(playerid, SkinSelector_Title);
140 TextDrawShowForPlayer(playerid, SkinSelector_Accept);
141 TextDrawShowForPlayer(playerid, SkinSelector_Right);
142 TextDrawShowForPlayer(playerid, SkinSelector_Left);
143 }
144 else
145 {
146 ShowPlayerDialog(playerid, REGISTER3_DIALOG, DIALOG_STYLE_INPUT, "Rejestracja", "Podaj swój wiek", "Akceptuj", "Opuść Serwer");
147 SendClientMessage(playerid, -1, ERROR_STRING"Żeby zagrać musisz mieć 13-30 lat!");
148 }
149 }
150 case REGISTER2_DIALOG: // Rejestracja wybór Gender
151 {
152 Player[playerid][Gender] = response;
153 ShowPlayerDialog(playerid, REGISTER3_DIALOG, DIALOG_STYLE_INPUT, "Rejestracja", "Podaj swój wiek", "Akceptuj", "Opuść Serwer");
154 }
155 case REGISTER1_DIALOG: //zAKÅADNIE KONTA
156 {
157 if(strlen(inputtext) >= 6 && IsStrValid(inputtext))
158 {
159 WP_Hash(Player[playerid][Password], 129, inputtext);
160 ShowPlayerDialog(playerid, REGISTER2_DIALOG, DIALOG_STYLE_MSGBOX, "Rejestracja", "Wybierz swoją przynależność sexualną.", "Mężczyzna", "Kobieta");
161 }
162 else
163 {
164 ShowPlayerDialog(playerid, REGISTER1_DIALOG, DIALOG_STYLE_PASSWORD, "REJESTRACJA", "Aby zagrać na serwerze, prosimy stwórz konto. \nHasło proszę wpisać poniżej", "Akceptuj", "Anuluj");
165 SendClientMessage(playerid, -1, ERROR_STRING"Hasło powinno zawierać min. 8 zanków, nie może zawierać przerw ani znaków specjalnych!!");
166 }
167 }
168 }
169 return 0;
170}
171
172public OnPlayerSpawn(playerid)
173{
174 new query[258];
175 if(Player[playerid][LoggedIn] == false)
176 {
177 // nie zalogowany
178 SetPlayerInterior(playerid, 12);
179 SetPlayerPos(playerid, 2324.3040, -1135.8479, 1051.3047);
180 SetPlayerFacingAngle(playerid, 180.2658);
181 SetPlayerVirtualWorld(playerid, 50 + playerid);
182 SetPlayerCameraPos(playerid, 2324.5247, -1138.4045, 1050.4990);
183 SetPlayerCameraLookAt(playerid, 2324.3040, -1135.8479, 1051.3047);
184 TogglePlayerControllable(playerid, false);
185 ShowPlayerMouse(playerid, true);
186 mysql_format(SQL_ID, query, sizeof query, "SELECT * FROM players_accounts WHERE Login = '%s' LIMIT 1", PlayerName(playerid));
187 mysql_tquery(SQL_ID, query, "OnAccountCheck", "i", playerid);
188 }
189 else
190 {
191 //zalogowany
192
193 }
194 return 1;
195}
196
197//CALLBACK MYSQL
198forward OnAccountCheck(playerid);
199public OnAccountCheck (playerid)
200{
201 if(cache_num_rows() > 0)
202 {
203 //konto odnalezione
204 cache_get_value(0, "password", Player[playerid][Password], 129);
205 Player[playerid][Cache_ID] = cache_save();
206 ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Logowanie", "Znaleźliśmy rejestrację Twojego konta. /nPodaj hasło aby zagrać.", "Logowanie", "Opuść Serwer");
207 }
208 else
209 {
210 //Konton nie odnalezione
211 ShowPlayerDialog(playerid, REGISTER1_DIALOG, DIALOG_STYLE_PASSWORD, "REJESTRACJA", "Aby zagrać na serwerze, prosimy stwórz konto. \nHasło proszę wpisać poniżej", "Akceptuj", "Anuluj");
212 }
213 return 1;
214}
215
216 stock IsNumeric(const string[])
217{
218 for (new i = 0, j = strlen(string); i < j; i++)
219 {
220 if (string[i] > '9' || string[i] < '0') return 0;
221 }
222 return 1;
223}
224
225
226
227stock bool:IsStrValid(const string[])
228{
229 new num;
230 new len = strlen(string);
231 for(new i; i < len; i++)
232 switch(string[i])
233 {
234 case 'A'..'Z':num++;
235 case 'a'..'z':num++;
236 case '0'..'9':num++;
237 }
238 if(num == len) return true;
239 else return false;
240}
241
242//Timery
243forward SecondUpdate();
244public SecondUpdate()
245{
246 for(new playerid, j = GetPlayerPoolSize(); playerid <= j; playerid++)
247 {
248 if(IsPlayerConnected(playerid))
249 {
250 if(Player[playerid][ShowMouse])
251 {
252 ShowPlayerMouse(playerid, true);
253 }
254 }
255 }
256 return 1;
257}
258
259//STOCKI
260stock PlayerName(playerid)
261{
262 new name[MAX_PLAYER_NAME];
263 GetPlayerName(playerid, name, sizeof name);
264 return name;
265}
266
267forward ShowPlayerMouse(playerid, bool:show);
268public ShowPlayerMouse(playerid, bool:show)
269{
270 if(show)
271 {
272 SelectTextDraw(playerid, -1);
273 Player[playerid][ShowMouse] = true;
274 }
275 else
276 {
277 CancelSelectTextDraw(playerid);
278 Player[playerid][ShowMouse] = false;
279 }
280 return 1;
281}
282
283stock ClearPlayerChat(playerid)
284{
285 for(new i; i < 15; i++)
286 SendClientMessage(playerid, -1, " ");
287 return 1;
288}
289
290stock MySQL_SetUpTables ()
291{
292 mysql_tquery(SQL_ID, " CREATE TABLE IF NOT EXISTS `Players Accounts` ( \
293 `uid` INT(11) NOT NULL AUTO_INCREMENT, \
294 `Login` TEXT NOT NULL COLLATE 'utf8_polish_ci', \
295 `password` TEXT NOT NULL COLLATE 'utf8_polish_ci', \
296 `ID Skina` INT(11) NOT NULL, \
297 `money` INT(11) NOT NULL DEFAULT '0', \
298 `gender` INT(11) NOT NULL, \
299 `age` INT(11) NOT NULL, \
300 `lvl` INT(11) NOT NULL DEFAULT '1', \
301 `admin lv` INT(11) NOT NULL DEFAULT '0', \
302 `lastip` TEXT NOT NULL COLLATE 'utf8_polish_ci', \
303 `lastonline` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, \
304 `createdate` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, \
305 PRIMARY KEY (`uid`))");
306 return 1;
307}
308
309stock MySQL_Init()
310{
311 mysql_log();
312 SQL_ID = mysql_connect_file("mysql.ini");
313 if(SQL_ID == MYSQL_INVALID_HANDLE ||mysql_errno(SQL_ID) != 0)
314 {
315 print("[MYSQL - BLAD] Nie można było połączyć się z bazą danych! Serwer wyłączony ..!");
316 SendRconCommand("exit");
317 return 0;
318 }
319 print("[MYSQL] Połączenie z bazą danych zostało nawiązane!");
320 return 1;
321}
322
323
324stock CreateGlobalTD()
325{
326 SkinSelector_Title = TextDrawCreate(316.000000, 370.000000, "WYBIERZ POSTAC");
327 TextDrawFont(SkinSelector_Title, 2);
328 TextDrawLetterSize(SkinSelector_Title, 0.291666, 2.049999);
329 TextDrawTextSize(SkinSelector_Title, 400.000000, 405.000000);
330 TextDrawSetOutline(SkinSelector_Title, 1);
331 TextDrawSetShadow(SkinSelector_Title, 0);
332 TextDrawAlignment(SkinSelector_Title, 2);
333 TextDrawColor(SkinSelector_Title, -1378294017);
334 TextDrawBackgroundColor(SkinSelector_Title, 255);
335 TextDrawBoxColor(SkinSelector_Title, 50);
336 TextDrawUseBox(SkinSelector_Title, 0);
337 TextDrawSetProportional(SkinSelector_Title, 1);
338 TextDrawSetSelectable(SkinSelector_Title, 0);
339
340 SkinSelector_Right = TextDrawCreate(351.000000, 392.000000, ">>>");
341 TextDrawFont(SkinSelector_Right, 2);
342 TextDrawLetterSize(SkinSelector_Right, 0.258332, 1.750000);
343 TextDrawTextSize(SkinSelector_Right, 16.500000, 33.500000);
344 TextDrawSetOutline(SkinSelector_Right, 1);
345 TextDrawSetShadow(SkinSelector_Right, 0);
346 TextDrawAlignment(SkinSelector_Right, 2);
347 TextDrawColor(SkinSelector_Right, -1);
348 TextDrawBackgroundColor(SkinSelector_Right, 255);
349 TextDrawBoxColor(SkinSelector_Right, 76);
350 TextDrawUseBox(SkinSelector_Right, 1);
351 TextDrawSetProportional(SkinSelector_Right, 1);
352 TextDrawSetSelectable(SkinSelector_Right, 1);
353
354 SkinSelector_Left = TextDrawCreate(281.000000, 392.000000, "<<<");
355 TextDrawFont(SkinSelector_Left, 2);
356 TextDrawLetterSize(SkinSelector_Left, 0.258332, 1.750000);
357 TextDrawTextSize(SkinSelector_Left, 16.500000, 33.500000);
358 TextDrawSetOutline(SkinSelector_Left, 1);
359 TextDrawSetShadow(SkinSelector_Left, 0);
360 TextDrawAlignment(SkinSelector_Left, 2);
361 TextDrawColor(SkinSelector_Left, -1);
362 TextDrawBackgroundColor(SkinSelector_Left, 255);
363 TextDrawBoxColor(SkinSelector_Left, 76);
364 TextDrawUseBox(SkinSelector_Left, 1);
365 TextDrawSetProportional(SkinSelector_Left, 1);
366 TextDrawSetSelectable(SkinSelector_Left, 1);
367
368 SkinSelector_Accept = TextDrawCreate(316.000000, 392.000000, "OK");
369 TextDrawFont(SkinSelector_Accept, 2);
370 TextDrawLetterSize(SkinSelector_Accept, 0.258332, 1.750000);
371 TextDrawTextSize(SkinSelector_Accept, 16.500000, 23.500000);
372 TextDrawSetOutline(SkinSelector_Accept, 1);
373 TextDrawSetShadow(SkinSelector_Accept, 0);
374 TextDrawAlignment(SkinSelector_Accept, 2);
375 TextDrawColor(SkinSelector_Accept, -1);
376 TextDrawBackgroundColor(SkinSelector_Accept, 255);
377 TextDrawBoxColor(SkinSelector_Accept, 76);
378 TextDrawUseBox(SkinSelector_Accept, 1);
379 TextDrawSetProportional(SkinSelector_Accept, 1);
380 TextDrawSetSelectable(SkinSelector_Accept, 1);
381 return 1;
382}