Guest User

Untitled

a guest
Jan 22nd, 2012
923
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.99 KB | None | 0 0
  1. #include <YSI\y_ini>
  2. #include <sscanf2>
  3. #include <zcmd>
  4. // PRAGMA_--
  5. #pragma tabsize 0
  6. // DEFINES_--
  7. #define SCRIPT_VERSION "BSRP"
  8. #define DIALOGO_LOGIN 700
  9. #define DIALOGO_REGISTRO 701
  10. #define TERMS_OF_USE 702
  11.  
  12. // MACROS_--
  13. #define function%0(%1) forward %0(%1); public %0(%1)
  14. // NEW'S_--
  15.  
  16. new gPlayerLogTries[MAX_PLAYERS], gPlayerLogged[MAX_PLAYERS];
  17. new BigEar[MAX_PLAYERS];
  18.  
  19. // COLORS_--
  20. #define COLOR_GRAD2 0xBFC0C2FF
  21. #define COLOR_GREY 0xAFAFAFAA
  22. #define COLOR_FADE1 0xE6E6E6E6
  23. #define COLOR_FADE2 0xC8C8C8C8
  24. #define COLOR_FADE3 0xAAAAAAAA
  25. #define COLOR_FADE4 0x8C8C8C8C
  26. #define COLOR_FADE5 0x6E6E6E6E
  27.  
  28. // ENUMS_--
  29. enum pInfo
  30. {
  31. pKey[64],
  32. pLevel,
  33. pAdmin,
  34. pConnectTime,
  35. pCash,
  36. };
  37. new PlayerInfo[MAX_PLAYERS][pInfo];
  38. new playername[MAX_PLAYER_NAME];
  39. // CBACKS_--
  40. SpaceInUser(playerid, const string[])
  41. {
  42. if(IsPlayerConnected(playerid))
  43. {
  44. if(strfind(string, "=", true) != -1) return 0;
  45. else if(strfind(string, "\n", true) != -1) return 0;
  46. else return 1;
  47. }
  48. return 0;
  49. }
  50. main()
  51. {
  52. print(" Gamemode Iniciado ");
  53. }
  54.  
  55.  
  56. public OnGameModeInit()
  57. {
  58. SetGameModeText("ReplayHD");
  59. AddPlayerClass(0,2512.8611,-1673.2799,13.5104,87.7485,0,0,0,0,0,0);
  60. return 1;
  61. }
  62. public OnPlayerConnect(playerid)
  63. {
  64. new string[128];
  65. new PlayerN[MAX_PLAYERS]; GetPlayerName(playerid, PlayerN, sizeof(PlayerN));
  66.  
  67.  
  68. SetPlayerCameraPos(playerid,1614.3577,-2272.5510,13.5153);
  69. SetPlayerCameraLookAt(playerid,1614.3815,-2277.4917,13.5153);
  70. BigEar[playerid] = 0;
  71. SetPVarString(playerid, "pPass", "0") ;
  72. format(string, sizeof(string), "users/%s.ini", PlayerN);
  73.  
  74. if(INI_Exist(PlayerNombre(playerid))) ShowLoginDialog(playerid);
  75. else ShowRegisterDialog(playerid);
  76. return 1;
  77. }
  78.  
  79. function OnPlayerLogin(playerid)
  80. {
  81. if(PlayerInfo[playerid][pAdmin] > 0)
  82. SendClientMessage(playerid, -1, "Te-ai logat ca si admin");
  83. else
  84. SendClientMessage(playerid, -1, "Te-ai logat ca si user");
  85.  
  86. TermsOfUse(playerid);
  87. return 1;
  88. }
  89.  
  90. function ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  91. {
  92. if(IsPlayerConnected(playerid))
  93. {
  94. new Float:posx, Float:posy, Float:posz;
  95. new Float:oldposx, Float:oldposy, Float:oldposz;
  96. new Float:tempposx, Float:tempposy, Float:tempposz;
  97. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  98. //radi = 2.0; //Trigger Radius
  99. for(new i = 0; i < MAX_PLAYERS; i++)
  100. {
  101. if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
  102. {
  103. if(!BigEar[i])
  104. {
  105. GetPlayerPos(i, posx, posy, posz);
  106. tempposx = (oldposx -posx);
  107. tempposy = (oldposy -posy);
  108. tempposz = (oldposz -posz);
  109. if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  110. {
  111. SendClientMessage(i, col1, string);
  112. }
  113. else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  114. {
  115. SendClientMessage(i, col2, string);
  116. }
  117. else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  118. {
  119. SendClientMessage(i, col3, string);
  120. }
  121. else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  122. {
  123. SendClientMessage(i, col4, string);
  124. }
  125. else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  126. {
  127. SendClientMessage(i, col5, string);
  128. }
  129. }
  130. else
  131. {
  132. SendClientMessage(i, col1, string);
  133. }
  134. }
  135. }
  136. }//not connected
  137. return 1;
  138. }
  139.  
  140. function OnPlayerRegister(playerid, password[])
  141. {
  142. if(IsPlayerConnected(playerid))
  143. {
  144. new
  145. PlayerFile[ 13 + MAX_PLAYER_NAME ];
  146.  
  147. format( PlayerFile , sizeof PlayerFile, "users/%s.ini", PlayerNombre(playerid));
  148.  
  149. new
  150. INI:PlayerAcc = INI_Open( PlayerFile );
  151.  
  152. strmid(PlayerInfo[playerid][pKey], password, 0, strlen(password), 64);
  153. INI_WriteString(PlayerAcc, "Password", PlayerInfo[playerid][pKey]);
  154. SetPlayerPos(playerid, 1730.3131,-2238.5420,13.5422);
  155. printf("Cont %s's Inregistrat .",PlayerNombre(playerid));
  156.  
  157. INI_Close(PlayerAcc);
  158.  
  159. INI_ParseFile( PlayerFile, "LoadUser", false, true, playerid, true, false );
  160.  
  161. OnPlayerLogin(playerid);
  162. }
  163. return 1;
  164. }
  165. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  166. {
  167. new string[128];
  168.  
  169. if(dialogid == DIALOGO_LOGIN)
  170. {
  171. if (response)
  172. {
  173. if ( strlen( inputtext ) == 0 )
  174. {
  175. ShowLoginDialog(playerid);
  176. SendClientMessage(playerid, COLOR_GRAD2, "Pune parola pentru a te loga.");
  177. return 1; }
  178.  
  179.  
  180. new
  181. PlayerFile[ 13 + MAX_PLAYER_NAME ], PlayerPass[ 129 ];
  182.  
  183. format( PlayerFile , sizeof PlayerFile, "users/%s.ini", PlayerNombre(playerid));
  184. INI_ParseFile( PlayerFile, "IdentificarPass", .bExtra = true, .extra = playerid );
  185. GetPVarString( playerid, "pPass", PlayerPass, 129 );
  186.  
  187. if(!strcmp(PlayerPass, inputtext))
  188. {
  189. format( PlayerFile , sizeof PlayerFile, "users/%s.ini", PlayerNombre(playerid));
  190. INI_ParseFile( PlayerFile, "LoadUser", false, true, playerid, true, false );
  191. OnPlayerLogin(playerid);
  192. }
  193. else
  194. {
  195. ShowLoginDialog(playerid);
  196. gPlayerLogTries[playerid] ++;
  197. format(string, sizeof(string), "Error: Parola gresita, Incercari {FF0000}(%d/3", gPlayerLogTries[playerid]);
  198. SendClientMessage(playerid, COLOR_GRAD2, string);
  199. SendClientMessage(playerid, COLOR_GRAD2, "Daca ti-ai uitat parola intra pe forum. (forum.com).");
  200. if(gPlayerLogTries[playerid] == 9)
  201. {
  202. SendClientMessage(playerid, COLOR_GRAD2, "Server Closed Connection");
  203. Kick(playerid);
  204. }
  205. }
  206. }
  207. else
  208. {
  209. SendClientMessage(playerid, COLOR_GRAD2, "Probleme cu logarea ? Intra pe forum (forum.com).");
  210. Kick(playerid);
  211. }
  212. }
  213.  
  214. if(dialogid == TERMS_OF_USE)
  215. {
  216. if(response)
  217. {
  218. gPlayerLogged[playerid] = 1;
  219.  
  220.  
  221. SpawnPlayer(playerid);
  222. }
  223. else TermsOfUse(playerid);
  224. }
  225. if(dialogid == DIALOGO_REGISTRO)
  226. {
  227. if (response)
  228. {
  229. if (sscanf(inputtext, "s[20]", inputtext[0]))
  230. {
  231. SendClientMessage(playerid, COLOR_GRAD2, "Doar 6-20 Litere.");
  232. ShowRegisterDialog(playerid); return 1;
  233. }
  234.  
  235. if (strlen(inputtext) < 6 || strlen(inputtext) > 20 )
  236. {
  237. SendClientMessage(playerid, COLOR_GRAD2, "Doar 6-20 Litere.");
  238. ShowRegisterDialog(playerid); return 1;
  239. }
  240. if(SpaceInUser(playerid, inputtext) == 1)
  241. {
  242. OnPlayerRegister(playerid, inputtext);
  243. }
  244. else
  245. {
  246.  
  247. SendClientMessage(playerid, COLOR_GRAD2, "Doar 6-20 Litere.");
  248. ShowRegisterDialog(playerid);
  249. }
  250. }
  251. else
  252. {
  253. SendClientMessage(playerid, COLOR_GRAD2, "Multumim ca ne-ai vizitat ! Te mai asteptam !");
  254. Kick(playerid);
  255. }
  256. }
  257.  
  258. return 1;
  259. }
  260. stock TermsOfUse(playerid)
  261. {
  262. new INFORMACION[] =" \n {45F86C} Cititi regulamentul de pe forum.com ";
  263. SetPlayerHealth(playerid, 50);
  264. ShowPlayerDialog(playerid, TERMS_OF_USE,DIALOG_STYLE_MSGBOX, "{FFFFFF}ReplayHD - Information", INFORMACION, "Play", "" );
  265. }
  266. PlayerNombre( playerid )
  267. {
  268. new xName[ MAX_PLAYER_NAME ];
  269. GetPlayerName( playerid, xName, sizeof( xName ) );
  270. return xName;
  271. }
  272.  
  273. INI_Exist(nickname[])
  274. {
  275. new tmp[128];
  276. format(tmp,sizeof(tmp),"users/%s.ini", nickname);
  277. return fexist(tmp);
  278. }
  279.  
  280. ShowLoginDialog(playerid)
  281. {
  282. new
  283. title[] = "ReplayHD - Login",
  284. string[512],
  285. str[128]
  286. ;
  287.  
  288. strcat(string, "Bun venit pe ReplayHD");
  289. format(str, sizeof str, "\n{FFFFFF}Contul tau: %s \n\t\t Deja inregistrat!! \n\t Connect!", PlayerNombre(playerid));
  290. strcat(string, str);
  291.  
  292. ShowPlayerDialog(playerid, DIALOGO_LOGIN, DIALOG_STYLE_INPUT, title, string, "Login", "Iesi");
  293. return 1;
  294. }
  295. ShowRegisterDialog(playerid)
  296. {
  297. new
  298. title[] = "ReplayHD - Login",
  299. string[512],
  300. str[128]
  301. ;
  302.  
  303. strcat(string, "Welcome to: ReplayHD");
  304. format(str, sizeof str, "{FFFFFF}Introdu parola pentru a te loga %s", PlayerNombre(playerid));
  305. strcat(string, str);
  306.  
  307. ShowPlayerDialog(playerid, DIALOGO_REGISTRO, DIALOG_STYLE_INPUT, title, string, "Register", "Iesi");
  308. return 1;
  309. }
  310. public OnPlayerSpawn(playerid)
  311. {
  312. if(gPlayerLogged[playerid] == 0)
  313. {
  314. SendClientMessage(playerid, COLOR_GRAD2, "** ReplayHD: Trebuie sa te inregistrezi pentru a te juca **");
  315. Kick(playerid);
  316. }
  317. return 1;
  318. }
  319. function LoadUser(playerid, name[], value[])
  320. {
  321. INI_Int( "Level", PlayerInfo[playerid][pLevel]);
  322. INI_Int( "Staff_Level", PlayerInfo[playerid][pAdmin]);
  323. INI_Int( "ConnectTime", PlayerInfo[playerid][pConnectTime]);
  324. INI_Int( "Money", PlayerInfo[playerid][pCash] );
  325. return 0;
  326. }
  327. function OnPlayerText(playerid, text[])
  328. {
  329. new sendername[MAX_PLAYER_NAME];
  330. new string[128];
  331. GetPlayerName(playerid, sendername, sizeof(sendername));
  332. format(string,sizeof(string),"%s Says: %s", sendername,text);
  333. ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
  334. return 0;
  335. }
  336.  
  337. function IdentificarPass( playerid, name[ ], value[ ] )
  338. {
  339. if ( ! strcmp( name, "Password" ) ) SetPVarString( playerid, "pPass", value ) ;
  340. }
  341. function OnPlayerUpdateTime(playerid)
  342. {
  343. if(INI_Exist(PlayerNombre(playerid)) && gPlayerLogged[playerid] == 1)
  344. {
  345. new
  346. PlayerFile[ 13 + MAX_PLAYER_NAME + 1];
  347.  
  348. format( PlayerFile , sizeof PlayerFile, "users/%s.ini", PlayerNombre(playerid));
  349.  
  350. new
  351. INI:PlayerAcc = INI_Open( PlayerFile );
  352. INI_WriteInt( PlayerAcc, "Staff_Level", PlayerInfo[playerid][pAdmin] );
  353. INI_WriteInt( PlayerAcc, "Level", PlayerInfo[playerid][pLevel] );
  354. INI_WriteInt( PlayerAcc, "ConnectTime", PlayerInfo[playerid][pConnectTime] );
  355. INI_WriteInt( PlayerAcc, "Money", GetPlayerMoney( playerid ) );
  356. INI_Close( PlayerAcc );
  357. }
  358. return 1;
  359. }
  360. Log(sz_fileName[], sz_input[]) {
  361.  
  362. new
  363. sz_logEntry[156],
  364. i_dateTime[2][3],
  365. File: fileHandle = fopen(sz_fileName, io_append);
  366.  
  367. gettime(i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2]);
  368. getdate(i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2]);
  369.  
  370. format(sz_logEntry, sizeof(sz_logEntry), "[%i/%i/%i - %i:%i:%i] %s\r\n", i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2], i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2], sz_input);
  371. fwrite(fileHandle, sz_logEntry);
  372. return fclose(fileHandle);
  373. }
  374. // COMENZI_--
  375. CMD:makeadmin(playerid, params[]){
  376. if(PlayerInfo[playerid][pAdmin] <= 3) return SendClientMessage(playerid, COLOR_GREY, "Nu esti admin");
  377. if(!sscanf(params, "ui", params[0], params[1])){
  378. new string[128];
  379. PlayerInfo[params[0]][pAdmin] = params[1];
  380. format(string, sizeof(string), "ATENTIE: Ii dai lui: %s Admin level: %d",PlayerNombre(params[0]), params[1]);
  381. SendClientMessage(playerid, COLOR_GRAD2, string);
  382. Log("logs/Cadministrativos.log", string);
  383. OnPlayerUpdateTime(playerid);
  384. } else SendClientMessage(playerid, COLOR_GRAD2, "FOLOSIRE: /makeadmin <ID> <Level>.");
  385. return 1;
  386. }
  387. CMD:givemoney(playerid, params[]){
  388. if(PlayerInfo[playerid][pAdmin] <= 3) return SendClientMessage(playerid, COLOR_GREY, "Nu esti un admin.");
  389. if(!sscanf(params, "ui", params[0], params[1])){
  390. GivePlayerMoney(params[0], params[1]);
  391. } else SendClientMessage(playerid, COLOR_GRAD2, "FOLOSIRE: /givemoney <ID> <Value>.");
  392. return 1;
  393. }
  394. CMD:ah(playerid, params[]){
  395. if(PlayerInfo[playerid][pAdmin] <= 3) return SendClientMessage(playerid, COLOR_GREY, "Nu esti un admin");
  396. SendClientMessage(playerid, COLOR_GRAD2, "Admin Help");
  397. SendClientMessage(playerid, COLOR_GRAD2, "/makeadmin /bigears /givemoney");
  398. return 1;
  399. }
  400. public OnGameModeExit()
  401. {
  402. return 1;
  403. }
  404. public OnPlayerRequestClass(playerid, classid)
  405. {
  406. SetPlayerPos(playerid, 2167.0342, -1672.6652, 15.0757);
  407. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  408. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  409. return 1;
  410. }
  411.  
  412. public OnPlayerDisconnect(playerid, reason)
  413. {
  414. return 1;
  415. }
  416. public OnPlayerDeath(playerid, killerid, reason)
  417. {
  418. return 1;
  419. }
  420.  
  421. public OnVehicleSpawn(vehicleid)
  422. {
  423. return 1;
  424. }
  425.  
  426. public OnVehicleDeath(vehicleid, killerid)
  427. {
  428. return 1;
  429. }
  430. public OnPlayerCommandText(playerid, cmdtext[])
  431. {
  432. if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  433. {
  434. // Do something here
  435. return 1;
  436. }
  437. return 0;
  438. }
  439.  
  440. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  441. {
  442. return 1;
  443. }
  444.  
  445. public OnPlayerExitVehicle(playerid, vehicleid)
  446. {
  447. return 1;
  448. }
  449.  
  450. public OnPlayerStateChange(playerid, newstate, oldstate)
  451. {
  452. return 1;
  453. }
  454.  
  455. public OnPlayerEnterCheckpoint(playerid)
  456. {
  457. return 1;
  458. }
  459.  
  460. public OnPlayerLeaveCheckpoint(playerid)
  461. {
  462. return 1;
  463. }
  464.  
  465. public OnPlayerEnterRaceCheckpoint(playerid)
  466. {
  467. return 1;
  468. }
  469.  
  470. public OnPlayerLeaveRaceCheckpoint(playerid)
  471. {
  472. return 1;
  473. }
  474.  
  475. public OnRconCommand(cmd[])
  476. {
  477. return 1;
  478. }
  479.  
  480. public OnPlayerRequestSpawn(playerid)
  481. {
  482. return 1;
  483. }
  484.  
  485. public OnObjectMoved(objectid)
  486. {
  487. return 1;
  488. }
  489.  
  490. public OnPlayerObjectMoved(playerid, objectid)
  491. {
  492. return 1;
  493. }
  494.  
  495. public OnPlayerPickUpPickup(playerid, pickupid)
  496. {
  497. return 1;
  498. }
  499.  
  500. public OnVehicleMod(playerid, vehicleid, componentid)
  501. {
  502. return 1;
  503. }
  504.  
  505. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  506. {
  507. return 1;
  508. }
  509.  
  510. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  511. {
  512. return 1;
  513. }
  514.  
  515. public OnPlayerSelectedMenuRow(playerid, row)
  516. {
  517. return 1;
  518. }
  519.  
  520. public OnPlayerExitedMenu(playerid)
  521. {
  522. return 1;
  523. }
  524.  
  525. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  526. {
  527. return 1;
  528. }
  529.  
  530. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  531. {
  532. return 1;
  533. }
  534.  
  535. public OnRconLoginAttempt(ip[], password[], success)
  536. {
  537. return 1;
  538. }
  539.  
  540. public OnPlayerUpdate(playerid)
  541. {
  542. return 1;
  543. }
  544.  
  545. public OnPlayerStreamIn(playerid, forplayerid)
  546. {
  547. return 1;
  548. }
  549.  
  550. public OnPlayerStreamOut(playerid, forplayerid)
  551. {
  552. return 1;
  553. }
  554.  
  555. public OnVehicleStreamIn(vehicleid, forplayerid)
  556. {
  557. return 1;
  558. }
  559.  
  560. public OnVehicleStreamOut(vehicleid, forplayerid)
  561. {
  562. return 1;
  563. }
  564. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  565. {
  566. return 1;
  567. }
Advertisement
Add Comment
Please, Sign In to add comment