Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- rRPG by Renas, RenaldasJ.
- */
- /* Includes */
- #include <a_samp>
- #include <dini>
- #include <dudb>
- #include <zcmd>
- #include <sscanf>
- /* Pragmos */
- #pragma tabsize 0 // dėl lygiavimo warningų
- /* Defines*/
- #define set.%0[%1] zInfo [ %1 ] [ %0 ]
- #define get.%0[%1] zInfo [ %1 ] [ %0 ]
- #define MODO_PAV "rRPG 0.0.1"// Modifikacijos pavadinimas
- #define MAP_NAME "mapname SanFierro" //Mappo vardas,vietoje sanFierro pasikeisk į kokį nori.
- #define PLAYERS_DIREKTORIJA "users/%s.ini"
- #define NEWBIE_POS -1981.6033,137.5583,27.6875,264.1191
- #define SHOW_REGISTER 1
- #define SHOW_LOGIN 2
- /* Forwards */
- /* Enumai*/
- enum _playerData // žaidėjo kintamasis.
- {
- pPinigai,
- pPatirtis,
- pSkin
- };
- /* Globaliniai kintamieji ir playeriniai */
- new
- playersOnline,
- bool: from_login [ MAX_PLAYERS ] ,
- bool: from_reg [ MAX_PLAYERS ] ,
- bool: online [ MAX_PLAYERS ] ,
- zInfo [ MAX_PLAYERS ] [ _playerData ]
- ;
- main()
- {
- print("\n----------------------------------");
- print(" rRPG sėkmingai užkrautas.");
- print("----------------------------------\n");
- }
- public OnGameModeInit()
- {
- // Don't use these lines if it's a filterscript
- SetGameModeText(MODO_PAV);
- /* Kad nesibugintu modas su Stay with world boundries, jeigu buginasi // ištrink. */
- AddPlayerClass(random(2), 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- InterpolateCameraPos(playerid, 1189.598022, -2074.284179, 217.528732, 558.943786, -2603.005371, 105.060241, 15000);
- InterpolateCameraLookAt(playerid, 1185.244995, -2071.832519, 217.325668, 557.516479, -2607.788818, 104.775238, 15000);
- new file [ 128 ] ;
- format( file, sizeof( file ) ,PLAYERS_DIREKTORIJA,pName ( playerid ) ) ;
- if( !fexist ( file ) )
- {
- ShowRegister ( playerid ) ;
- }
- else
- {
- ShowLogin ( playerid ) ;
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- playersOnline ++;
- /* Nulinam žaidėjo informacija */
- ClearPlayerInfo ( playerid ) ;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- playersOnline--;
- Saugojimas ( playerid ) ;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- /* Kodas dedamas čia, jeigu žaidėjas mirė ir atsispawnino */
- // Kodas.
- if( from_reg [ playerid ] ) // Jeigu žaidėjas ką tik prisiregistravo t.y po registracijos
- {
- SendClientMessage ( playerid, -1,"Jūs esate po registracijos.");
- SetPlayerPos( playerid, NEWBIE_POS ) ;
- Saugojimas ( playerid ) ; // pakraunam žaidėjo informacija
- }
- if( from_login [ playerid ] ) // Jeigu žaidėjas ką tik prisijungė t.y po prisijungimo
- {
- SendClientMessage ( playerid , -1,"Jūs esate po prisijungimo.");
- Krovimas ( playerid ) ; // Išsaugome žaidėjo informacija.
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- if( !online [ playerid ] )
- {
- SendClientMessage ( playerid, -1,"{FF0000}Pirmiau prisijunkit/prisiregistruokit!!");
- return 0;
- }
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch ( dialogid )
- {
- case SHOW_REGISTER: // Registracija
- {
- if(!response) Kick ( playerid ) ;
- if( response )
- {
- new
- file [ 128 ],
- msg [ 128 ]
- ;
- format( file, sizeof( file ) ,PLAYERS_DIREKTORIJA,pName ( playerid ));
- /* Kuriam failus žaidėjui */
- dini_Create ( file ) ;
- dini_Set( file , "slaptazodis", inputtext );
- format( msg,sizeof(msg) , "{ffffff}Jūsų vartotojas {33cc33}UŽREGISTRUOTAS!{ffffff}Slaptažodis: %s",inputtext ) ;
- SendClientMessage( playerid, -1, msg );
- from_reg [ playerid ] = true;
- online [ playerid ] = true;
- }
- return 1;
- }
- case SHOW_LOGIN: // Prisijungimas
- {
- if(!response) Kick ( playerid ) ;
- if( response )
- {
- new
- file [ 128 ]
- ;
- format( file, sizeof( file) , PLAYERS_DIREKTORIJA,pName ( playerid ) ) ;
- if( TikrinamSlaptazodi ( file, inputtext ) ) // Jei žaidėjo įvestas slaptažodis yra teisingas
- {
- SendClientMessage ( playerid , -1, "{33cc33}Sveikas sugrįžęs į mūsų serverį.");
- from_login [ playerid ] = true;
- online [ playerid ] = true;
- }
- else // Jei slaptažodis nėra teisingas.
- {
- SendClientMessage ( playerid , -1,"{FF0000}Slaptažodis neteisingas.");
- ShowLogin ( playerid ) ;
- }
- }
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- stock pName ( playerid )
- {
- new
- n [ MAX_PLAYER_NAME ]
- ;
- GetPlayerName ( playerid, n , MAX_PLAYER_NAME ) ;
- return n;
- }
- stock GetPlayerIpEx ( playerid )
- {
- new
- ip [ 16 ]
- ;
- GetPlayerIp(playerid, ip,sizeof(ip));
- return ip;
- }
- /* STOCK'ai */
- stock ShowRegister ( playerid )
- {
- new
- str [ 500 ]
- ;
- 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 ( ) ) ;
- ShowPlayerDialog ( playerid , SHOW_REGISTER , DIALOG_STYLE_PASSWORD , "{9999ff}LPM-LIFE.lt {ffffff}registracija.",str,"Registruotis","Atšaukti");
- return 1;
- }
- stock ShowLogin ( playerid )
- {
- new
- str [ 500 ]
- ;
- 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 ( ) ) ;
- ShowPlayerDialog ( playerid , SHOW_LOGIN , DIALOG_STYLE_PASSWORD , "{9999ff}LPM-LIFE.lt {ffffff}prisijungimas.",str,"Prisijungti","Atšaukti");
- return 1;
- }
- stock GautiData()
- {
- new
- stringas[ 31 ],
- data[ 6 ]
- ;
- getdate( data[ 0 ], data[ 1 ], data[ 2 ] );
- gettime( data[ 3 ], data[ 4 ], data[ 5 ] );
- format( stringas, 31, "%d.%02d.%02d %02d:%02d", data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ] );
- return stringas;
- }
- stock TikrinamSlaptazodi ( file[], inputtext[] )
- {
- if( !strcmp( dini_Get ( file , "slaptazodis"), inputtext , true ) ) return true;
- return false;
- }
- stock ClearPlayerInfo ( playerid )
- {
- set.pSkin [ playerid ] = 0;
- set.pPatirtis [ playerid ] = 0;
- set.pPinigai [ playerid ] = 0;
- online [ playerid ] = false;
- from_login [ playerid ] = false;
- from_reg [ playerid ] = false;
- }
- stock Saugojimas ( playerid )
- {
- new file [ 128 ];
- format(file, sizeof(file), PLAYERS_DIREKTORIJA , pName ( playerid ) );
- new Float:pos[3], weps[2][12];
- GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
- if(!fexist ( file ) ){ dini_Create( file ) ; }
- dini_IntSet ( file , "pSkin",GetPlayerSkin ( playerid ) ) ;
- dini_IntSet ( file , "pPatirtis",GetPlayerScore ( playerid ) ) ;
- dini_IntSet ( file , "pPinigai", GetPlayerMoney ( playerid ) ) ;
- for(new tmp=0; tmp<12; tmp++) GetPlayerWeaponData(playerid, tmp,weps[0] [tmp],weps[1][tmp]);
- dini_IntSet(file,"Ginklas0",weps[0][0]); dini_IntSet(file,"Ammo0",weps[1][0]);
- dini_IntSet(file,"Ginklas1",weps[0][1]); dini_IntSet(file,"Ammo1",weps[1][1]);
- dini_IntSet(file,"Ginklas2",weps[0][2]); dini_IntSet(file,"Ammo2",weps[1][2]);
- dini_IntSet(file,"Ginklas3",weps[0][3]); dini_IntSet(file,"Ammo3",weps[1][3]);
- dini_IntSet(file,"Ginklas4",weps[0][4]); dini_IntSet(file,"Ammo4",weps[1][4]);
- dini_IntSet(file,"Ginklas5",weps[0][5]); dini_IntSet(file,"Ammo5",weps[1][5]);
- dini_IntSet(file,"Ginklas6",weps[0][6]); dini_IntSet(file,"Ammo6",weps[1][6]);
- dini_IntSet(file,"Ginklas7",weps[0][7]); dini_IntSet(file,"Ammo7",weps[1][7]);
- dini_IntSet(file,"Ginklas8",weps[0][8]); dini_IntSet(file,"Ammo8",weps[1][8]);
- dini_IntSet(file,"Ginklas9",weps[0][9]); dini_IntSet(file,"Ammo9",weps[1][9]);
- dini_IntSet(file,"Ginklas10",weps[0][10]); dini_IntSet(file,"Ammo10",weps[1][10]);
- dini_IntSet(file,"Ginklas11",weps[0][11]); dini_IntSet(file,"Ammo11",weps[1][11]);
- dini_FloatSet(file,"pos_X",pos[0]);
- dini_FloatSet(file,"pos_Y",pos[1]);
- dini_FloatSet(file,"pos_Z",pos[2]);
- printf("Išsaugotas žaidėjas. [%s]",pName ( playerid ) ) ;
- return 1;
- }
- stock Krovimas ( playerid )
- {
- new file [ 128 ] ;
- format( file , sizeof( file ),PLAYERS_DIREKTORIJA,pName ( playerid ) );
- if(!fexist(file)) return;
- new tmpxp = dini_Int(file,"pPatirtis");
- new pinigai = dini_Int(file,"pPinigai");
- GivePlayerMoney(playerid, pinigai);
- SetPlayerScore(playerid, tmpxp);
- SetPlayerPos(playerid,dini_Float(file,"pos_X"),dini_Float(file,"pos_Y"),dini_Float(file,"pos_Z"));
- /* Kraunama žaidėjo informacija iš failo į serverį */
- SetPlayerSkin(playerid,dini_Int(file,"pSkin"));
- GivePlayerWeapon(playerid,dini_Int(file,"Ginklas0"),dini_Int(file,"Ammo0"));
- GivePlayerWeapon(playerid,dini_Int(file,"Ginklas1"),dini_Int(file,"Ammo1"));
- GivePlayerWeapon(playerid,dini_Int(file,"Ginklas2"),dini_Int(file,"Ammo2"));
- GivePlayerWeapon(playerid,dini_Int(file,"Ginklas3"),dini_Int(file,"Ammo3"));
- GivePlayerWeapon(playerid,dini_Int(file,"Ginklas4"),dini_Int(file,"Ammo4"));
- GivePlayerWeapon(playerid,dini_Int(file,"Ginklas5"),dini_Int(file,"Ammo5"));
- GivePlayerWeapon(playerid,dini_Int(file,"Ginklas6"),dini_Int(file,"Ammo6"));
- GivePlayerWeapon(playerid,dini_Int(file,"Ginklas7"),dini_Int(file,"Ammo7"));
- GivePlayerWeapon(playerid,dini_Int(file,"Ginklas8"),dini_Int(file,"Ammo8"));
- GivePlayerWeapon(playerid,dini_Int(file,"Ginklas9"),dini_Int(file,"Ammo9"));
- GivePlayerWeapon(playerid,dini_Int(file,"Ginklas10"),dini_Int(file,"Ammo10"));
- GivePlayerWeapon(playerid,dini_Int(file,"Ginklas11"),dini_Int(file,"Ammo11"));
- printf("Pakrautas žaidėjas. [%s]",pName ( playerid ) ) ;
- return;
- }
- /* Public'ai */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement