Guest User

Untitled

a guest
Jul 17th, 2018
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.04 KB | None | 0 0
  1. /**********************
  2. *************    Matrix Gaming
  3. ************
  4. ***********
  5. *********         Roleplay
  6. *******
  7. *****
  8. ***             By:Vectro64(Nick Makaveli)
  9. **
  10. *
  11. */
  12.  
  13.  
  14.  
  15. #include <a_samp>
  16. #include <YSI\y_ini>
  17.  
  18. //DEFINOVI
  19. // 1. Dialog Define
  20. #define DIALOG_REGISTER 1
  21. #define DIALOG_LOGIN 2
  22. #define DIALOG_SUCCESS_1 3
  23. #define DIALOG_SUCCESS_2 4
  24. #define DIALOG_SPAWN 5
  25. // 2. Osatli definovi
  26. #define PATH "/Users/%s.ini"
  27. // 3. Define boja
  28. #define COL_WHITE "{FFFFFF}"
  29. #define COL_BLUE "{039EFF}"
  30. #define COL_GREY "{ABAEB0}"
  31. #define COL_LIGHTBLUE "{00CED1}"
  32.  
  33. //VARIJABLE/Enumeratori
  34. enum pInfo
  35. {
  36.     pPass,
  37.     pCash,
  38.     pAdmin,
  39.     pKills,
  40.     pDeaths,
  41.     pMS,
  42.     pWanted,
  43.     pLeader,
  44.     pMember,
  45.     pDonator,
  46.     pSpawn,
  47.     pSkin,
  48.     pLevel
  49. }
  50. new PlayerInfo[MAX_PLAYERS][pInfo];
  51.  
  52.  
  53. #if defined FILTERSCRIPT
  54.  
  55. public OnFilterScriptInit()
  56. {
  57.     print("\n--------------------------------------");
  58.     print(" Blank Filterscript by your name here");
  59.     print("--------------------------------------\n");
  60.     return 1;
  61. }
  62.  
  63. public OnFilterScriptExit()
  64. {
  65.     return 1;
  66. }
  67.  
  68. #else
  69.  
  70. main()
  71. {
  72.     print("\n----------------------------------");
  73.     print("Matrix Gaming || Dobrodosli");
  74.     print("----------------------------------\n");
  75. }
  76.  
  77. #endif
  78.  
  79. public OnGameModeInit()
  80. {
  81.     // Don't use these lines if it's a filterscript
  82.     SetGameModeText("MG:RP v1.0.0");
  83.     return 1;
  84. }
  85.  
  86. public OnGameModeExit()
  87. {
  88.     return 1;
  89. }
  90.  
  91. public OnPlayerRequestClass(playerid, classid)
  92. {
  93.     return 1;
  94. }
  95.  
  96. public OnPlayerConnect(playerid)
  97. {
  98.     if(fexist(UserPath(playerid)))
  99.     {
  100.         INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  101.         SetPlayerCameraPos(playerid, 320.0, 50.0, 170.0);
  102.         SetPlayerCameraLookAt(playerid, 324.34, 54.122, 173.35);
  103.         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_BLUE"Login || Matrix Gaming",""COL_GREY"Dobrodosli nazad na Matrix Gaming Roleplay. Molimo, ulogirajte se","Login","Izlaz");
  104.         SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
  105.         SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
  106.        
  107.     }
  108.     else
  109.     {   SetPlayerCameraPos(playerid, 320.0, 50.0, 170.0);
  110.         SetPlayerCameraLookAt(playerid, 324.34, 54.122, 173.35);
  111.         ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,""COL_BLUE"Registracija || Matrix Gaming",""COL_WHITE"Dobrodosli na Matrix Gaming!\nUpisite password koji cete kasnije koristiti za login!!","Registracija","Izlaz");
  112.        
  113.     }
  114.     return 1;
  115. }
  116.  
  117. public OnPlayerDisconnect(playerid, reason)
  118. {
  119.     new INI:File = INI_Open(UserPath(playerid));
  120.     INI_SetTag(File,"data");
  121.     INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  122.     INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  123.     INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
  124.     INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
  125.     INI_WriteInt(File,"MS",PlayerInfo[playerid][pMS]);
  126.     INI_WriteInt(File,"Wanted",PlayerInfo[playerid][pWanted]);
  127.     INI_WriteInt(File,"Leader",PlayerInfo[playerid][pLeader]);
  128.     INI_WriteInt(File,"Members",PlayerInfo[playerid][pMember]);
  129.     INI_WriteInt(File,"Donator",PlayerInfo[playerid][pDonator]);
  130.     INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
  131.     INI_WriteInt(File,"Spawn",PlayerInfo[playerid][pSpawn]);
  132.     INI_Close(File);
  133.     return 1;
  134. }
  135.  
  136. public OnPlayerSpawn(playerid)
  137. {
  138.     return 1;
  139. }
  140.  
  141. public OnPlayerDeath(playerid, killerid, reason)
  142. {
  143.     return 1;
  144. }
  145.  
  146. public OnVehicleSpawn(vehicleid)
  147. {
  148.     return 1;
  149. }
  150.  
  151. public OnVehicleDeath(vehicleid, killerid)
  152. {
  153.     return 1;
  154. }
  155.  
  156. public OnPlayerText(playerid, text[])
  157. {
  158.     return 1;
  159. }
  160.  
  161. public OnPlayerCommandText(playerid, cmdtext[])
  162. {
  163.     if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  164.     {
  165.         // Do something here
  166.         return 1;
  167.     }
  168.     return 0;
  169. }
  170.  
  171. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  172. {
  173.     return 1;
  174. }
  175.  
  176. public OnPlayerExitVehicle(playerid, vehicleid)
  177. {
  178.     return 1;
  179. }
  180.  
  181. public OnPlayerStateChange(playerid, newstate, oldstate)
  182. {
  183.     return 1;
  184. }
  185.  
  186. public OnPlayerEnterCheckpoint(playerid)
  187. {
  188.     return 1;
  189. }
  190.  
  191. public OnPlayerLeaveCheckpoint(playerid)
  192. {
  193.     return 1;
  194. }
  195.  
  196. public OnPlayerEnterRaceCheckpoint(playerid)
  197. {
  198.     return 1;
  199. }
  200.  
  201. public OnPlayerLeaveRaceCheckpoint(playerid)
  202. {
  203.     return 1;
  204. }
  205.  
  206. public OnRconCommand(cmd[])
  207. {
  208.     return 1;
  209. }
  210.  
  211. public OnPlayerRequestSpawn(playerid)
  212. {
  213.     return 1;
  214. }
  215.  
  216. public OnObjectMoved(objectid)
  217. {
  218.     return 1;
  219. }
  220.  
  221. public OnPlayerObjectMoved(playerid, objectid)
  222. {
  223.     return 1;
  224. }
  225.  
  226. public OnPlayerPickUpPickup(playerid, pickupid)
  227. {
  228.     return 1;
  229. }
  230.  
  231. public OnVehicleMod(playerid, vehicleid, componentid)
  232. {
  233.     return 1;
  234. }
  235.  
  236. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  237. {
  238.     return 1;
  239. }
  240.  
  241. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  242. {
  243.     return 1;
  244. }
  245.  
  246. public OnPlayerSelectedMenuRow(playerid, row)
  247. {
  248.     return 1;
  249. }
  250.  
  251. public OnPlayerExitedMenu(playerid)
  252. {
  253.     return 1;
  254. }
  255.  
  256. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  257. {
  258.     return 1;
  259. }
  260.  
  261. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  262. {
  263.     return 1;
  264. }
  265.  
  266. public OnRconLoginAttempt(ip[], password[], success)
  267. {
  268.     return 1;
  269. }
  270.  
  271. public OnPlayerUpdate(playerid)
  272. {
  273.     return 1;
  274. }
  275.  
  276. public OnPlayerStreamIn(playerid, forplayerid)
  277. {
  278.     return 1;
  279. }
  280.  
  281. public OnPlayerStreamOut(playerid, forplayerid)
  282. {
  283.     return 1;
  284. }
  285.  
  286. public OnVehicleStreamIn(vehicleid, forplayerid)
  287. {
  288.     return 1;
  289. }
  290.  
  291. public OnVehicleStreamOut(vehicleid, forplayerid)
  292. {
  293.     return 1;
  294. }
  295.  
  296. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  297. {
  298.     switch( dialogid )
  299.     {
  300.         case DIALOG_REGISTER:
  301.         {
  302.             if (!response) return Kick(playerid);
  303.             if(response)
  304.             {
  305.                 if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_BLUE"Registracija || Matrix Gaming",""COL_GREY"Niste upisali tacan password.\n"COL_BLUE"Upisite password da se registrirate.","Registracija","Izlaz");
  306.                 new INI:File = INI_Open(UserPath(playerid));
  307.                 INI_SetTag(File,"data");
  308.                 INI_WriteInt(File,"Password",udb_hash(inputtext));
  309.                 INI_WriteInt(File,"Cash",0);
  310.                 INI_WriteInt(File,"Admin",0);
  311.                 INI_WriteInt(File,"MS",0);
  312.                 INI_WriteInt(File,"Wanted",0);
  313.                 INI_WriteInt(File,"Leader",0);
  314.                 INI_WriteInt(File,"Member",0);
  315.                 INI_WriteInt(File,"Donator",0);
  316.                 INI_Close(File);
  317.  
  318.                 ShowPlayerDialog(playerid, DIALOG_SPAWN, DIALOG_STYLE_LIST,""COL_BLUE"Izaberite na koju stanicu zelite da pristanete", "Autobuska\r\nZeljeznicka\r\nAerodrom\r\nLuka", "U redu", "");\
  319.                 PlayerInfo[playerid][pLevel] = 1;
  320.                 SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
  321.                 GivePlayerMoney(playerid, 1000);
  322.             }
  323.  
  324.  
  325.         case DIALOG_LOGIN:
  326.         {
  327.             if ( !response ) return Kick ( playerid );
  328.             if( response )
  329.             {
  330.                 if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
  331.                 {
  332.                     INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  333.                     GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
  334.                     SendClientMessage(playerid, -1, COL_BLUE, "MG:RP || Dobrodosli!");
  335.                 }
  336.                 else
  337.                 {
  338.                     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_BLUE"Login || Matrix Gaming",""COL_GREY"Niste upisali tacan password.\n"COL_BLUE"Molimo da upisete tacan password.","Login","Izlaz");
  339.                 }
  340.                 return 1;
  341.             }
  342.         }
  343.     }
  344.     return 1;
  345. }
  346. {switch(dialogid)
  347.     {
  348.         case DIALOG_SPAWN:
  349.         {
  350.         if(!response) return
  351.         if(response)
  352.         {
  353.         switch(listitem)
  354.         {
  355.         case 0:
  356.         {
  357.         SetPlayerPos(playerid, 0.0, 0.0, 0.0);
  358.         SpawnPlayer(playerid);
  359.         PlayerInfo[playerid][pSpawn] = 1;
  360.         PlayerInfo[playerid][pSkin] = 299;
  361.         SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
  362.         }
  363.         case 1:
  364.         {
  365.         SetPlayerPos(playerid, 0.0, 0.0, 0.0);
  366.         SpawnPlayer(playerid);
  367.         PlayerInfo[playerid][pSpawn] = 2;
  368.         PlayerInfo[playerid][pSkin] = 1;
  369.         SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
  370.         }
  371.         case 2:
  372.         {
  373.         SetPlayerPos(playerid, 0.0, 0.0, 0.0);
  374.         SpawnPlayer(playerid);
  375.         PlayerInfo[playerid][pSpawn] = 3;
  376.         PlayerInfo[playerid][pSkin] = 7;
  377.         SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
  378.         }
  379.         case 3:
  380.         {
  381.         SetPlayerPos(playerid, 0.0, 0.0, 0.0);
  382.         SpawnPlayer(playerid);
  383.         PlayerInfo[playerid][pSpawn] = 4;
  384.         PlayerInfo[playerid][pSkin] = 101;
  385.         SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
  386.         }
  387.         }
  388.     }
  389.     }
  390.     return 1;
  391. }
  392.  
  393. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  394. {
  395.     return 1;
  396. }
  397. //INI
  398. forward LoadUser_data(playerid,name[],value[]);
  399. public LoadUser_data(playerid,name[],value[])
  400. {
  401.     INI_Int("Password",PlayerInfo[playerid][pPass]);
  402.     INI_Int("Cash",PlayerInfo[playerid][pCash]);
  403.     INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  404.     INI_Int("Level",PlayerInfo[playerid][pLevel]);
  405.     INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
  406.     INI_Int("MS",PlayerInfo[playerid][pMS]);
  407.     INI_Int("Wanted",PlayerInfo[playerid][pWanted]);
  408.     INI_Int("Leader",PlayerInfo[playerid][pLeader]);
  409.     INI_Int("Members",PlayerInfo[playerid][pMember]);
  410.     INI_Int("Donator",PlayerInfo[playerid][pDonator]);
  411.     INI_Int("Skin",PlayerInfo[playerid][pSkin]);
  412.     INI_Int("Spawn",PlayerInfo[playerid][pSpawn]);
  413.     return 1;
  414. }
  415. //Stockovi
  416. stock UserPath(playerid)
  417. {
  418.     new string[128],playername[MAX_PLAYER_NAME];
  419.     GetPlayerName(playerid,playername,sizeof(playername));
  420.     format(string,sizeof(string),PATH,playername);
  421.     return string;
  422. }
  423. stock udb_hash(buf[]) {
  424.     new length=strlen(buf);
  425.     new s1 = 1;
  426.     new s2 = 0;
  427.     new n;
  428.     for (n=0; n<length; n++)
  429.     {
  430.        s1 = (s1 + buf[n]) % 65521;
  431.        s2 = (s2 + s1)     % 65521;
  432.     }
  433.     return (s2 << 16) + s1;
  434. }
Add Comment
Please, Sign In to add comment