Advertisement
Guest User

main roleplay

a guest
Sep 12th, 2016
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.10 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <YSI\y_ini.inc>
  7. #include <ZCMD>
  8. #include <sscanf2>
  9.  
  10. #define DIALOG_REGISTER 1
  11. #define DIALOG_LOGIN 2
  12. #define DIALOG_SUCCESS_1 3
  13. #define DIALOG_SUCCESS_2 4
  14. #define SERVER_NAME "Main Roleplay"
  15.  
  16. #define COL_WHITE "{FFFFFF}"
  17. #define COL_RED "{F81414}"
  18. #define COL_GREEN "{00FF22}"
  19. #define COL_LIGHTBLUE "{00CED1}"
  20. #define COLOR_PURPLE 0xC2A2DAAA
  21.  
  22. #define PATH "conturi/%s.ini"
  23.  
  24. enum pInfo
  25. {
  26. pPass,
  27. pCash,
  28. pAdmin,
  29. pKills,
  30. pDeaths,
  31. DT,
  32. DTT
  33. }
  34. new PlayerInfo[MAX_PLAYERS][pInfo];
  35.  
  36. forward dttimer(playerid);
  37. forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
  38. forward OnPlayerHealthChange(playerid, Float:newhealth, Float:oldhealth);
  39.  
  40. main()
  41. {
  42. print("\n----------------------------------");
  43. print(" MAIN ROLEPLAY NETWORK 0.1 [BETA] ");
  44. print("----------------------------------\n");
  45. }
  46.  
  47. public OnGameModeInit()
  48. {
  49. // Don't use these lines if it's a filterscript
  50. SetGameModeText("Main-RP 0.1[BETA]");
  51. return 1;
  52. }
  53.  
  54. public OnGameModeExit()
  55. {
  56. return 1;
  57. }
  58.  
  59. public OnPlayerRequestClass(playerid, classid)
  60. {
  61. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  62. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  63. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  64. return 1;
  65. }
  66.  
  67. public OnPlayerConnect(playerid)
  68. {
  69. if(fexist(UserPath(playerid)))
  70. {
  71. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  72. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Bine ai revenit!",""COL_WHITE"Contul acesta este deja inregistrat.\nIntrodu-ti parola in caseta de mai jos.","LOGARE","IESI");
  73. }
  74. else
  75. {
  76. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Bine ai venit!",""COL_WHITE"Bine ai venit pe "SERVER_NAME". Contul acesta nu este inregistrat.\nIntrodu-ti parola in caseta de mai jos pentru a te inregistra.","CREEAZA","IESI");
  77. }
  78. return 1;
  79. }
  80.  
  81. public OnPlayerDisconnect(playerid, reason)
  82. {
  83. new INI:File = INI_Open(UserPath(playerid));
  84. INI_SetTag(File,"data");
  85. INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  86. INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  87. INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
  88. INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
  89. INI_Close(File);
  90. return 1;
  91. }
  92.  
  93. public OnPlayerSpawn(playerid)
  94. {
  95. return 1;
  96. }
  97.  
  98. public OnPlayerDeath(playerid, killerid, reason)
  99. {
  100. return 1;
  101. }
  102.  
  103. public OnVehicleSpawn(vehicleid)
  104. {
  105. return 1;
  106. }
  107.  
  108. public OnVehicleDeath(vehicleid, killerid)
  109. {
  110. return 1;
  111. }
  112.  
  113. public OnPlayerText(playerid, text[])
  114. {
  115. new string[128];
  116. if(strfind(text, "?", true) != -1)
  117. {
  118. new msg[128];
  119. format(msg, sizeof(msg), "%s intreaba: %s");
  120. ProxDetector(50.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  121. }
  122. if(strfind(text, "!", true) != -1)
  123. {
  124. new msg[128];
  125. format(msg, sizeof(msg), "%s striga: %s");
  126. ProxDetector(50.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  127. }
  128. new msg[128];
  129. format(msg, sizeof(msg), "%s spune: %s");
  130. ProxDetector(50.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  131. return 1;
  132. }
  133.  
  134. /*CMD:acceptdeath(playerid, params[])
  135. {
  136. if(!PlayerInfo[playerid][DT] == 1) return SendClientMessage(playerid, 0xfffffff, "Nu esti in deathtimer!");
  137. if(!PlayerInfo[playerid][DTT] == 1) return SendClientMessage(playerid, 0xfffffff, "Nu au trecut 120 secunde!");
  138. SetPlayerPos(playerid,317.2694,54.9657,3.3750);
  139. SendClientMessage(playerid, 0xfffffff, "Un medic care nu era la datorie te-a gasit si te-a dus la el acasa.");
  140. SendClientMessage(playerid, 0xfffffff, "Acolo ti-a oferit primul ajutor iar acum te simti bine!");
  141. TogglePlayerControllable(playerid, 1);
  142. PlayerInfo[playerid][DT] = 0;
  143. return 1;
  144. }*/
  145.  
  146. CMD:acceptdeath(playerid, params[]) {
  147. if(PlayerInfo[playerid][DT] != 1)
  148. return SendClientMessage(playerid, 0xfffffff, "Nu esti in deathtimer!");
  149. if(PlayerInfo[playerid][DTT] != 1) return SendClientMessage(playerid, 0xfffffff, "Nu au trecut 120 secunde!");
  150. SetPlayerPos(playerid,317.2694,54.9657,3.3750);
  151. SendClientMessage(playerid, 0xfffffff, "Un medic care nu era la datorie te-a gasit si te-a dus la el acasa.");
  152. SendClientMessage(playerid, 0xfffffff, "Acolo ti-a oferit primul ajutor iar acum te simti bine!");
  153. TogglePlayerControllable(playerid, 1);
  154. PlayerInfo[playerid][DT] = 0;
  155. return 1;
  156. }
  157.  
  158.  
  159. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  160. {
  161. return 1;
  162. }
  163.  
  164. public OnPlayerExitVehicle(playerid, vehicleid)
  165. {
  166. return 1;
  167. }
  168.  
  169. public OnPlayerStateChange(playerid, newstate, oldstate)
  170. {
  171. return 1;
  172. }
  173.  
  174. public OnPlayerEnterCheckpoint(playerid)
  175. {
  176. return 1;
  177. }
  178.  
  179. public OnPlayerLeaveCheckpoint(playerid)
  180. {
  181. return 1;
  182. }
  183.  
  184. public OnPlayerEnterRaceCheckpoint(playerid)
  185. {
  186. return 1;
  187. }
  188.  
  189. public OnPlayerLeaveRaceCheckpoint(playerid)
  190. {
  191. return 1;
  192. }
  193.  
  194. public OnRconCommand(cmd[])
  195. {
  196. return 1;
  197. }
  198.  
  199. public OnPlayerCommandPerformed(playerid, cmdtext[], success)
  200. {
  201. return 1;
  202. }
  203.  
  204. public OnPlayerHealthChange(playerid, Float:newhealth, Float:oldhealth)
  205. {
  206. if(newhealth > 20)
  207. {
  208. TogglePlayerControllable(playerid,0);
  209. new Text3D:label = Create3DTextLabel("(( JUCATORUL ESTE RANIT. IN-CHARACTER ESTE PE JOS. ))", 0x008080FF, 30.0, 40.0, 50.0, 40.0, 0);
  210. Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.7);
  211. SendClientMessage(playerid, 0xff00000, "Ai intrat in DEATH-TIMER! Peste 120 secunde vei putea folosii /deathtimer.");
  212. SetTimerEx("dttimer", 120000, false, "i", playerid);
  213. PlayerInfo[playerid][DT] = 1;
  214. PlayerInfo[playerid][DTT] = 1;
  215. }
  216. return 1;
  217. }
  218.  
  219. public dttimer(playerid)
  220. {
  221. SendClientMessage(playerid, 0xff00000, "Au trecut 120 secunde. Acum poti da /acceptdeath.");
  222. PlayerInfo[playerid][DTT] = 0;
  223. }
  224.  
  225. public OnPlayerRequestSpawn(playerid)
  226. {
  227. return 1;
  228. }
  229.  
  230. public OnObjectMoved(objectid)
  231. {
  232. return 1;
  233. }
  234.  
  235. public OnPlayerObjectMoved(playerid, objectid)
  236. {
  237. return 1;
  238. }
  239.  
  240. public OnPlayerPickUpPickup(playerid, pickupid)
  241. {
  242. return 1;
  243. }
  244.  
  245. public OnVehicleMod(playerid, vehicleid, componentid)
  246. {
  247. return 1;
  248. }
  249.  
  250. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  251. {
  252. return 1;
  253. }
  254.  
  255. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  256. {
  257. return 1;
  258. }
  259.  
  260. public OnPlayerSelectedMenuRow(playerid, row)
  261. {
  262. return 1;
  263. }
  264.  
  265. public OnPlayerExitedMenu(playerid)
  266. {
  267. return 1;
  268. }
  269.  
  270. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  271. {
  272. return 1;
  273. }
  274.  
  275. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  276. {
  277. return 1;
  278. }
  279.  
  280. public OnRconLoginAttempt(ip[], password[], success)
  281. {
  282. return 1;
  283. }
  284.  
  285. public OnPlayerUpdate(playerid)
  286. {
  287. return 1;
  288. }
  289.  
  290. public OnPlayerStreamIn(playerid, forplayerid)
  291. {
  292. return 1;
  293. }
  294.  
  295. public OnPlayerStreamOut(playerid, forplayerid)
  296. {
  297. return 1;
  298. }
  299.  
  300. public OnVehicleStreamIn(vehicleid, forplayerid)
  301. {
  302. return 1;
  303. }
  304.  
  305. public OnVehicleStreamOut(vehicleid, forplayerid)
  306. {
  307. return 1;
  308. }
  309.  
  310. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  311. {
  312. switch( dialogid )
  313. {
  314. case DIALOG_REGISTER:
  315. {
  316. if (!response) return Kick(playerid);
  317. if(response)
  318. {
  319. if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_RED"EROARE",""COL_RED"Nu ai introdus o parola"COL_WHITE".\n"COL_WHITE"Introdu-ti parola mai jos pentru a te inregistra.","Register","Quit");
  320. new INI:File = INI_Open(UserPath(playerid));
  321. INI_SetTag(File,"data");
  322. INI_WriteInt(File,"Password",udb_hash(inputtext));
  323. INI_WriteInt(File,"Cash",0);
  324. INI_WriteInt(File,"Admin",0);
  325. INI_WriteInt(File,"Kills",0);
  326. INI_WriteInt(File,"Deaths",0);
  327. INI_Close(File);
  328.  
  329. SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
  330. SpawnPlayer(playerid);
  331. ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"SUCCES!",""COL_GREEN"Cont inregistrat\n"COL_WHITE"Ai fost inregistrat cu succes. Acum te poti juca pe server.","Continua","");
  332. }
  333. }
  334.  
  335. case DIALOG_LOGIN:
  336. {
  337. if ( !response ) return Kick ( playerid );
  338. if( response )
  339. {
  340. if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
  341. {
  342. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  343. GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
  344. ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"SUCCES!",""COL_GREEN"Te-ai logat\n"COL_WHITE"Acum te poti juca. Spor la joc!","Continua","");
  345. }
  346. else
  347. {
  348. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE""COL_RED"EROARE",""COL_RED"Parola incorecta.\n"COL_WHITE"Te rog introdu-ti parola in casuta de mai jos.","LOGHEAZA","IESI");
  349. }
  350. return 1;
  351. }
  352. }
  353. }
  354. return 1;
  355. }
  356.  
  357. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  358. {
  359. return 1;
  360. }
  361.  
  362. stock UserPath(playerid)
  363. {
  364. new string[128],playername[MAX_PLAYER_NAME];
  365. GetPlayerName(playerid,playername,sizeof(playername));
  366. format(string,sizeof(string),PATH,playername);
  367. return string;
  368. }
  369.  
  370. /*Credits to Dracoblue*/
  371. stock udb_hash(buf[]) {
  372. new length=strlen(buf);
  373. new s1 = 1;
  374. new s2 = 0;
  375. new n;
  376. for (n=0; n<length; n++)
  377. {
  378. s1 = (s1 + buf[n]) % 65521;
  379. s2 = (s2 + s1) % 65521;
  380. }
  381. return (s2 << 16) + s1;
  382. }
  383.  
  384. forward LoadUser_data(playerid,name[],value[]);
  385. public LoadUser_data(playerid,name[],value[])
  386. {
  387. INI_Int("Password",PlayerInfo[playerid][pPass]);
  388. INI_Int("Cash",PlayerInfo[playerid][pCash]);
  389. INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  390. INI_Int("Kills",PlayerInfo[playerid][pKills]);
  391. INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
  392. return 1;
  393. }
  394.  
  395. public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  396. {
  397. if(IsPlayerConnected(playerid))
  398. {
  399. new Float:posx, Float:posy, Float:posz;
  400. new Float:oldposx, Float:oldposy, Float:oldposz;
  401. new Float:tempposx, Float:tempposy, Float:tempposz;
  402. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  403. for(new i = 0; i < MAX_PLAYERS; i++)
  404. {
  405. if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
  406. {
  407. GetPlayerPos(i, posx, posy, posz);
  408. tempposx = (oldposx -posx);
  409. tempposy = (oldposy -posy);
  410. tempposz = (oldposz -posz);
  411. if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  412. {
  413. SendClientMessage(i, col1, string);
  414. }
  415. else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  416. {
  417. SendClientMessage(i, col2, string);
  418. }
  419. else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  420. {
  421. SendClientMessage(i, col3, string);
  422. }
  423. else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  424. {
  425. SendClientMessage(i, col4, string);
  426. }
  427. else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  428. {
  429. SendClientMessage(i, col5, string);
  430. }
  431. }
  432. else
  433. {
  434. SendClientMessage(i, col1, string);
  435. }
  436. }
  437. }
  438. return 1;
  439. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement