Advertisement
Guest User

rRPG v0.0.1

a guest
Jan 25th, 2014
972
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.14 KB | None | 0 0
  1. /*
  2.  
  3.         rRPG by Renas, RenaldasJ.
  4.  
  5.  
  6. */
  7.  
  8.  
  9. /* Includes */
  10. #include <a_samp>
  11. #include <dini>
  12. #include <dudb>
  13. #include <zcmd>
  14. #include <sscanf>
  15. /* Pragmos */
  16. #pragma tabsize 0 // dėl lygiavimo warningų
  17.  
  18. /* Defines*/
  19. #define set.%0[%1]              zInfo [ %1 ] [ %0 ]
  20. #define get.%0[%1]              zInfo [ %1 ] [ %0 ]
  21. #define MODO_PAV                "rRPG 0.0.1"// Modifikacijos pavadinimas
  22. #define MAP_NAME                "mapname SanFierro" //Mappo vardas,vietoje sanFierro pasikeisk į kokį nori.
  23. #define PLAYERS_DIREKTORIJA     "users/%s.ini"
  24. #define NEWBIE_POS              -1981.6033,137.5583,27.6875,264.1191
  25. #define SHOW_REGISTER               1
  26. #define SHOW_LOGIN                  2
  27.  
  28. /* Forwards */
  29.  
  30. /* Enumai*/
  31. enum _playerData // žaidėjo kintamasis.
  32. {
  33.         pPinigai,
  34.         pPatirtis,
  35.         pSkin
  36. };
  37.  
  38. /* Globaliniai kintamieji ir playeriniai */
  39. new
  40.     playersOnline,
  41.     bool: from_login [ MAX_PLAYERS ] ,
  42.     bool: from_reg  [ MAX_PLAYERS ] ,
  43.     bool: online [ MAX_PLAYERS ] ,
  44.     zInfo [ MAX_PLAYERS ] [ _playerData ]
  45. ;
  46. main()
  47. {
  48.     print("\n----------------------------------");
  49.     print(" rRPG sėkmingai užkrautas.");
  50.     print("----------------------------------\n");
  51. }
  52.  
  53.  
  54. public OnGameModeInit()
  55. {
  56.     // Don't use these lines if it's a filterscript
  57.     SetGameModeText(MODO_PAV);
  58.     /* Kad nesibugintu modas su Stay with world boundries, jeigu buginasi // ištrink. */
  59.     AddPlayerClass(random(2), 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  60.     return 1;
  61. }
  62.  
  63. public OnGameModeExit()
  64. {
  65.     return 1;
  66. }
  67.  
  68. public OnPlayerRequestClass(playerid, classid)
  69. {
  70.     InterpolateCameraPos(playerid, 1189.598022, -2074.284179, 217.528732, 558.943786, -2603.005371, 105.060241, 15000);
  71.     InterpolateCameraLookAt(playerid, 1185.244995, -2071.832519, 217.325668, 557.516479, -2607.788818, 104.775238, 15000);
  72.    
  73.     new file [ 128 ] ;
  74.     format( file, sizeof( file ) ,PLAYERS_DIREKTORIJA,pName ( playerid ) ) ;
  75.     if( !fexist ( file )  )
  76.     {
  77.         ShowRegister ( playerid ) ;
  78.     }
  79.     else
  80.     {
  81.         ShowLogin ( playerid ) ;
  82.     }
  83.  
  84.     return 1;
  85. }
  86.  
  87. public OnPlayerConnect(playerid)
  88. {
  89.     playersOnline ++;
  90.     /* Nulinam žaidėjo informacija */
  91.     ClearPlayerInfo ( playerid ) ;
  92.  
  93.     return 1;
  94. }
  95.  
  96. public OnPlayerDisconnect(playerid, reason)
  97. {
  98.     playersOnline--;
  99.     Saugojimas ( playerid ) ;
  100.     return 1;
  101. }
  102.  
  103. public OnPlayerSpawn(playerid)
  104. {
  105.     /* Kodas dedamas čia, jeigu žaidėjas mirė ir atsispawnino */
  106.     // Kodas.
  107.  
  108.     if( from_reg [ playerid ] ) // Jeigu žaidėjas ką tik prisiregistravo t.y po registracijos
  109.     {
  110.         SendClientMessage ( playerid, -1,"Jūs esate po registracijos.");
  111.         SetPlayerPos( playerid, NEWBIE_POS ) ;
  112.         Saugojimas ( playerid ) ; // pakraunam žaidėjo informacija
  113.     }
  114.     if( from_login [ playerid ] ) // Jeigu žaidėjas ką tik prisijungė t.y po prisijungimo
  115.     {
  116.         SendClientMessage ( playerid , -1,"Jūs esate po prisijungimo.");
  117.         Krovimas ( playerid ) ; // Išsaugome žaidėjo informacija.
  118.     }
  119.     return 1;
  120. }
  121.  
  122. public OnPlayerDeath(playerid, killerid, reason)
  123. {
  124.     return 1;
  125. }
  126.  
  127. public OnVehicleSpawn(vehicleid)
  128. {
  129.     return 1;
  130. }
  131.  
  132. public OnVehicleDeath(vehicleid, killerid)
  133. {
  134.     return 1;
  135. }
  136.  
  137. public OnPlayerText(playerid, text[])
  138. {
  139.     return 1;
  140. }
  141.  
  142. public OnPlayerCommandText(playerid, cmdtext[])
  143. {
  144.    
  145.     return 0;
  146. }
  147.  
  148. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  149. {
  150.     return 1;
  151. }
  152.  
  153. public OnPlayerExitVehicle(playerid, vehicleid)
  154. {
  155.     return 1;
  156. }
  157.  
  158. public OnPlayerStateChange(playerid, newstate, oldstate)
  159. {
  160.     return 1;
  161. }
  162.  
  163. public OnPlayerEnterCheckpoint(playerid)
  164. {
  165.     return 1;
  166. }
  167.  
  168. public OnPlayerLeaveCheckpoint(playerid)
  169. {
  170.     return 1;
  171. }
  172.  
  173. public OnPlayerEnterRaceCheckpoint(playerid)
  174. {
  175.     return 1;
  176. }
  177.  
  178. public OnPlayerLeaveRaceCheckpoint(playerid)
  179. {
  180.     return 1;
  181. }
  182.  
  183. public OnRconCommand(cmd[])
  184. {
  185.     return 1;
  186. }
  187.  
  188. public OnPlayerRequestSpawn(playerid)
  189. {
  190.     if( !online [ playerid ] )
  191.     {
  192.         SendClientMessage ( playerid, -1,"{FF0000}Pirmiau prisijunkit/prisiregistruokit!!");
  193.         return 0;
  194.     }
  195.     return 1;
  196. }
  197.  
  198. public OnObjectMoved(objectid)
  199. {
  200.     return 1;
  201. }
  202.  
  203. public OnPlayerObjectMoved(playerid, objectid)
  204. {
  205.     return 1;
  206. }
  207.  
  208. public OnPlayerPickUpPickup(playerid, pickupid)
  209. {
  210.     return 1;
  211. }
  212.  
  213. public OnVehicleMod(playerid, vehicleid, componentid)
  214. {
  215.     return 1;
  216. }
  217.  
  218. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  219. {
  220.     return 1;
  221. }
  222.  
  223. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  224. {
  225.     return 1;
  226. }
  227.  
  228. public OnPlayerSelectedMenuRow(playerid, row)
  229. {
  230.     return 1;
  231. }
  232.  
  233. public OnPlayerExitedMenu(playerid)
  234. {
  235.     return 1;
  236. }
  237.  
  238. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  239. {
  240.     return 1;
  241. }
  242.  
  243. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  244. {
  245.     return 1;
  246. }
  247.  
  248. public OnRconLoginAttempt(ip[], password[], success)
  249. {
  250.     return 1;
  251. }
  252.  
  253. public OnPlayerUpdate(playerid)
  254. {
  255.     return 1;
  256. }
  257.  
  258. public OnPlayerStreamIn(playerid, forplayerid)
  259. {
  260.     return 1;
  261. }
  262.  
  263. public OnPlayerStreamOut(playerid, forplayerid)
  264. {
  265.     return 1;
  266. }
  267.  
  268. public OnVehicleStreamIn(vehicleid, forplayerid)
  269. {
  270.     return 1;
  271. }
  272.  
  273. public OnVehicleStreamOut(vehicleid, forplayerid)
  274. {
  275.     return 1;
  276. }
  277.  
  278. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  279. {
  280.     switch ( dialogid )
  281.     {
  282.         case SHOW_REGISTER: // Registracija
  283.         {
  284.             if(!response) Kick ( playerid ) ;
  285.             if( response )
  286.             {
  287.                 new
  288.                     file [ 128 ],
  289.                     msg [ 128 ]
  290.                 ;
  291.                 format( file, sizeof( file ) ,PLAYERS_DIREKTORIJA,pName ( playerid ));
  292.                
  293.                 /* Kuriam failus žaidėjui */
  294.                 dini_Create ( file ) ;
  295.                 dini_Set( file , "slaptazodis", inputtext );
  296.                 format( msg,sizeof(msg) , "{ffffff}Jūsų vartotojas {33cc33}UŽREGISTRUOTAS!{ffffff}Slaptažodis: %s",inputtext ) ;
  297.                 SendClientMessage( playerid, -1, msg );
  298.                
  299.                 from_reg [ playerid ] = true;
  300.                 online [ playerid ] = true;
  301.                
  302.  
  303.             }
  304.             return 1;
  305.         }
  306.         case SHOW_LOGIN: // Prisijungimas
  307.         {
  308.             if(!response) Kick ( playerid ) ;
  309.             if( response )
  310.             {
  311.                 new
  312.                     file [ 128 ]
  313.              ;
  314.              format( file, sizeof( file) , PLAYERS_DIREKTORIJA,pName ( playerid ) ) ;
  315.              if( TikrinamSlaptazodi ( file, inputtext ) ) // Jei žaidėjo įvestas slaptažodis yra teisingas
  316.              {
  317.                 SendClientMessage ( playerid , -1, "{33cc33}Sveikas sugrįžęs į mūsų serverį.");
  318.                 from_login [ playerid ] = true;
  319.                 online [ playerid ] = true;
  320.  
  321.              }
  322.              else // Jei slaptažodis nėra teisingas.
  323.              {
  324.                 SendClientMessage ( playerid , -1,"{FF0000}Slaptažodis neteisingas.");
  325.                 ShowLogin ( playerid ) ;
  326.              }
  327.             }
  328.         }
  329.     }
  330.     return 1;
  331. }
  332.  
  333. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  334. {
  335.     return 1;
  336. }
  337. stock pName ( playerid )
  338. {
  339.     new
  340.         n [ MAX_PLAYER_NAME ]
  341.     ;
  342.  GetPlayerName ( playerid, n , MAX_PLAYER_NAME ) ;
  343.  return n;
  344.  
  345. }
  346. stock GetPlayerIpEx ( playerid )
  347. {
  348.     new
  349.         ip [ 16 ]
  350.  ;
  351.  GetPlayerIp(playerid, ip,sizeof(ip));
  352.  return ip;
  353. }
  354. /* STOCK'ai */
  355. stock ShowRegister ( playerid )
  356. {
  357.     new
  358.         str [ 500 ]
  359.  ;
  360.      format( str,sizeof(str),"{ffffff}Sveikas atvykęs {9999ff}%s {ffffff}į {9999ff}LPM-LIFE.lt{ffffff}serverį!\n\nJūsų paskyra: {FF0000}NEREGISTRUOTA.\n{FFFFFF}Jūsų IP: {33cc33}%s\n{FFFFFF}Jūsų būsimas ID: {33cc33}%i\n{ffffff}Dabar žaidžia: {33cc33}%i žaidėjai(ų)\n{ffffff}Dabar yra: {33cc33}%s\n\n{ffffff}Sugalvokite slaptažodį ir jį čia įrašykite:",pName( playerid ) , GetPlayerIpEx ( playerid ) , playerid, playersOnline, GautiData ( ) ) ;
  361.      ShowPlayerDialog ( playerid , SHOW_REGISTER , DIALOG_STYLE_PASSWORD , "{9999ff}LPM-LIFE.lt {ffffff}registracija.",str,"Registruotis","Atšaukti");
  362.  
  363.  
  364.     return 1;
  365. }
  366.  
  367. stock ShowLogin ( playerid )
  368. {
  369.     new
  370.         str [ 500 ]
  371.  ;
  372.      format( str,sizeof(str),"{ffffff}Sveikas atvykęs {9999ff}%s {ffffff}į {9999ff}LPM-LIFE.lt{ffffff}serverį!\n\nJūsų paskyra: {33cc33}REGISTRUOTA.\n{FFFFFF}Jūsų IP: {33cc33}%s\n{FFFFFF}Jūsų būsimas ID: {33cc33}%i\n{ffffff}Dabar žaidžia: {33cc33}%i žaidėjai(ų)\n{ffffff}Dabar yra: {33cc33}%s\n\n{ffffff}Įveskite savo paskyros slaptažodį:",pName( playerid ) , GetPlayerIpEx ( playerid ) , playerid, playersOnline, GautiData ( ) ) ;
  373.      ShowPlayerDialog ( playerid , SHOW_LOGIN , DIALOG_STYLE_PASSWORD , "{9999ff}LPM-LIFE.lt {ffffff}prisijungimas.",str,"Prisijungti","Atšaukti");
  374.      
  375.      return 1;
  376. }
  377. stock GautiData()
  378. {
  379.     new
  380.         stringas[ 31 ],
  381.         data[ 6 ]
  382.     ;
  383.     getdate( data[ 0 ], data[ 1 ], data[ 2 ] );
  384.     gettime( data[ 3 ], data[ 4 ], data[ 5 ] );
  385.     format( stringas, 31, "%d.%02d.%02d %02d:%02d", data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ] );
  386.     return stringas;
  387. }
  388. stock TikrinamSlaptazodi ( file[], inputtext[] )
  389. {
  390.     if( !strcmp( dini_Get ( file , "slaptazodis"), inputtext , true ) ) return true;
  391.     return false;
  392. }
  393. stock ClearPlayerInfo ( playerid )
  394. {
  395.     set.pSkin       [ playerid ] = 0;
  396.     set.pPatirtis   [ playerid ] = 0;
  397.     set.pPinigai    [ playerid ] = 0;
  398.     online          [ playerid ] = false;
  399.     from_login      [ playerid ] = false;
  400.     from_reg        [ playerid ] = false;
  401. }
  402. stock  Saugojimas ( playerid )
  403. {
  404.     new file [ 128 ];
  405.     format(file, sizeof(file), PLAYERS_DIREKTORIJA , pName ( playerid ) );
  406.     new Float:pos[3], weps[2][12];
  407.     GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  408.     if(!fexist ( file ) ){ dini_Create( file ) ; }
  409.     dini_IntSet ( file , "pSkin",GetPlayerSkin ( playerid ) ) ;
  410.     dini_IntSet ( file , "pPatirtis",GetPlayerScore ( playerid ) ) ;
  411.     dini_IntSet ( file , "pPinigai", GetPlayerMoney ( playerid ) ) ;
  412.     for(new tmp=0; tmp<12; tmp++) GetPlayerWeaponData(playerid, tmp,weps[0] [tmp],weps[1][tmp]);
  413.     dini_IntSet(file,"Ginklas0",weps[0][0]); dini_IntSet(file,"Ammo0",weps[1][0]);
  414.     dini_IntSet(file,"Ginklas1",weps[0][1]); dini_IntSet(file,"Ammo1",weps[1][1]);
  415.     dini_IntSet(file,"Ginklas2",weps[0][2]); dini_IntSet(file,"Ammo2",weps[1][2]);
  416.     dini_IntSet(file,"Ginklas3",weps[0][3]); dini_IntSet(file,"Ammo3",weps[1][3]);
  417.     dini_IntSet(file,"Ginklas4",weps[0][4]); dini_IntSet(file,"Ammo4",weps[1][4]);
  418.     dini_IntSet(file,"Ginklas5",weps[0][5]); dini_IntSet(file,"Ammo5",weps[1][5]);
  419.     dini_IntSet(file,"Ginklas6",weps[0][6]); dini_IntSet(file,"Ammo6",weps[1][6]);
  420.     dini_IntSet(file,"Ginklas7",weps[0][7]); dini_IntSet(file,"Ammo7",weps[1][7]);
  421.     dini_IntSet(file,"Ginklas8",weps[0][8]); dini_IntSet(file,"Ammo8",weps[1][8]);
  422.     dini_IntSet(file,"Ginklas9",weps[0][9]); dini_IntSet(file,"Ammo9",weps[1][9]);
  423.     dini_IntSet(file,"Ginklas10",weps[0][10]); dini_IntSet(file,"Ammo10",weps[1][10]);
  424.     dini_IntSet(file,"Ginklas11",weps[0][11]); dini_IntSet(file,"Ammo11",weps[1][11]);
  425.     dini_FloatSet(file,"pos_X",pos[0]);
  426.     dini_FloatSet(file,"pos_Y",pos[1]);
  427.     dini_FloatSet(file,"pos_Z",pos[2]);
  428.     printf("Išsaugotas žaidėjas. [%s]",pName ( playerid ) ) ;
  429.     return 1;
  430. }
  431.  
  432. stock Krovimas ( playerid )
  433. {
  434.     new file [ 128 ] ;
  435.     format( file , sizeof( file ),PLAYERS_DIREKTORIJA,pName ( playerid ) );
  436.     if(!fexist(file)) return;
  437.     new tmpxp = dini_Int(file,"pPatirtis");
  438.     new pinigai = dini_Int(file,"pPinigai");
  439.     GivePlayerMoney(playerid, pinigai);
  440.     SetPlayerScore(playerid, tmpxp);
  441.     SetPlayerPos(playerid,dini_Float(file,"pos_X"),dini_Float(file,"pos_Y"),dini_Float(file,"pos_Z"));
  442.     /* Kraunama žaidėjo informacija iš failo į serverį */
  443.     SetPlayerSkin(playerid,dini_Int(file,"pSkin"));
  444.     GivePlayerWeapon(playerid,dini_Int(file,"Ginklas0"),dini_Int(file,"Ammo0"));
  445.     GivePlayerWeapon(playerid,dini_Int(file,"Ginklas1"),dini_Int(file,"Ammo1"));
  446.     GivePlayerWeapon(playerid,dini_Int(file,"Ginklas2"),dini_Int(file,"Ammo2"));
  447.     GivePlayerWeapon(playerid,dini_Int(file,"Ginklas3"),dini_Int(file,"Ammo3"));
  448.     GivePlayerWeapon(playerid,dini_Int(file,"Ginklas4"),dini_Int(file,"Ammo4"));
  449.     GivePlayerWeapon(playerid,dini_Int(file,"Ginklas5"),dini_Int(file,"Ammo5"));
  450.     GivePlayerWeapon(playerid,dini_Int(file,"Ginklas6"),dini_Int(file,"Ammo6"));
  451.     GivePlayerWeapon(playerid,dini_Int(file,"Ginklas7"),dini_Int(file,"Ammo7"));
  452.     GivePlayerWeapon(playerid,dini_Int(file,"Ginklas8"),dini_Int(file,"Ammo8"));
  453.     GivePlayerWeapon(playerid,dini_Int(file,"Ginklas9"),dini_Int(file,"Ammo9"));
  454.     GivePlayerWeapon(playerid,dini_Int(file,"Ginklas10"),dini_Int(file,"Ammo10"));
  455.     GivePlayerWeapon(playerid,dini_Int(file,"Ginklas11"),dini_Int(file,"Ammo11"));
  456.     printf("Pakrautas žaidėjas. [%s]",pName ( playerid ) ) ;
  457.     return;
  458. }
  459.  
  460.  
  461. /* Public'ai */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement