Advertisement
Guest User

Main-RP

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