· 8 years ago · Apr 19, 2018, 08:00 PM
1//===========================Includes==================================
2#include <a_samp>
3#include <a_sampmysql>
4#include <float>
5#include <time>
6#include <file>
7#include <streamer>
8#include <zcmd>
9//Enum pInfo
10enum pInfo
11{
12 pKey,
13}
14//Enum pInfo Finished
15//new's Sections
16static pTrecut[MAX_PLAYERS];
17new A[MAX_PLAYERS];
18new DB:Database;
19new Cash[MAX_PLAYERS];
20//Section defines
21#define COLOR_GRAD2 0xBFC0C2FF
22#define COLOR_YELLOW 0xDABB3EAA
23#define COLOR_YELLOW2 0xF5DEB3AA
24#define SCM SendClientMessage
25#define COLOR_LIGHTRED 0xFF6347AA
26#define COLOR_GREEN 0x9EC73DAA
27#define COLOR_GREY 0xAFAFAFAA
28#define pragma 1
29//=======================forward================================================
30forward split(const strsrc[], strdest[][], delimiter);
31forward OnPlayerRegister(playerid, password[]);
32forward OnPropUpdate();
33forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
34forward SavePlayerData(playerid);
35forward GivePlayerCash(playerid, money);
36forward ClearChatbox(playerid, lines);
37//Timerele folositoare pentru test
38forward Trecut(playerid);
39forward Trecut2(playerid);
40forward IO2(playerid);
41forward IO6(playerid);
42forward IO3(playerid);
43forward IO4(playerid);
44forward A1(playerid);
45forward A2(playerid);
46forward A3(playerid);
47forward A4(playerid);
48//===========================Section: strtok & split============================
49strtok(const string[], &index)
50{
51 new length = strlen(string);
52 while ((index < length) && (string[index] <= ' '))
53 {
54 index++;
55 }
56
57 new offset = index;
58 new result[20];
59 while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
60 {
61 result[index - offset] = string[index];
62 index++;
63 }
64 result[index - offset] = EOS;
65 return result;
66}
67public split(const strsrc[], strdest[][], delimiter)
68{
69 new i, li;
70 new aNum;
71 new len;
72 while(i <= strlen(strsrc)){
73 if(strsrc[i]==delimiter || i==strlen(strsrc)){
74 len = strmid(strdest[aNum], strsrc, li, i, 128);
75 strdest[aNum][len] = 0;
76 li = i+1;
77 aNum++;
78 }
79 i++;
80 }
81 return 1;
82}
83//=========================public =============================================
84public OnFilterScriptInit( )
85{
86Database = db_open( "Carnet.db" );
87db_free_result( db_query( Database, "CREATE TABLE IF NOT EXISTS `Carnet` \
88 ( `pTrecut` INT, )" ) );
89return 1;
90}
91public OnPlayerConnect(playerid)
92{
93 if (pTrecut[playerid] == 0)
94 {
95 SCM(playerid, COLOR_GREEN, "Inca nu ai carnet , dute si ial !");
96 }
97}
98public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
99{
100 if(IsPlayerConnected(playerid))
101 {
102 new Float:oldposx, Float:oldposy, Float:oldposz;
103 new Float:tempposx, Float:tempposy, Float:tempposz;
104 GetPlayerPos(playerid, oldposx, oldposy, oldposz);
105 tempposx = (oldposx -x);
106 tempposy = (oldposy -y);
107 tempposz = (oldposz -z);
108 if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
109 {
110 return 1;
111 }
112 }
113 return 0;
114}
115public GivePlayerCash(playerid, money)
116{
117 Cash[playerid] += money;
118 return Cash[playerid];
119}
120public ClearChatbox(playerid, lines)
121{
122 if (IsPlayerConnected(playerid))
123 {
124 for(new i=0; i<lines; i++)
125 {
126 SendClientMessage(playerid, COLOR_GREY, " ");
127 }
128 }
129 return 1;
130}
131public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
132{
133 if (pTrecut[playerid] == 0)
134 {
135 SCM(playerid, COLOR_GREEN, "Nu ai carnet , dute si ial altfel te prinde politia !!");
136 }
137 return 0;
138}
139//Timerele pentru test==========================================================
140public IO2(playerid)
141{
142 ClearChatbox(playerid, 5);
143 SendClientMessage(playerid, COLOR_YELLOW, "REGULI , CITESTE CU ATENTIE !!!");
144 SendClientMessage(playerid, COLOR_GREEN, "|--------------------|");
145 SendClientMessage(playerid, COLOR_YELLOW2, "Nu se merge pe contrasens deoarece se pot crea");
146 SendClientMessage(playerid, COLOR_YELLOW2, "accidente iar pe contasens se merge doar cand");
147 SendClientMessage(playerid, COLOR_YELLOW2, "celalalta banda este stricata sau in lucru.");
148 SendClientMessage(playerid, COLOR_YELLOW2, "URMARESTE URMATOAREA REGULA");
149 SendClientMessage(playerid, COLOR_GREEN, "_____________________________________________________________________");
150}
151public IO6(playerid)
152{
153 ClearChatbox(playerid, 5);
154 SendClientMessage(playerid, COLOR_GREEN, "|--------------------|");
155 SendClientMessage(playerid, COLOR_YELLOW2, "Daca mergi cu viteza prea mare si te prinde radarul");
156 SendClientMessage(playerid, COLOR_YELLOW2, "ti se va lua carnetul si masina , iar in caz ca ai accidentat");
157 SendClientMessage(playerid, COLOR_YELLOW2, "pe cineva in timpul mersului vei ajunge la JAIL");
158 SendClientMessage(playerid, COLOR_YELLOW2, "URMARESTE URMATOAREA REGULA");
159 SendClientMessage(playerid, COLOR_GREEN, "_____________________________________________________________________");
160}
161public IO3(playerid)
162{
163 ClearChatbox(playerid, 5);
164 SendClientMessage(playerid, COLOR_GREEN, "|--------------------|");
165 SendClientMessage(playerid, COLOR_YELLOW2, "Daca vei participa la o cursa ilegala vei ajunge imediat");
166 SendClientMessage(playerid, COLOR_YELLOW2, "la JAIL impreuna cu prietenii tai de la cursa");
167 SendClientMessage(playerid, COLOR_YELLOW2, "si daca nu te predai vei primi WANTED 10");
168 SendClientMessage(playerid, COLOR_YELLOW2, "URMARESTE URMATOAREA REGULA");
169 SendClientMessage(playerid, COLOR_GREEN, "_____________________________________________________________________");
170}
171public IO4(playerid)
172{
173 SendClientMessage(playerid, COLOR_YELLOW, "|--------------------|");
174 SendClientMessage(playerid, COLOR_YELLOW, "Daca cineva ti-a furat masina suna imediat la 911");
175 SendClientMessage(playerid, COLOR_YELLOW, "si va fi recuperata !");
176 SendClientMessage(playerid, COLOR_YELLOW2, "Sfarsitul Regulilor , ai grija la test !!!");
177 SendClientMessage(playerid, COLOR_GREEN, "_____________________________________________________________________");
178 SetTimerEx("A1", 5000, 0, "d", playerid);
179}
180public A1(playerid)
181{
182 A[playerid] = 1;
183 ClearChatbox(playerid, 6);
184 SendClientMessage(playerid, COLOR_LIGHTRED, "|_______________________________Intrebareaa 1____________________________|");
185 SendClientMessage(playerid, COLOR_GREEN, "Daca banda este continua poti face la stanga?");
186 SendClientMessage(playerid, COLOR_YELLOW, "Adevarat.");
187 SendClientMessage(playerid, COLOR_YELLOW, "Fals.");
188 SendClientMessage(playerid, COLOR_LIGHTRED, "|_______________________________________________________________________________|");
189 SendClientMessage(playerid, COLOR_LIGHTRED, " ");
190 SendClientMessage(playerid, COLOR_LIGHTRED, " ");
191}
192public A2(playerid)
193{
194 A[playerid] = 2;
195 ClearChatbox(playerid, 5);
196 SendClientMessage(playerid, COLOR_LIGHTRED, "|__________________________________Intrebarea 2________________________|");
197 SendClientMessage(playerid, COLOR_GREEN, "Ce se poate intampla daca ai fost prins la viteza excesiva?");
198 SendClientMessage(playerid, COLOR_YELLOW, "1: Nimic , sunt regele soselelor.");
199 SendClientMessage(playerid, COLOR_YELLOW, "2: Fug in continuu de politie.");
200 SendClientMessage(playerid, COLOR_YELLOW, "3: Scot arma si trag ");
201 SendClientMessage(playerid, COLOR_YELLOW, "4: Mi se va lua carnetul sau chiar masina.");
202 SendClientMessage(playerid, COLOR_LIGHTRED, "|_______________________________________________________________________________|");
203 SendClientMessage(playerid, COLOR_LIGHTRED, " ");
204}
205public A3(playerid)
206{
207 A[playerid] = 3;
208 ClearChatbox(playerid, 5);
209 SendClientMessage(playerid, COLOR_LIGHTRED, "|_________________________Intrebarea 3__________________________|");
210 SendClientMessage(playerid, COLOR_GREEN, "Ce se intampla daca participi la o cursa ilegala si te-a prins radarul?");
211 SendClientMessage(playerid, COLOR_YELLOW, "1: Plec cu premiul acasa.");
212 SendClientMessage(playerid, COLOR_YELLOW, "2: Sun un prieten apropiat ca sa petrecem.");
213 SendClientMessage(playerid, COLOR_YELLOW, "3: Ma voi ascunde de politie.");
214 SendClientMessage(playerid, COLOR_YELLOW, "4: Voi ajunge la Jail fara carnet si fara masina.");
215 SendClientMessage(playerid, COLOR_LIGHTRED, "|_______________________________________________________________|");
216 SendClientMessage(playerid, COLOR_LIGHTRED, " ");
217}
218public A4(playerid)
219{
220 A[playerid] = 4;
221 ClearChatbox(playerid, 5);
222 SendClientMessage(playerid, COLOR_LIGHTRED, "|_________________________Intrebarea 4__________________________|");
223 SendClientMessage(playerid, COLOR_GREEN, "Daca ti s-a furat masian ce faci?");
224 SendClientMessage(playerid, COLOR_YELLOW, "1: Sun la 911 , departamentul politiei.");
225 SendClientMessage(playerid, COLOR_YELLOW, "2: Scot un ShotGun de la chiloti si il omor.");
226 SendClientMessage(playerid, COLOR_YELLOW, "3: O iau pe jos cu tramvaiul.");
227 SendClientMessage(playerid, COLOR_YELLOW, "4: Nu ma intereseaza , mai am 5 masini.");
228 SendClientMessage(playerid, COLOR_LIGHTRED, "|_______________________________________________________________|");
229 SendClientMessage(playerid, COLOR_LIGHTRED, " ");
230}
231public OnPlayerText(playerid, text[])
232{
233 new tmp[256];
234
235 if(A[playerid] > 0)
236 {
237 if(A[playerid] == 1)
238 {
239 new idx;
240 tmp = strtok(text, idx);
241 if((strcmp("2", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("2")))
242 {
243 SendClientMessage(playerid, COLOR_YELLOW2, "Corect");
244 SetTimerEx("A2", 5000, 0, "d", playerid);
245 return 0;
246 }
247 else
248 {
249 SetPlayerPos(playerid, 1944.8649,2069.2163,10.8203);
250 SetPlayerInterior(playerid, 0);
251 GameTextForPlayer(playerid, "~r~ Picat", 5000, 3);
252 SendClientMessage(playerid, COLOR_LIGHTRED, "Incorect");
253 A[playerid] = 0;
254 }
255 return 0;
256 }
257 else if(A[playerid] == 2)
258 {
259 new idx;
260 tmp = strtok(text, idx);
261 if((strcmp("4", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("4")))
262 {
263 SendClientMessage(playerid, COLOR_YELLOW2, "Corect");
264 SetTimerEx("A3", 5000, 0, "d", playerid);
265 return 0;
266 }
267 else
268 {
269 SetPlayerPos(playerid, 1944.8649,2069.2163,10.8203);
270 SetPlayerInterior(playerid, 0);
271 GameTextForPlayer(playerid, "~r~ Picat", 5000, 3);
272 SendClientMessage(playerid, COLOR_LIGHTRED, "Incorect");
273 A[playerid] = 0;
274 }
275 return 0;
276 }
277 else if(A[playerid] == 3)
278 {
279 new idx;
280 tmp = strtok(text, idx);
281 if((strcmp("4", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("4")))
282 {
283 SendClientMessage(playerid, COLOR_YELLOW2, "Corect");
284 SetTimerEx("A4", 5000, 0, "d", playerid);
285 return 0;
286 }
287 else
288 {
289 SetPlayerPos(playerid, 1944.8649,2069.2163,10.8203);
290 SetPlayerInterior(playerid, 0);
291 GameTextForPlayer(playerid, "~r~ Picat", 5000, 3);
292 SendClientMessage(playerid, COLOR_LIGHTRED, "Incorect");
293 A[playerid] = 0;
294 }
295 return 0;
296 }
297 else if(A[playerid] == 4)
298 {
299 new idx;
300 tmp = strtok(text, idx);
301 if((strcmp("1", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("1")))
302 {
303 SendClientMessage(playerid, COLOR_YELLOW2, "Corect");
304 SetPlayerPos(playerid, 1944.8649,2069.2163,10.8203);
305 SetPlayerInterior(playerid, 0);
306 SendClientMessage(playerid, COLOR_LIGHTRED, "___________________________________");
307 SendClientMessage(playerid, COLOR_YELLOW, "Finalul Examenului");
308 SendClientMessage(playerid, COLOR_GREEN, "Ai trecut primul text cu succes !.");
309 GameTextForPlayer(playerid, "~g~ Aprobat", 5000, 3);
310 pTrecut[playerid] = 1;
311 GivePlayerCash(playerid, -100);
312 SetTimerEx("Trecut", 3600 * 1000, false, "i", playerid);
313 }
314 else
315 {
316 SetPlayerPos(playerid, 1944.8649,2069.2163,10.8203);
317 SetPlayerInterior(playerid, 0);
318 GameTextForPlayer(playerid, "~r~ Picat", 5000, 3);
319 SendClientMessage(playerid, COLOR_LIGHTRED, "Picat");
320 A[playerid] = 0;
321 }
322 return 0;
323 }
324 }
325 return 1;
326}
327//===================================CMDS(ZCMD)=================================
328 CMD:exam(playerid, params[])
329 {
330 if(IsPlayerConnected(playerid))
331 {
332 if(PlayerToPoint(2.0, playerid,1412.8313,-1700.3066,13.5395))
333 {
334 SetPlayerInterior(playerid,3);
335 SetPlayerPos(playerid, 321.6462,164.1290,1014.1797);
336 GameTextForPlayer(playerid, "~r~Citeste instructiunile",5000,3);
337 SetTimerEx("IO2", 6000, 0, "d", playerid);
338 SetTimerEx("IO6", 11000, 0, "d", playerid);
339 SetTimerEx("IO3", 16000, 0, "d", playerid);
340 SetTimerEx("IO4", 21000, 0, "d", playerid);
341 }
342 }
343 }