Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////////////
- // //
- // San Fierro RPG by Jonas ( 2011 - 2012 ). // //
- // //
- ////////////////////////////////////////////////////////////////////////////////
- #include < a_samp >
- #include < a_mysql.inc >
- #include < streamer >
- #include < sscanf2 >
- #include < foreach >
- #include < zcmd >
- //-----------------------------------------------------------
- // Mysql prisijungimo duomenys
- //-----------------------------------------------------------
- #define MySQL_HOST "localhost"
- #define MySQL_USER "root"
- #define MySQL_DATA "sanfierrorpg"
- #define MySQL_PASS ""
- //-----------------------------------------------------------
- // Definai
- //-----------------------------------------------------------
- #define MAX_QUERY 4000
- //-----------------------------------------------------------
- // Forwardai
- //-----------------------------------------------------------
- //-----------------------------------------------------------
- // Enum'ai
- //-----------------------------------------------------------
- enum PlayerInfo
- {
- bool: atsispawnines ,
- bool: uzsiregistraves ,
- }
- new pInfo [ MAX_PLAYERS ][ PlayerInfo ];
- //-----------------------------------------------------------
- // Spalvos
- //-----------------------------------------------------------
- #define MELYNA 0x0080FFFF
- #define JUODA 0x000000FF
- #define BALTA 0xFFFFFFFF
- #define ZYDRA 0xFFFF00FF
- #define ZALIA 0x00EA00FF
- #define TZALIA 0x408080FF
- #define RAUDONA 0xF00000FF
- #define PURPLE 0xFF80C0FF
- #define PILKA 0xC0C0C0FF
- #define GELTONA 0xFFFF00FF
- #define ORANGE 0xFF8000FF
- #define TORANGE 0xFF5D00FF
- //-----------------------------------------------------------
- // Serverio paleidimo ( motd )
- //-----------------------------------------------------------
- main( )
- {
- print ( "\n---------------------------------------" ) ;
- print ( "Paleistas San Fierro RPG by Jonas\n 2011 - 2012" ) ;
- print ( "---------------------------------------\n" ) ;
- }
- //-----------------------------------------------------------
- // OnPlayerConnect callback'as
- //-----------------------------------------------------------
- public OnPlayerConnect ( playerid )
- {
- //-----------------------------------------------------------
- // Jei vartotojo vardas netaisyklingas ( Vardas_Pavarde )
- //-----------------------------------------------------------
- if ( InvalidNickKick( playerid ) ) return 0;
- //-----------------------------------------------------------
- // Jei vartotojo vardas taisyklingas ( Vardas_Pavarde )
- //-----------------------------------------------------------
- SendClientMessage ( playerid, BALTA, " ");
- SendClientMessage ( playerid, BALTA, " ");
- SendClientMessage ( playerid, BALTA, " ");
- SendClientMessage ( playerid, BALTA, " ");
- SendClientMessage ( playerid, BALTA, " ");
- SendClientMessage ( playerid, BALTA, " ");
- SendClientMessage ( playerid, ORANGE, " Sveiki atvykę į San Fierro RPG! ");
- SendClientMessage ( playerid, ORANGE, " Serverio komandos - /Komandos , /Komandos2 , /Komandos3 ");
- SendClientMessage ( playerid, ORANGE, " Serverio pagalba - /Pagalba ");
- SendClientMessage ( playerid, BALTA, " ");
- SendClientMessage ( playerid, RAUDONA," Naudoti 'cheatus' ir kitas pagalbines žaidimo priemones yra GRIEŽTAI DRAUDŽIAMA! ");
- //-----------------------------------------------------------
- // Registracija ( Dialog 0 ), Prisijungimas ( Dialog 1 )
- //-----------------------------------------------------------
- SendClientMessage ( playerid, BALTA, " " );
- new
- Query[ 200 ]
- ;
- format ( Query,sizeof( Query ), "SELECT * FROM `Vartotojai` WHERE `Vardas` = '%s'", GetPlayerNameEx ( playerid ) );
- mysql_query ( Query );
- mysql_store_result( );
- if( mysql_num_rows( ) )
- {
- ShowPlayerDialog( playerid,1,DIALOG_STYLE_PASSWORD,"Prisijungimas","Jūs jau esate užsiregistravęs, todėl jums reikia prisijungti:","Jungtis","Atšaukti" );
- }
- else
- {
- ShowPlayerDialog( playerid,0,DIALOG_STYLE_PASSWORD,"Registracija","Jūs neįrašytas mūsų duomenų bazėje todėl užsiregistruokite:","Registruotis","Atšaukti" );
- }
- mysql_free_result( );
- //-----------------------------------------------------------
- //
- //-----------------------------------------------------------
- return 1;
- }
- //-----------------------------------------------------------
- // OnPlayerSpawn callback'as
- //-----------------------------------------------------------
- public OnPlayerSpawn( playerid )
- {
- SetPlayerInterior( playerid, GetPVarInt( playerid, "interior" ) );
- /* print("Sekmingai atsispawnines");
- if(pInfo[playerid][atsispawnines] == false)
- {
- Krovimas( playerid );
- pInfo[playerid][atsispawnines] = true;
- }
- return 1;*/
- }
- //-----------------------------------------------------------
- // OnPlayerDeath callback'as
- //-----------------------------------------------------------
- public OnPlayerDeath( playerid, killerid, reason )
- {
- }
- //-----------------------------------------------------------
- // onPlayerRequestSpawn callback'as
- //-----------------------------------------------------------
- public OnPlayerRequestSpawn ( playerid )
- {
- if (pInfo[playerid][uzsiregistraves] == true)
- {
- SetPlayerSkin(playerid,98);
- SetPlayerPos(playerid,-1957.3085,137.5778,27.6940);
- pInfo[playerid][uzsiregistraves] = false;
- }
- return 1;
- }
- //-----------------------------------------------------------
- // OnPlayerRequestClass callback'as
- //-----------------------------------------------------------
- public OnPlayerRequestClass( playerid, classid )
- {
- if(IsPlayerNPC(playerid)) return 1;
- SetPlayerFacingAngle(playerid,250.7573);
- SetPlayerPos(playerid,-1980.2172,137.8874,30.4085);
- SetPlayerCameraPos(playerid,-1978.7152,138.0048,28.3085);
- SetPlayerCameraLookAt(playerid,-1980.2172,137.8874,30.4085);
- PlayerPlaySound(playerid, 1097, 0 , 0 , 0);// Garsas
- ApplyAnimation(playerid,"DANCING","DAN_Left_A",4.0,1,0,0,0,-1);// Sokis
- SetPlayerInterior(playerid,0);
- SetPlayerVirtualWorld(playerid, 1);
- GameTextForPlayer(playerid, "~w~Spauskite ~n~~g~SHIFT ~n~~w~arba~n~~g~'Spawn'", 1000, 3);
- return 1;
- }
- //-----------------------------------------------------------
- // OnGameModeInit callback'as
- //-----------------------------------------------------------
- public OnGameModeInit( )
- {
- //-----------------------------------------------------------
- // Gamemode ( Mode ), Serverio nustatymai
- //-----------------------------------------------------------
- SetGameModeText("San Fierro - RPG");
- EnableStuntBonusForAll(false);
- AllowInteriorWeapons(true);
- SetNameTagDrawDistance(25);
- LimitGlobalChatRadius(30);
- ShowPlayerMarkers(0);
- //-----------------------------------------------------------
- // Mysql pranešimas ( Prisijungta / Neprisijungta )
- //-----------------------------------------------------------
- mysql_debug( true );
- mysql_connect( MySQL_HOST,MySQL_USER,MySQL_DATA,MySQL_PASS );
- if( mysql_ping( ) >= 1 )
- {
- print( "San Fierro - RPG: Prisijungimas prie mysql sėkmingas!" );
- }
- else
- {
- SendRconCommand( "exit" );
- }
- return 1;
- }
- //-----------------------------------------------------------
- // OnGameModeExit callback'as
- //-----------------------------------------------------------
- public OnGameModeExit( )
- {
- SendClientMessageToAll( -1, "~ Serveris išjungiamas, prisijunkite vėliau.");
- mysql_close( );
- return 1;
- }
- //-----------------------------------------------------------
- // OnPlayerUpdate callback'as
- //-----------------------------------------------------------
- public OnPlayerUpdate( playerid )
- {
- }
- //-----------------------------------------------------------
- // OnPlayerCommandText callback;as
- //-----------------------------------------------------------
- public OnPlayerCommandText( playerid )
- {
- }
- //-----------------------------------------------------------
- // OnDialogResponse callback'as
- //-----------------------------------------------------------
- public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[] )
- {
- //-----------------------------------------------------------
- // Serverio mysql registracija
- //-----------------------------------------------------------
- if( dialogid == 0 )
- {
- if( response )
- {
- if( !strlen( inputtext ) )
- return SendClientMessage( playerid,-1,"Laukelis Negali būti tuščias." );
- if( strlen( inputtext ) > 40 )
- return SendClientMessage( playerid,-1,"Slaptažodis negali būti ilgesnis nei 40simboliū." );
- new
- Query[ 150 ],string [ 68 ]
- ;
- format( Query,sizeof( Query ),"INSERT INTO `Vartotojai` (Vardas,Slaptazodis) VALUES ('%s','%s')",GetPlayerNameEx( playerid ),inputtext );
- mysql_query( Query );
- mysql_free_result();
- format(string, 68, "Sveikiname! Užsiregistravote, jūsų slaptažodis - %s",inputtext);
- SendClientMessage(playerid,MELYNA,string);
- SendClientMessage(playerid,MELYNA,"Jūs prijungtas automatiškai, gero žaidimo!");
- pInfo[playerid][uzsiregistraves] = true;
- }
- else
- {
- Kick( playerid );
- }
- return true;
- }
- //-----------------------------------------------------------
- // Serverio mysql prisijungimas
- //-----------------------------------------------------------
- if( dialogid == 1 )
- {
- if( response )
- {
- if( !strlen( inputtext ) )
- return SendClientMessage( playerid,-1,"Laukelis Negali būti tuščias." );
- if( strlen( inputtext ) > 40 )
- return SendClientMessage( playerid,-1,"Slaptažodis negali būti ilgesnis nei 40simbolių." );
- new
- Query[ 150 ]
- ;
- format( Query,sizeof( Query ),"SELECT * FROM `Vartotojai` WHERE `Vardas` = '%s' AND `Slaptazodis` = '%s'",GetPlayerNameEx( playerid ),inputtext );
- mysql_query( Query );
- mysql_store_result( );
- if(! mysql_num_rows( ) )
- {
- Kick( playerid );
- }
- else
- {
- SendClientMessage( playerid,-1,"Prisijungėte sėkmingai!" );
- Krovimas( playerid );
- }
- if( !response )
- {
- Kick( playerid );
- }
- mysql_free_result( );
- return true;
- }
- return true;
- }
- return true;
- }
- //-----------------------------------------------------------
- // OnPlayerDisconnect callback'as
- //-----------------------------------------------------------
- public OnPlayerDisconnect ( playerid )
- {
- saugojimas( playerid );
- }
- //-----------------------------------------------------------
- // Vardo stock'as
- //-----------------------------------------------------------
- stock GetPlayerNameEx( playerid )
- {
- new
- Name[ MAX_PLAYER_NAME ]
- ;
- GetPlayerName( playerid,Name,MAX_PLAYER_NAME );
- return Name;
- }
- //-----------------------------------------------------------
- // Mysql saugojimo stock'as
- //-----------------------------------------------------------
- /*stock saugojimas( playerid )
- {
- new query[MAX_QUERY];
- new Float:x, Float:y, Float:z, Float:a;
- GetPlayerPos(playerid,x,y,z);
- GetPlayerFacingAngle(playerid,a);
- SQLUpdateAddInt(query,"Interjeras",GetPlayerInterior(playerid));
- SQLUpdateAddFloat(query,"x",x);
- SQLUpdateAddFloat(query,"y",y);
- SQLUpdateAddFloat(query,"z",z);
- SQLUpdateAddFloat(query,"a",a);
- SQLUpdateCompleteEx("Vartotojai",query,"sanfierrorpg");
- mysql_query(query);
- }*/
- stock saugojimas ( playerid )
- {
- new query [MAX_QUERY];
- new Float:x, Float:y, Float:z, Float:a;
- GetPlayerPos( playerid, x, y, z );
- GetPlayerFacingAngle( playerid, a);
- format ( query, sizeof ( query ), "UPDATE `Vartotojai` SET `Interjeras` = %d, `x` = %f, `y` = %f, `z` = %f, `a` = %f WHERE `id` = %i",GetPlayerInterior( playerid ), x, y, z, a,GetPVarInt(playerid,"id"));
- mysql_query( query );
- }
- //-----------------------------------------------------------
- // Mysql krovimo stock'as
- //-----------------------------------------------------------
- stock Krovimas ( playerid )
- {
- new resultline [ 1024 ] , fetch[258], Float:x,Float:y,Float:z, query [ MAX_QUERY ],tmpinterior, Float:a, tmpid;
- format(query,1042,"SELECT * FROM `Vartotojai` WHERE `Vardas` = '%s'",GetPlayerNameEx(playerid));
- mysql_query(query);
- mysql_store_result();
- mysql_fetch_row(resultline);
- mysql_fetch_field_row(fetch,"id");
- sscanf(fetch, "i", tmpid);
- SetPVarInt( playerid, "id", tmpid );
- mysql_fetch_field_row(fetch,"x");
- sscanf(fetch, "f", x);
- mysql_fetch_field_row(fetch,"y");
- sscanf(fetch, "f", y);
- mysql_fetch_field_row(fetch,"z");
- sscanf(fetch, "f", z);
- mysql_fetch_field_row(fetch,"a");
- sscanf(fetch, "f", a);
- mysql_fetch_field_row(fetch,"Interjeras");
- sscanf(fetch, "d", tmpinterior);
- SetPVarInt( playerid, "interior", tmpinterior );
- SetSpawnInfo( playerid, NO_TEAM, GetPlayerSkin( playerid ), x, y, z, a, 0, 0, 0, 0, 0, 0 );
- }
- //-----------------------------------------------------------
- // Neteisingo vardo stock'as
- //-----------------------------------------------------------
- stock InvalidNickKick(playerid)
- {
- if(IsPlayerNPC(playerid))return 1;
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,MAX_PLAYER_NAME);
- new where = strfind(name,"_",true);
- new lenght = strlen(name)-1;
- new invalid = strfind(name,"[",true);
- if(invalid == -1) invalid = strfind(name,"]",true);
- if(name[0] < 65 || name[0] > 90)
- {
- SendClientMessage(playerid,RAUDONA,"Jūsų slapyvardis netinkamas, vardas rašosi didžiają raide!");
- SendClientMessage(playerid,RAUDONA,"Teisinga slapyvardžio forma būtų:");
- SendClientMessage(playerid,RAUDONA,"Vardas_Pavardė.");
- Kick(playerid);
- return 1;
- }
- if(name[where+1] < 65 || name[where+1] > 90)
- {
- SendClientMessage(playerid,RAUDONA,"Jūsų slapyvardis netinkamas, pavardė rašosi didžiaja raide!");
- SendClientMessage(playerid,RAUDONA,"Teisinga slapyvardžio forma būtų:");
- SendClientMessage(playerid,RAUDONA,"Vardas_Pavardė.");
- Kick(playerid);
- return 1;
- }
- for(new i = 1; i < where-1; i++)
- {
- if(name[i] < 97 || name[i] > 122)
- {
- SendClientMessage(playerid,RAUDONA,"Jūsų slapyvardis netinkamas (didžiosios raidės arba skaičiai vardo viduryje).");
- SendClientMessage(playerid,RAUDONA,"Teisinga slapyvardžio forma būtų:");
- SendClientMessage(playerid,RAUDONA,"Vardas_Pavardė.");
- Kick(playerid);
- return 1;
- }
- }
- if(where == 0 || where == lenght || where==-1)
- {
- SendClientMessage(playerid,RAUDONA,"Jūsų slapyvardis netinkamas.");
- SendClientMessage(playerid,RAUDONA,"Teisinga slapyvardžio forma būtų:");
- SendClientMessage(playerid,RAUDONA,"Vardas_Pavardė.");
- Kick(playerid);
- return 1;
- }
- if(strlen(name[where])<4)
- {
- SendClientMessage(playerid,RAUDONA,"Jūsų pavardė per trumpa.");
- SendClientMessage(playerid,RAUDONA,"Teisinga slapyvardžio forma būtų:");
- SendClientMessage(playerid,RAUDONA,"Vardas_Pavardė.");
- Kick(playerid);
- return 1;
- }
- if(where<3)
- {
- SendClientMessage(playerid,RAUDONA,"Jūsų vardas per trumpas.");
- SendClientMessage(playerid,RAUDONA,"Teisinga slapyvardžio forma būtų:");
- SendClientMessage(playerid,RAUDONA,"Vardas_Pavardė.");
- Kick(playerid);
- return 1;
- }
- if(invalid != -1)
- {
- SendClientMessage(playerid,RAUDONA,"Varde rasta netinkamų raidzių.");
- SendClientMessage(playerid,RAUDONA,"Teisinga slapyvardžio forma būtų:");
- SendClientMessage(playerid,RAUDONA,"Vardas_Pavardė.");
- Kick(playerid);
- return 1;
- }
- for(new i = where+2; i < MAX_PLAYER_NAME; i++)
- {
- if(name[i] < 97 || name[i] > 122)
- {
- if(name[i] == 0){i = MAX_PLAYER_NAME; return 0;}
- SendClientMessage(playerid,RAUDONA,"Jūsų slapyvardis netinkamas (didžiosios raidės arba skaičiai pavardės viduryje).");
- SendClientMessage(playerid,RAUDONA,"Teisinga slapyvardžio forma būtų:");
- SendClientMessage(playerid,RAUDONA,"Vardas_Pavardė.");
- Kick(playerid);
- return 1;
- }
- }
- return 0;
- }
- //-----------------------------------------------------------
- // Mysql užklausų generavimas
- //-----------------------------------------------------------
- stock SQLUpdateAddInt(string[],varname,var,bool:last=false)
- {
- new epicstr[MAX_QUERY];
- format(epicstr,sizeof(epicstr),"%s %s=%d",string,varname,var);
- if(!last) strcat(epicstr,",");
- return epicstr;
- }
- stock SQLUpdateAddString(string[],varname,var[],bool:last=false)
- {
- new epicstr[MAX_QUERY];
- format(epicstr,sizeof(epicstr),"%s %s=\"%s\"",string,varname,var);
- if(!last) strcat(epicstr,",");
- return epicstr;
- }
- stock SQLUpdateAddFloat(string[],varname,Float:var,bool:last=false)
- {
- new epicstr[MAX_QUERY];
- format(epicstr,sizeof(epicstr),"%s %s=%f",string,varname,var);
- if(!last) strcat(epicstr,",");
- return epicstr;
- }
- stock SQLUpdateComplete(table[],data[],id)
- {
- new epicstr[MAX_QUERY];
- format(epicstr,sizeof(epicstr),"UPDATE %s SET %s WHERE id=%d",table,data,id);
- return epicstr;
- }
- stock SQLUpdateCompleteEx(table[],data[],where[])
- {
- new epicstr[MAX_QUERY];
- format(epicstr,sizeof(epicstr),"UPDATE %s SET %s WHERE %s",table,data,where);
- return epicstr;
- }
- //-----------------------------------------------------------
- // Skripto pabaiga
- //-----------------------------------------------------------
Add Comment
Please, Sign In to add comment