Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- main( ) { }
- #include <a_samp>
- #include <streamer>
- #include <YSI\y_ini>
- #include <mysql>
- //******************************************************************************
- // Define-uri
- //******************************************************************************
- //Colors
- #define COLOR_WHITE 0xFFFFFFFF
- //
- #define SPD ShowPlayerDialog
- #define SCM SendClientMessage
- #define DIALOG_REGISTER ( 1 )
- #define DIALOG_LOGIN ( 2 )
- #define DIALOG_SEX ( 3 )
- #define DIALOG_VARSTA ( 4 )
- #define DIALOG_EMAIL ( 5 )
- #define DIALOG_SPAWN ( 6 )
- //******************************************************************************
- #define mysql_host "localhost"
- #define mysql_user "trinity"
- #define mysql_db "Accounts"
- #define mysql_pass "calculator"
- //******************************************************************************
- // Forwards
- //******************************************************************************
- forward RefreshMenuHeader(playerid,Menu:menu,text[]);
- //******************************************************************************
- // Enums
- //******************************************************************************
- enum PlayerData
- {
- Nume [ MAX_PLAYER_NAME ] ,
- Bani ,
- Scor ,
- Ucideri ,
- Email ,
- Sex ,
- Varsta ,
- Interior ,
- Spawn ,
- Decese
- } ;
- new PlayerInfo[MAX_PLAYERS][PlayerData];
- new
- P_DATA [ MAX_PLAYERS ] [ PlayerData ] ,
- bool: Logat [ MAX_PLAYERS ] ,
- DB:Accounts
- ;
- //******************************************************************************
- // Functii Public
- //******************************************************************************
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- return 0;
- }
- public OnGameModeInit()
- {
- print(" ");
- print("------[HardCore-Gaming RPG]-------------");
- print("________________________________________");
- print("---(GameMode creeat de: Trinity)----------");
- print(" ");
- mysql_connect ( "localhost", "trinity", "Accounts", "calculator" );
- SetGameModeText("HC:RP v0.0.1");
- AddPlayerClass(60,1743.0549,-1861.2273,13.5778,46.8583,0,0,0,0,0,0);
- new
- string [ 756 ]
- ;
- Accounts = db_open ( "Accounts.db" ) ;
- strcat ( string , "CREATE TABLE IF NOT EXISTS `Jucatori`" , 756 ) ;
- strcat ( string , "(`ID` INTEGER PRIMARY KEY AUTOINCREMENT ,\
- `Nume` TEXT ,\
- `Parola` TEXT ,\
- `Bani` NUMERIC ,\
- `Scor` NUMERIC , " , 756 ) ;
- strcat ( string , "`Ucideri` NUMERIC ,\
- `Decese` NUMERIC ,\
- `Email` TEXT ,\
- `Sex` NUMERIC ,\
- `Varsta` NUMERIC ,\
- `Interior` NUMERIC ,\
- `Spawn` NUMERIC ) " , 756 ) ;
- db_free_result ( db_query ( Accounts , string ) ) ;
- return ( 1 ) ;
- }
- public OnPlayerSpawn(playerid)
- {
- if(PlayerInfo[playerid][Spawn] == 1)//LS
- {
- SetPlayerPos(playerid,1743.054931,-1861.227294,13.577773);
- SetPlayerFacingAngle(playerid, 0);
- SetPlayerInterior(playerid,0);
- PlayerInfo[playerid][Interior] = 0;
- }
- else if(PlayerInfo[playerid][Spawn] == 2)//SF
- {
- SetPlayerPos(playerid,-1983.503540,137.988937,27.687500);
- SetPlayerFacingAngle(playerid, 90);
- SetPlayerInterior(playerid,0);
- PlayerInfo[playerid][Interior] = 0;
- }
- else if(PlayerInfo[playerid][Spawn] == 3)//LV
- {
- SetPlayerPos(playerid,1932.8171,1345.1152,9.9688);
- SetPlayerFacingAngle(playerid, -90);
- SetPlayerInterior(playerid,0);
- PlayerInfo[playerid][Interior] = 0;
- }
- }
- public OnGameModeExit()
- {
- db_close ( Accounts ) ;
- return ( 1 ) ;
- }
- public OnPlayerConnect ( playerid )
- {
- new
- Query [ 256 ] ,
- pNume [ MAX_PLAYER_NAME ] ,
- DBResult:Result
- ;
- Logat [ playerid ] = false ;
- GetPlayerName ( playerid , pNume , MAX_PLAYER_NAME ) ;
- strcpy ( P_DATA [ playerid ] [ Nume ] , DB_Escape ( pNume ) , MAX_PLAYER_NAME ) ;
- format ( Query , 256 , "SELECT * FROM `Jucatori` WHERE `Nume` = '%s'" , P_DATA [ playerid ] [ Nume ] ) ;
- Result = db_query ( Accounts , Query ) ;
- if ( db_num_rows ( Result ) > 0 )
- SPD ( playerid , DIALOG_LOGIN , DIALOG_STYLE_PASSWORD , "Logheaza-te" , "Introdu parola in casuta de mai jos:" , "Login" , "" ) ;
- else
- ShowPlayerDialog(playerid,DIALOG_EMAIL,DIALOG_STYLE_INPUT,"Email","Scrie aici email-ul tau","O.K.","");
- db_free_result ( Result ) ;
- return ( 1 ) ;
- }
- public OnPlayerDisconnect ( playerid , reason )
- {
- if ( Logat [ playerid ] )
- {
- new
- Query [ 256 ]
- ;
- format ( Query , sizeof ( Query ) , "UPDATE `Jucatori` SET `Bani` = '%d' ,`Scor` = '%d' , `Ucideri` = '%d' , `Decese` = '%d' , `Sex` = '%d' , `Interior` = '%d' , `Varsta` = '%d' , 'Spawn' ='%d' WHERE `Nume` = '%s'"
- , GetPlayerMoney ( playerid ) , GetPlayerScore ( playerid ) , P_DATA [ playerid ] [ Ucideri ] , P_DATA [ playerid ] [ Decese ] , P_DATA [ playerid ] [ Nume ] ) ;
- db_free_result ( db_query ( Accounts , Query ) ) ;
- }
- return ( 1 ) ;
- }
- public OnPlayerDeath ( playerid , killerid , reason )
- {
- P_DATA [ playerid ] [ Decese ] ++ ;
- if ( killerid != INVALID_PLAYER_ID )
- {
- P_DATA [ killerid ] [ Ucideri ] ++ ;
- }
- return ( 1 ) ;
- }
- public OnDialogResponse ( playerid , dialogid , response , listitem , inputtext [ ] )
- {
- if ( dialogid == DIALOG_EMAIL )
- {
- if ( !response || isnull(inputtext ) ) return ShowPlayerDialog(playerid,DIALOG_EMAIL,DIALOG_STYLE_INPUT,"Email","Scrie aici email-ul tau","O.K.","");
- new email = strval(inputtext);
- new
- Query [ 256 ]
- ;
- format ( Query , sizeof ( Query ) , "INSERT INTO `Jucatori` ( `Email` ) VALUE ( '%s' )"
- , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) , email ) ;
- db_free_result ( db_query ( Accounts , Query ) ) ;
- SPD ( playerid , DIALOG_REGISTER , DIALOG_STYLE_PASSWORD , "Inregistreaza-te" , "Introduceti o parola pentru a va inregistra:" , "Register" , "" );
- return ( 1 ) ;
- }
- if ( dialogid == DIALOG_REGISTER )
- {
- if ( !response || isnull(inputtext ) ) return SPD ( playerid , DIALOG_REGISTER , DIALOG_STYLE_PASSWORD , "Inregistreaza-te" , "Introduceti o parola pentru a va inregistra:" , "Register" , "" ) ;
- new
- Query [ 256 ]
- ;
- format ( Query , sizeof ( Query ) , "INSERT INTO `Jucatori` ( `Nume` , `Parola` , `Bani` , `Scor` , `Ucideri` , `Decese` ) VALUES ( '%s' , '%s', '%d' , '%d' , '%d' , '%d' )"
- , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) , 500 , 0 , 0 , 0 ) ;
- db_free_result ( db_query ( Accounts , Query ) ) ;
- ShowPlayerDialog(playerid,DIALOG_SEX,DIALOG_STYLE_LIST,"Care este sexul tau?","Masculin \nFeminin","Select","");
- return ( 1 ) ;
- }
- if(dialogid == DIALOG_SEX)
- {
- if ( !response || isnull(inputtext ) ) return ShowPlayerDialog(playerid,DIALOG_SEX,DIALOG_STYLE_LIST,"Care este sexul tau?","Masculin \nFeminin","Select","");
- {
- if(listitem == 0)
- {
- PlayerInfo[playerid][Sex] = 1;
- new
- Query [ 256 ]
- ;
- format ( Query , sizeof ( Query ) , "INSERT INTO `Jucatori` ( `Sex` ) VALUE ( '%d' )"
- , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) , PlayerInfo[playerid][Sex] ) ;
- db_free_result ( db_query ( Accounts , Query ) ) ;
- SendClientMessage(playerid,COLOR_WHITE,"[{3399FF}HardCore-Gaming{FFFFFF}]Bine,Deci esti baiat");
- ShowPlayerDialog(playerid,DIALOG_VARSTA,DIALOG_STYLE_INPUT,"Varsta","Scrie ce varsta ai!","OK","");
- }
- else if(listitem == 1)
- {
- PlayerInfo[playerid][Sex] = 1;
- new
- Query [ 256 ]
- ;
- format ( Query , sizeof ( Query ) , "INSERT INTO `Jucatori` ( `Sex` ) VALUE ( '%d' )"
- , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) , PlayerInfo[playerid][Sex] ) ;
- db_free_result ( db_query ( Accounts , Query ) ) ;
- SendClientMessage(playerid,COLOR_WHITE,"[{3399FF}HardCore-Gaming{FFFFFF}]Bine,Deci esti fata");
- ShowPlayerDialog(playerid,DIALOG_VARSTA,DIALOG_STYLE_INPUT,"Varsta","Scrie ce varsta ai!","OK","");
- }
- }
- }
- if(dialogid == DIALOG_VARSTA)
- {
- if ( !response || isnull(inputtext ) ) return ShowPlayerDialog(playerid,DIALOG_VARSTA,DIALOG_STYLE_INPUT,"Varsta","Scrie ce varsta ai!","OK","");
- {
- new varsta = strval(inputtext);
- if(varsta >5 && varsta<90)
- {
- new
- Query [ 256 ]
- ;
- format ( Query , sizeof ( Query ) , "INSERT INTO `Jucatori` ( `Varsta` ) VALUE ( '%d' )"
- , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) , varsta ) ;
- db_free_result ( db_query ( Accounts , Query ) ) ;
- new string[256];
- format(string,256,"[{3399FF}HardCore-Gaming{FFFFFF}]Bine,deci ai %d ani",varsta);
- SendClientMessage(playerid,COLOR_WHITE,string);
- }
- }
- SCM ( playerid , -1 , "Te-ai inregistrat cu succes." ) ;
- ShowPlayerDialog(playerid,DIALOG_SPAWN,DIALOG_STYLE_LIST,"Alege unde vrei sa fi spawnat","Los Santos \nSan Fierro \nLas Venturas","Select","");
- // SPD ( playerid , DIALOG_LOGIN , DIALOG_STYLE_PASSWORD , "Logheaza-te" , "Introdu parola in casuta de mai jos:" , "Login" , "Renunta" ) ;
- }
- if(dialogid == DIALOG_SPAWN)
- {
- if(response)
- {
- if(listitem == 0)
- {
- PlayerInfo[playerid][Spawn] = 1;//LS
- new
- Query [ 256 ]
- ;
- format ( Query , sizeof ( Query ) , "INSERT INTO `Jucatori` ( `Spawn` ) VALUE ( '%d' )"
- , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) , PlayerInfo[playerid][Spawn] ) ;
- db_free_result ( db_query ( Accounts , Query ) ) ;
- SendClientMessage(playerid,COLOR_WHITE,"[{3399FF}HardCore-Gaming{FFFFFF}]Bine,deci vei fi spawnat in Los Santos");
- SPD ( playerid , DIALOG_LOGIN , DIALOG_STYLE_PASSWORD , "Logheaza-te" , "Introdu parola in casuta de mai jos:" , "Login" , "" ) ;
- }
- else if(listitem == 1)
- {
- PlayerInfo[playerid][Spawn] = 2;//SF
- new
- Query [ 256 ]
- ;
- format ( Query , sizeof ( Query ) , "INSERT INTO `Jucatori` ( `Spawn` ) VALUE ( '%d' )"
- , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) , PlayerInfo[playerid][Spawn] ) ;
- db_free_result ( db_query ( Accounts , Query ) ) ;
- SendClientMessage(playerid,COLOR_WHITE,"[{3399FF}HardCore-Gaming{FFFFFF}]Bine,deci vei fi spawnat in San Fierro");
- SPD ( playerid , DIALOG_LOGIN , DIALOG_STYLE_PASSWORD , "Logheaza-te" , "Introdu parola in casuta de mai jos:" , "Login" , "" ) ;
- }
- else if(listitem == 2)
- {
- new
- Query [ 256 ]
- ;
- format ( Query , sizeof ( Query ) , "INSERT INTO `Jucatori` ( `Spawn` ) VALUE ( '%d' )"
- , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) , PlayerInfo[playerid][Spawn] ) ;
- db_free_result ( db_query ( Accounts , Query ) ) ;
- PlayerInfo[playerid][Spawn] = 3;//LV
- SendClientMessage(playerid,COLOR_WHITE,"[{3399FF}HardCore-Gaming{FFFFFF}]Bine,deci vei fi spawnat in Las Venturas");
- SPD ( playerid , DIALOG_LOGIN , DIALOG_STYLE_PASSWORD , "Logheaza-te" , "Introdu parola in casuta de mai jos:" , "Login" , "" ) ;
- }
- }
- }
- if ( dialogid == DIALOG_LOGIN )
- {
- if ( !response || isnull ( inputtext ) ) return SPD ( playerid , DIALOG_LOGIN , DIALOG_STYLE_PASSWORD , "Logheaza-te" , "Introdu parola in casuta de mai jos:" , "Login" , "" ) ;
- new
- Query [ 256 ] ,
- DBResult:Result
- ;
- format ( Query , sizeof ( Query ) , "SELECT `Bani` , `Scor` , `Ucideri` , `Decese` , 'Email' , 'Sex' , 'Varsta' , 'Interior' FROM `Jucatori` WHERE `Nume` = '%s' AND `Parola` = '%s'"
- , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) ) ;
- Result = db_query ( Accounts , Query ) ;
- if ( db_num_rows ( Result ) )
- {
- new
- Field [ 30 ]
- ;
- db_get_field_assoc ( Result , "Bani" , Field , 30 ) ;
- P_DATA [ playerid ] [ Bani ] = strval ( Field ) ;
- ResetPlayerMoney ( playerid ) ;
- GivePlayerMoney ( playerid , strval ( Field ) ) ;
- db_get_field_assoc ( Result , "Scor" , Field , 30 ) ;
- P_DATA [ playerid ] [ Scor ] = strval ( Field ) ;
- SetPlayerScore ( playerid , strval ( Field ) ) ;
- db_get_field_assoc ( Result , "Ucideri" , Field , 30 ) ;
- P_DATA [ playerid ] [ Ucideri ] = strval ( Field ) ;
- db_get_field_assoc ( Result , "Decese" , Field , 30 ) ;
- P_DATA [ playerid ] [ Decese ] = strval(Field);
- db_get_field_assoc ( Result , "Email" , Field , 30 ) ;
- P_DATA [ playerid ] [ Interior ] = strval(Field);
- db_get_field_assoc ( Result , "Sex" , Field , 30 ) ;
- P_DATA [ playerid ] [ Sex ] = strval(Field);
- db_get_field_assoc ( Result , "Varsta" , Field , 30 ) ;
- P_DATA [ playerid ] [ Varsta ] = strval(Field);
- db_get_field_assoc ( Result , "Interior" , Field , 30 ) ;
- P_DATA [ playerid ] [ Interior ] = strval(Field);
- }
- else
- {
- SPD ( playerid , DIALOG_LOGIN , DIALOG_STYLE_PASSWORD , "Logheaza-te" , "Parola gresita.Introdu parola in casuta de mai jos:" , "Login" , "" ) ;
- }
- db_free_result ( Result ) ;
- Logat [ playerid ] = true ;
- SpawnPlayer(playerid);
- return ( 1 ) ;
- }
- return ( 0 ) ;
- }
- stock DB_Escape ( text [] )
- {
- new
- ret[ MAX_INI_ENTRY_TEXT * 2 ] ,
- ch ,
- i ,
- j
- ;
- while ( ( ch = text [ i++ ] ) && j < sizeof ( ret ) )
- {
- if ( ch == '\'' )
- {
- if ( j < sizeof ( ret ) - 2 )
- {
- ret [ j++ ] = '\'' ;
- ret [ j++ ] = '\'' ;
- }
- }
- else if ( j < sizeof ( ret ) )
- {
- ret [ j++ ] = ch ;
- }
- else
- {
- j++ ;
- }
- }
- ret [ sizeof ( ret ) - 1 ] = '\0' ;
- return ret ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement