Advertisement
Guest User

Untitled

a guest
Nov 17th, 2011
588
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 28.81 KB | None | 0 0
  1. #include a_samp
  2. #include zcmd
  3. #include foreach
  4. #include Dini
  5.  
  6. #define Path                "manhunt/accounts/%s.sto"
  7. #define Version             "0.4"
  8. #define LastUpdate          "22st, October, 2011"
  9. #define Authors             "admantis & Mecaurio"
  10.  
  11. #define LOGIN_DIALOG        1
  12. #define REGISTER_DIALOG     2
  13. #define REGISTER2_DIALOG    3
  14. #define SETTINGS_DIALOG     4
  15. #define SKIN_DIALOG         5
  16. #define LOCKACC_DIALOG      6
  17. #define HELP_DIALOG         7
  18. #define MSG_DIALOG          0
  19.  
  20.  
  21. main(){}
  22. enum xx
  23. {
  24.     bool:LoggedIn,
  25.     Score,
  26.     Money,
  27.     Muted,
  28.     Locked,
  29.     Aislated,
  30.     Level,
  31.     Skin,
  32.     PlayingMinutes,
  33.     Hunts,
  34.     HuntedTimes,
  35.     DonatorLevel,
  36.     // due below, variables don't save in a file
  37.     LoginAttempts,
  38. }
  39.  
  40. new PlayerInfo[MAX_PLAYERS][xx];
  41.  
  42. new ManhuntVictim;
  43. new ManhuntVictimName[24];
  44. new ManhuntReward[2]; // 0 : score | 1 : money
  45. new TotalPlayers = 0;
  46.  
  47. new Text:Textdraw0;
  48. new Text:Textdraw1;
  49. new Text:Textdraw2;
  50. new Text:Textdraw3;
  51. new Text:Textdraw4;
  52. new Text:Textdraw5;
  53.  
  54. new Float:RandomSpawn[][4] =
  55. {
  56.     {713.1885,1195.6671,13.3964,276.8443},
  57.     {-84.7373,1378.8387,10.2734,350.3290},
  58.     {-317.1604,1052.4156,20.3403,9.2268},
  59.     {-314.4944,1773.9430,43.6406,139.5658},
  60.     {-857.3574,1536.6853,22.5870,307.9844},
  61.     {-783.6329,1446.7645,13.9453,162.7717},
  62.     {-1441.6185,2636.1814,55.8359,239.6728},
  63.     {-778.0161,2759.9465,45.6930,193.9529},
  64.     {-271.9291,2715.1750,62.6875,272.6671},
  65.     {-251.6501,2599.9866,62.8582,293.7300}
  66. };
  67.  
  68. native sscanf(const data[], const format[], {Float,_}:...);
  69. native unformat(const data[], const format[], {Float,_}:...) = sscanf;
  70.  
  71.  
  72. // Native publics
  73. public OnGameModeInit()
  74. {
  75.     for( new i = 0; i < 7; i ++ ) { printf( " " ); }
  76.    
  77.     printf(" ... loading sequence initialized ... ");
  78.     printf(" ... loading static vehicles ... " );
  79.     LoadStaticVehiclesFromFile( "manhunt/vehicles/bone.txt" );
  80.     LoadStaticVehiclesFromFile( "manhunt/vehicles/flint.txt" );
  81.     LoadStaticVehiclesFromFile( "manhunt/vehicles/lv_airport.txt" );
  82.     LoadStaticVehiclesFromFile( "manhunt/vehicles/lv_law.txt" );
  83.     LoadStaticVehiclesFromFile( "manhunt/vehicles/lv_gen.txt" );
  84.     LoadStaticVehiclesFromFile( "manhunt/vehicles/tierra.txt" );
  85.     LoadStaticVehiclesFromFile( "manhunt/vehicles/trains.txt" );
  86.     LoadStaticVehiclesFromFile( "manhunt/vehicles/whetstone.txt" );
  87.     printf(" ... creating graphics ... ");
  88.  
  89.     Textdraw0 = TextDrawCreate(810.000000, 84.000000, "New Textdraw");
  90.     TextDrawBackgroundColor(Textdraw0, 255);
  91.     TextDrawFont(Textdraw0, 1);
  92.     TextDrawLetterSize(Textdraw0, 0.800000, 15.000000);
  93.     TextDrawColor(Textdraw0, 572662306);
  94.     TextDrawSetOutline(Textdraw0, 0);
  95.     TextDrawSetProportional(Textdraw0, 1);
  96.     TextDrawSetShadow(Textdraw0, 1);
  97.     TextDrawUseBox(Textdraw0, 1);
  98.     TextDrawBoxColor(Textdraw0, 180);
  99.     TextDrawTextSize(Textdraw0, -8.000000, -229.000000);
  100.  
  101.     Textdraw1 = TextDrawCreate(258.000000, 95.000000, "The Manhunt");
  102.     TextDrawBackgroundColor(Textdraw1, 1721355519);
  103.     TextDrawFont(Textdraw1, 1);
  104.     TextDrawLetterSize(Textdraw1, 0.529999, 1.799999);
  105.     TextDrawColor(Textdraw1, 255);
  106.     TextDrawSetOutline(Textdraw1, 1);
  107.     TextDrawSetProportional(Textdraw1, 1);
  108.  
  109.     Textdraw2 = TextDrawCreate(70.000000, 307.000000, "Easy concept; random player is chosen, he is hunted down.");
  110.     TextDrawBackgroundColor(Textdraw2, 1721355519);
  111.     TextDrawFont(Textdraw2, 1);
  112.     TextDrawLetterSize(Textdraw2, 0.500000, 1.399999);
  113.     TextDrawColor(Textdraw2, 255);
  114.     TextDrawSetOutline(Textdraw2, 1);
  115.     TextDrawSetProportional(Textdraw2, 1);
  116.  
  117.     Textdraw3 = TextDrawCreate(130.000000, 322.000000, "Kill him, and become the new manhunt victim.");
  118.     TextDrawBackgroundColor(Textdraw3, 1721355519);
  119.     TextDrawFont(Textdraw3, 1);
  120.     TextDrawLetterSize(Textdraw3, 0.500000, 1.299999);
  121.     TextDrawColor(Textdraw3, 255);
  122.     TextDrawSetOutline(Textdraw3, 1);
  123.     TextDrawSetProportional(Textdraw3, 1);
  124.  
  125.     Textdraw4 = TextDrawCreate(150.000000, 336.000000, "For how long you will survive? Play now!");
  126.     TextDrawBackgroundColor(Textdraw4, 1721355519);
  127.     TextDrawFont(Textdraw4, 1);
  128.     TextDrawLetterSize(Textdraw4, 0.500000, 1.200000);
  129.     TextDrawColor(Textdraw4, 255);
  130.     TextDrawSetOutline(Textdraw4, 1);
  131.     TextDrawSetProportional(Textdraw4, 1);
  132.  
  133.     Textdraw5 = TextDrawCreate(432.000000, 430.000000, "Developed by admantis");
  134.     TextDrawBackgroundColor(Textdraw5, 16777215);
  135.     TextDrawFont(Textdraw5, 1);
  136.     TextDrawLetterSize(Textdraw5, 0.500000, 1.000000);
  137.     TextDrawColor(Textdraw5, 255);
  138.     TextDrawSetOutline(Textdraw5, 1);
  139.     TextDrawSetProportional(Textdraw5, 1);
  140.     TextDrawUseBox(Textdraw5, 1);
  141.     TextDrawBoxColor(Textdraw5, 255);
  142.     TextDrawTextSize(Textdraw5, 635.000000, 0.000000);
  143.  
  144.     printf(" ... fixing variables, it should take a few miliseconds ... ");
  145.    
  146.     SetGameModeText("The Manhunt");
  147.     SendRconCommand("mapname www.volt-host.com" );
  148.     ManhuntVictim = -1;
  149.     ManhuntVictimName = "";
  150.     TotalPlayers = 0;
  151.     ManhuntReward[0] = 0;
  152.     ManhuntReward[1] = 0;
  153.    
  154.     printf(" ... loading sequence finished, ready to play ... " );
  155.     printf(" ... displaying build information ... ");
  156.     printf(" ... version: %s ... ", Version );
  157.     printf(" ... last update: %s ...", LastUpdate );
  158.     printf(" ... authors: %s ...", Authors );
  159.    
  160.     for( new i = 0; i < 7; i ++ ) { printf( " " ); }
  161.    
  162.     return 1;
  163. }
  164.  
  165. public OnPlayerSpawn( playerid )
  166. {
  167.     TextDrawHideForPlayer( playerid, Textdraw0 );
  168.     TextDrawHideForPlayer( playerid, Textdraw1 );
  169.     TextDrawHideForPlayer( playerid, Textdraw2 );
  170.     TextDrawHideForPlayer( playerid, Textdraw3 );
  171.     TextDrawHideForPlayer( playerid, Textdraw4 );
  172.     TextDrawHideForPlayer( playerid, Textdraw5 );
  173.    
  174.     new szString[128];
  175.     new rand = random(sizeof(RandomSpawn));
  176.     SetPlayerPos( playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2] );
  177.     SetPlayerFacingAngle( playerid, RandomSpawn[rand][3] );
  178.     SetPlayerSkin( playerid, PlayerInfo[playerid][Skin] );
  179.    
  180.     if ( ManhuntVictim == -1 )
  181.     {
  182.         ManhuntReward[0] = Random( 1, 15 );
  183.         ManhuntReward[1] = Random( 500, 2000 );
  184.         ManhuntVictim = playerid;
  185.         ManhuntVictimName = GetName( playerid );
  186.  
  187.         SetPlayerColor( playerid, 0xFF0000FF );
  188.         format( szString, 128, "{FF0000}A new manhunt started! Pursuit and kill %s to win %d score and $%d!", GetName( playerid ), ManhuntReward[0], ManhuntReward[1] );
  189.         SendClientMessageToAll( -1, szString );
  190.     }
  191.    
  192.     if ( IsManhuntVictim ( playerid ) )
  193.     {
  194.         SendClientMessage( playerid, -1, "{F08080}You are the Manhunt Victim. Don't let anyone kill you! ");
  195.  
  196.         GivePlayerWeapon( playerid, Random( 22, 24 ), Random( 100, 300 ) );
  197.         GivePlayerWeapon( playerid, Random( 28, 32 ), Random( 100, 300 ) );
  198.         GivePlayerWeapon( playerid, Random( 4, 9 ), 1 );
  199.         SetPlayerArmour( playerid, Random( 25, 50 ) );
  200.     }
  201.     else
  202.     {
  203.         format( szString, 128, "{F08080}Kill %s to win %d score and $%d. There might be competition!", ManhuntVictimName, ManhuntReward[0], ManhuntReward[1] );
  204.         SendClientMessage( playerid, -1, szString );
  205.  
  206.         GivePlayerWeapon( playerid, Random( 22, 24 ), Random( 100, 300 ) );
  207.         GivePlayerWeapon( playerid, Random( 28, 32 ), Random( 100, 300 ) );
  208.         GivePlayerWeapon( playerid, Random( 4, 9 ), 1 );
  209.         SetPlayerArmour( playerid, Random( 10, 30 ) );
  210.     }
  211.    
  212.     if ( !IsPlayerConnected ( ManhuntVictim ) && ManhuntVictim > 0 )
  213.     {
  214.         ManhuntReward[0] = Random( 1, 15 );
  215.         ManhuntReward[1] = Random( 500, 2000 );
  216.         ManhuntVictim = playerid;
  217.         ManhuntVictimName = GetName( playerid );
  218.  
  219.         SetPlayerColor( playerid, 0xFF0000FF );
  220.         format( szString, 128, "{FF0000}A new manhunt started! Pursuit and kill %s to win %d score and $%d!", GetName( playerid ), ManhuntReward[0], ManhuntReward[1] );
  221.         SendClientMessageToAll( -1, szString );
  222.     }
  223.    
  224.     if ( !IsPlayerConnected ( ManhuntVictim ) && ManhuntVictim != -1)
  225.     {
  226.         new randplayer = GetRandomPlayer();
  227.         ManhuntReward[0] = Random( 1, 15 );
  228.         ManhuntReward[1] = Random( 500, 2000 );
  229.         ManhuntVictim = randplayer;
  230.         ManhuntVictimName = GetName( randplayer );
  231.  
  232.         SetPlayerColor( randplayer, 0xFF0000FF );
  233.         format( szString, 128, "{FF0000}%s is now the new manhunt victim! Kill them to win %d score and $%d!", GetName( randplayer ), ManhuntReward[0], ManhuntReward[1] );
  234.         SendClientMessageToAll( -1, szString );
  235.  
  236.         printf(" ... new manhunt victim %s (id%d) reward %d and $%d", GetName( randplayer ), randplayer, ManhuntReward[0], ManhuntReward[1] );
  237.     }
  238.    
  239.     if ( GetPlayerSkin( playerid ) == 0 )
  240.     {
  241.         SetPlayerSkin( playerid, 29 );
  242.     }
  243.    
  244.     return 1;
  245. }
  246.  
  247. public OnPlayerDeath( playerid, killerid, reason )
  248. {
  249.     new szString[ 128 ];
  250.    
  251.     if ( IsManhuntVictim ( playerid ) )
  252.     {
  253.         if ( killerid == INVALID_PLAYER_ID )
  254.         {
  255.             format( szString, 128, "{6699CC}The manhunt victim %s died in an accident. Starting new manhunt round!", GetName( playerid ) );
  256.             SendClientMessageToAll( -1, szString );
  257.            
  258.             new randplayer = GetRandomPlayer();
  259.             ManhuntReward[0] = Random( 1, 15 );
  260.             ManhuntReward[1] = Random( 500, 2000 );
  261.             ManhuntVictim = randplayer;
  262.             ManhuntVictimName = GetName( randplayer );
  263.            
  264.             SetPlayerColor( randplayer, 0xFF0000FF );
  265.             format( szString, 128, "{FF0000}%s is now the new manhunt victim! Kill them to win %d score and $%d!", GetName( randplayer ), ManhuntReward[0], ManhuntReward[1] );
  266.             SendClientMessageToAll( -1, szString );
  267.            
  268.             printf(" ... new manhunt victim %s (id%d) reward %d and $%d", GetName( randplayer ), randplayer, ManhuntReward[0], ManhuntReward[1] );
  269.         }
  270.         else
  271.         {
  272.             format( szString, 128, "{6699CC}The manhunt victim %s has been killed by %s and has became the new manhunt victim. ", GetName( playerid ), GetName( killerid ) );
  273.             SendClientMessageToAll( -1, szString );
  274.            
  275.             ManhuntReward[0] = Random( 1, 15 );
  276.             ManhuntReward[1] = Random( 500, 2000 );
  277.             ManhuntVictim = killerid;
  278.             ManhuntVictimName = GetName( killerid );
  279.  
  280.             PlayerInfo[killerid][Hunts] += 1;
  281.             PlayerInfo[playerid][HuntedTimes] += 1;
  282.             SetPlayerScore( killerid, ManhuntReward[0] );
  283.             GivePlayerMoney( killerid, ManhuntReward[1] );
  284.            
  285.             SetPlayerColor( killerid, 0xFF0000FF );
  286.             format( szString, 128, "{FF0000}A new manhunt started! Pursuit and kill %s to win %d score and $%d!", GetName( killerid ), ManhuntReward[0], ManhuntReward[1] );
  287.             SendClientMessageToAll( -1, szString );
  288.            
  289.             printf(" ... new manhunt victim %s (id%d) reward %d and $%d", GetName( killerid ), killerid, ManhuntReward[0], ManhuntReward[1] );
  290.         }
  291.     }
  292. }
  293.  
  294. public OnPlayerDisconnect(playerid, reason)
  295. {
  296.     new szString[128];
  297.    
  298.     if ( PlayerInfo[playerid][LoggedIn] == true )
  299.     {
  300.         new szFile[128];
  301.         format( szFile, 128, Path, GetName( playerid ) );
  302.         if ( fexist ( szFile ) )
  303.         {
  304.             dini_IntSet( szFile, "Score", GetPlayerScore( playerid ) );
  305.             dini_IntSet( szFile, "Money", GetPlayerMoney( playerid ) );
  306.             dini_IntSet( szFile, "Muted", PlayerInfo[playerid][Muted] );
  307.             dini_IntSet( szFile, "Locked", PlayerInfo[playerid][Locked] );
  308.             dini_IntSet( szFile, "Aislated", PlayerInfo[playerid][Aislated] );
  309.             dini_IntSet( szFile, "Level", PlayerInfo[playerid][Level] );
  310.             dini_IntSet( szFile, "Skin", GetPlayerSkin( playerid ) );
  311.             dini_IntSet( szFile, "PlayingMinutes", PlayerInfo[playerid][PlayingMinutes] );
  312.             dini_IntSet( szFile, "Hunts", PlayerInfo[playerid][Hunts] );
  313.             dini_IntSet( szFile, "HuntedTimes", PlayerInfo[playerid][HuntedTimes] );
  314.             dini_IntSet( szFile, "DonatorLevel", PlayerInfo[playerid][DonatorLevel] );
  315.         }
  316.     }
  317.    
  318.     if ( ManhuntVictim == playerid )
  319.     {
  320.         if ( TotalPlayers == 1 )
  321.         {
  322.             ManhuntVictim = -1;
  323.             ManhuntVictimName = "";
  324.             ManhuntReward[0] = 0;
  325.             ManhuntReward[1] = 0;
  326.             printf(" ... manhunt victim %s (id%d) left the server ...", GetName(playerid), playerid);
  327.             printf(" ... couldn't start new manhunt, no online players, waiting for players ... ");
  328.         }
  329.         else
  330.         {
  331.             new randplayer = GetRandomPlayer();
  332.             ManhuntReward[0] = Random( 1, 15 );
  333.             ManhuntReward[1] = Random( 500, 2000 );
  334.             ManhuntVictim = randplayer;
  335.             ManhuntVictimName = GetName( randplayer );
  336.  
  337.             SetPlayerColor( randplayer, 0xFF0000FF );
  338.             format( szString, 128, "{FF0000}%s is now the new manhunt victim! Kill them to win %d score and $%d!", GetName( randplayer ), ManhuntReward[0], ManhuntReward[1] );
  339.             SendClientMessageToAll( -1, szString );
  340.             printf(" ... %s left so %s (id%d) is now the hunt victim reward %d score & $%d money ...", playerid, ManhuntVictimName, ManhuntVictim, ManhuntReward[0], ManhuntReward[1] );
  341.         }
  342.     }
  343.  
  344.     if (reason)
  345.     {
  346.         if ( reason == 0 ) format( szString, 128, "{9ACD32} * %s has disconnected from the server (Timeout).", GetName( playerid ) );
  347.         else if ( reason == 1 ) format( szString, 128, "{9ACD32} * %s has disconnected from the server (Leaving).", GetName( playerid ) );
  348.         else if ( reason == 2 ) format( szString, 128, "{9ACD32} * %s has disconnected from the server (Kicked or Banned).", GetName( playerid ) );
  349.         SendClientMessageToAll( -1, szString );
  350.     }
  351.     TotalPlayers -= 1;
  352.     return 1;
  353. }
  354.  
  355. public OnPlayerConnect( playerid )
  356. {
  357.     TotalPlayers += 1;
  358.     ClearChat( false, playerid ); ClearChat( false, playerid ); ClearChat( false, playerid );
  359.     TextDrawShowForPlayer( playerid, Textdraw0 );
  360.     TextDrawShowForPlayer( playerid, Textdraw1 );
  361.     TextDrawShowForPlayer( playerid, Textdraw2 );
  362.     TextDrawShowForPlayer( playerid, Textdraw3 );
  363.     TextDrawShowForPlayer( playerid, Textdraw4 );
  364.     TextDrawShowForPlayer( playerid, Textdraw5 );
  365.  
  366.     PlayerInfo[playerid][LoggedIn] = false;
  367.     TogglePlayerSpectating( playerid, 1 );
  368.     SetPlayerPos( playerid, 340.3234,1734.9473,70.2102 );
  369.     SetPlayerCameraPos( playerid, 340.3234,1734.9473,70.2102 );
  370.     SetPlayerCameraLookAt( playerid, 187.8685,1897.0536,34.3850 );
  371.    
  372.     new szFile[128];
  373.     format( szFile, 128, Path, GetName( playerid ) );
  374.     if ( fexist ( szFile ) )
  375.     {
  376.         if ( dini_Int ( szFile, "Locked" ) != 0 )
  377.         {
  378.             SendClientMessage( playerid, -1, "Account Locked.");
  379.             SendClientMessage( playerid, -1, "If you think this is an unfair lock, post a ban appeal in our forums.");
  380.             printf(" ... %s (id%d) couldn't join because he/she is locked ...", GetName( playerid ), playerid );
  381.             Kick( playerid );
  382.         }
  383.         ShowPlayerDialog( playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "{6699CC}Dear Manhunt Member", "{FFFFFF}This account is registered. To log in, input the password in the field.", "Log In", "Quit" );
  384.     }
  385.     else if ( !fexist ( szFile ) )
  386.     {
  387.         ShowPlayerDialog( playerid, REGISTER_DIALOG, DIALOG_STYLE_INPUT, "{6699CC}Dear SA-MP Player", "{FFFFFF}This account is not registered. To register, input the password in the field.\nRemember this is a English only server!", "Register", "Quit" );
  388.     }
  389.  
  390.     SendClientMessage(playerid, 0x0000FFFF, "Welcome to Manhunt. Server is only available to testers and is in development.");
  391.  
  392.     format( szFile, 128, "{9ACD32} * %s has joined the server.", GetName( playerid ) );
  393.     SendClientMessageToAll( -1, szFile );
  394.     return 1;
  395. }
  396.  
  397. public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[] )
  398. {
  399.     switch( dialogid )
  400.     {
  401.         case REGISTER_DIALOG:
  402.         {
  403.             if ( !strlen ( inputtext ) )
  404.             {
  405.                 ShowPlayerDialog( playerid, REGISTER_DIALOG, DIALOG_STYLE_INPUT, "{FF0000}Unacceptable Password! Too short or too long.", "{FFFFFF}This account is not registered. To register, input the password in the field.\nRemember this is a English only server!", "Register", "Quit" );
  406.                 return 1;
  407.             }
  408.             ShowPlayerDialog( playerid, REGISTER2_DIALOG, DIALOG_STYLE_MSGBOX, "{00FF00}Account Registered!", "{FFFFFF}Thanks for registering in Manhunt!\nYou can change your account settings with /settings", "OK", "" );
  409.  
  410.             new szFile[128];
  411.             format( szFile, 128, Path, GetName( playerid ) );
  412.            
  413.             GivePlayerMoney( playerid, 1000 );
  414.             SetPlayerScore( playerid, 10 );
  415.             SetPlayerSkin( playerid, 1 );
  416.             PlayerInfo[playerid][Skin] = 1;
  417.            
  418.             dini_Create( szFile );
  419.             dini_Set( szFile, "Password", inputtext );
  420.             dini_IntSet( szFile, "Score", GetPlayerScore( playerid ) );
  421.             dini_IntSet( szFile, "Money", GetPlayerMoney( playerid ) );
  422.             dini_IntSet( szFile, "Muted", 0 );
  423.             dini_IntSet( szFile, "Locked", 0 );
  424.             dini_IntSet( szFile, "Aislated", 0 );
  425.             dini_IntSet( szFile, "Level", 0 );
  426.             dini_IntSet( szFile, "Skin", GetPlayerSkin( playerid ) );
  427.             dini_IntSet( szFile, "PlayingMinutes", 1 );
  428.             dini_IntSet( szFile, "Hunts", 0 );
  429.             dini_IntSet( szFile, "HuntedTimes", 0 );
  430.             dini_IntSet( szFile, "DonatorLevel", 0 );
  431.             PlayerInfo[playerid][LoggedIn] = true;
  432.             printf(" ... %s (id%d) registered account", GetName( playerid ), playerid);
  433.            
  434.             return 1;
  435.         }
  436.        
  437.         case LOGIN_DIALOG:
  438.         {
  439.             if ( response)
  440.             {
  441.                 new szFile[128], Checker[128];
  442.                 format( szFile, 128, Path, GetName( playerid ) );
  443.                 Checker = dini_Get( szFile, "Password" );
  444.  
  445.                 if ( !strcmp ( inputtext, Checker, false ) )
  446.                 {
  447.                     PlayerInfo[playerid][Score] = dini_Int( szFile, "Score" );
  448.                     PlayerInfo[playerid][Money] = dini_Int( szFile, "Money" );
  449.                     PlayerInfo[playerid][Muted] = dini_Int( szFile, "Muted" );
  450.                     PlayerInfo[playerid][Locked] = dini_Int( szFile, "Locked" );
  451.                     PlayerInfo[playerid][Aislated] = dini_Int( szFile, "Aislated" );
  452.                     PlayerInfo[playerid][Level] = dini_Int( szFile, "Level" );
  453.                     PlayerInfo[playerid][Skin] = dini_Int( szFile, "Skin" );
  454.                     PlayerInfo[playerid][PlayingMinutes] = dini_Int( szFile, "PlayingMinutes" );
  455.                     PlayerInfo[playerid][Hunts] = dini_Int( szFile, "Hunts" );
  456.                     PlayerInfo[playerid][HuntedTimes] = dini_Int( szFile, "HuntedTimes" );
  457.                     PlayerInfo[playerid][DonatorLevel] = dini_Int( szFile, "DonatorLevel" );
  458.  
  459.                     SetPlayerScore( playerid, PlayerInfo[playerid][Score] );
  460.                     GivePlayerMoney( playerid, ( -GetPlayerMoney( playerid ) ) + PlayerInfo[playerid][Money] );
  461.                     SetPlayerSkin( playerid, PlayerInfo[playerid][Skin] );
  462.  
  463.                     TogglePlayerSpectating( playerid, 0 );
  464.                     SetSpawnInfo( playerid, 0, PlayerInfo[playerid][Skin], 3.0, 3.0, 10.0, 360.0, 0, 0, 0, 0, 0, 0 );
  465.                     SpawnPlayer( playerid );
  466.                     PlayerInfo[playerid][LoggedIn] = true;
  467.                     PlayerInfo[playerid][LoginAttempts] = 0;
  468.                     SendClientMessage( playerid, -1, "{6699CC}Thanks for logging in!");
  469.  
  470.                     printf(" ... %s (id%d) logged in his account ...", GetName( playerid ), playerid );
  471.                     return 1;
  472.                 }
  473.                 else
  474.                 {
  475.                     SendClientMessage( playerid, -1, "{FF6347}Wrong password. Remember passwords are CaSe SeNsItIvE.");
  476.  
  477.                     PlayerInfo[playerid][LoginAttempts] += 1;
  478.                     if ( PlayerInfo[playerid][LoginAttempts] == 5 )
  479.                     {
  480.                          SendClientMessage( playerid, -1, " You have been kicked for security reasons." );
  481.                          printf(" ... %s (id%d) was kicked for 5 failed login attempts ...", GetName( playerid ), playerid );
  482.                          Kick( playerid );
  483.                     }
  484.                     ShowPlayerDialog( playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "{6699CC}Dear Manhunt Member", "{FFFFFF}This account is registered. To log in, input the password in the field.", "Log In", "Quit" );
  485.                     return 1;
  486.                 }
  487.             }
  488.             else
  489.             {
  490.                 Kick(playerid);
  491.             }
  492.             return 1;
  493.         }
  494.        
  495.         case REGISTER2_DIALOG:
  496.         {
  497.             SendClientMessage( playerid, -1, "{66FF33} You have registered. Have fun!" );
  498.             TogglePlayerSpectating( playerid, 0 );
  499.             SetSpawnInfo( playerid, 0, PlayerInfo[playerid][Skin], 3.0, 3.0, 10.0, 360.0, 0, 0, 0, 0, 0, 0 );
  500.             SpawnPlayer( playerid );
  501.             return 1;
  502.         }
  503.        
  504.         case SETTINGS_DIALOG:
  505.         {
  506.             if ( response )
  507.             {
  508.                 switch( listitem )
  509.                 {
  510.                     case 0:
  511.                     {
  512.                         ShowPlayerDialog( playerid, SKIN_DIALOG, DIALOG_STYLE_INPUT, "{99FF99}Input a valid skin ID.", "{FFFFFF}To change your skin, input a valid skin ID (0-300)", "OK", "Go Back" );
  513.                         return 1;
  514.                     }
  515.                     case 1:
  516.                     {
  517.                         ShowPlayerDialog( playerid, LOCKACC_DIALOG, DIALOG_STYLE_MSGBOX, "{99FF99}Lock Account Confirmation.", "{FFFFFF}You are about to lock your account.\n{FF0000}This method can't be undone, and is permanent!\nWhatever is your reason, please think twice before locking your account.", "OK", "Cancel");
  518.                         return 1;
  519.                     }
  520.                 }
  521.             }
  522.         }
  523.        
  524.         case SKIN_DIALOG:
  525.         {
  526.             if ( IsValidSkin ( strval(inputtext) ) )
  527.             {
  528.                 if ( response )
  529.                 {
  530.                     SendClientMessage( playerid, -1, "{00FF00}Skin changed.");
  531.                     SetPlayerSkin( playerid, strval(inputtext) );
  532.                     PlayerInfo[playerid][Skin] = strval(inputtext);
  533.                     ShowSettingsDialog( playerid );
  534.                     printf(" ... %s (id%d) changed skin to %d via account setting menu ...", GetName( playerid ), playerid, strval( inputtext ) );
  535.                 }
  536.                 else if ( ! response )
  537.                 {
  538.                     ShowSettingsDialog( playerid );
  539.                 }
  540.             }
  541.             else
  542.             {
  543.                 ShowSettingsDialog( playerid );
  544.                 SendClientMessage( playerid, -1, "{FF0000}Invalid skin ID (below 0, above 300, or unfunctional.");
  545.             }
  546.         }
  547.        
  548.         case LOCKACC_DIALOG:
  549.         {
  550.             if ( response )
  551.             {
  552.                 SendClientMessage(playerid, -1, "Account Locked.");
  553.                 PlayerInfo[playerid][Locked] = 1;
  554.                 printf(" ... sadly, %s (id%d) locked his account ...", GetName( playerid ), playerid );
  555.                 Kick(playerid);
  556.             }
  557.             else if ( !response )
  558.             {
  559.                 ShowSettingsDialog( playerid );
  560.             }
  561.         }
  562.        
  563.         case HELP_DIALOG:
  564.         {
  565.             switch( listitem )
  566.             {
  567.                 case 0:
  568.                 {
  569.                     if ( response )
  570.                     {
  571.                         ShowPlayerDialog( playerid, MSG_DIALOG, DIALOG_STYLE_MSGBOX, "{99FF99}Manhunt Commands", "Basic:{FFFFFF} /kill, /settings, /help, /admins, /report, /pm, /info", "OK", "");
  572.                     }
  573.                 }
  574.                 case 1:
  575.                 {
  576.                     if ( response )
  577.                     {
  578.                         ShowPlayerDialog( playerid, MSG_DIALOG, DIALOG_STYLE_MSGBOX, "{99FF99}Manhunt Concept", "{FFFFFF}The Manhunt is a gamemode where a random player is randomly chosen.\nThen, the other players must hunt him down.\nIn change, who hunts down the 'victim', may receive a reward (random money and score).\nBut also, he will become the new 'victim', so other players must hunt him down.\n\n{6699CC}Have fun playing Manhunt, and remember to respect everyone and follow the rules!", "I agree", "");
  579.                     }
  580.                 }
  581.                 case 2:
  582.                 {
  583.                     if ( response )
  584.                     {
  585.                         ShowSettingsDialog( playerid );
  586.                     }
  587.                 }
  588.             }
  589.         }
  590.     }
  591.    
  592.     return 1;
  593. }
  594.            
  595.  
  596. public OnPlayerText( playerid, text[] )
  597. {
  598.     if ( IsManhuntVictim( playerid ) )
  599.     {
  600.         new szOutput[128];
  601.         format( szOutput, 128, "{FF0000}Manhunt %s: {CC0000}%s", GetName( playerid ), text );
  602.         SendClientMessageToAll( -1, szOutput );
  603.         return 0;
  604.     }
  605.    
  606.     return 1;
  607. }
  608.  
  609. public OnPlayerStateChange(playerid,newstate,oldstate)
  610. {
  611.     if ( newstate == 2 || newstate == 3 )
  612.     {
  613.         if ( IsAirVehicle ( GetPlayerVehicleID ( playerid ) ) )
  614.         {
  615.             if ( IsManhuntVictim ( playerid ) )
  616.             {
  617.                 RemovePlayerFromVehicle( playerid );
  618.                 SendClientMessage(playerid, 0xC0C0C0FF, "You may not be in this vehicle at the moment.");
  619.             }
  620.         }
  621.     }
  622.     return 1;
  623. }
  624.  
  625. // Stock functions
  626.  
  627. stock GetRandomPlayer()
  628. {
  629.     new yplayer[MAX_PLAYERS+1];
  630.    
  631.     for (new y = 0; y != MAX_PLAYERS; y ++)
  632.     {
  633.         if (IsPlayerConnected(y))
  634.         {
  635.             yplayer[0] ++;
  636.             yplayer[yplayer[0]] = y;
  637.         }
  638.     }
  639.    
  640.     return yplayer[random(yplayer[0])+1];
  641. }
  642.  
  643. stock IsManhuntVictim( playerid )
  644. {
  645.     return ( ManhuntVictim == playerid ) ? 1 : 0;
  646. }
  647.  
  648. stock Random( min, max )
  649. {
  650.     return min + random ( ( max - min ) );
  651. }
  652.  
  653. stock GetName( playerid )
  654. {
  655.     new szName[24] = "";
  656.    
  657.     if ( IsPlayerConnected ( playerid ) )
  658.     {
  659.         GetPlayerName( playerid, szName, 24 );
  660.     }
  661.    
  662.     return szName;
  663. }
  664.  
  665. stock IsValidSkin(skinid)
  666. {
  667.     #define MAX_BAD_SKINS 22
  668.     new badSkins[MAX_BAD_SKINS] =
  669.     {
  670.         3, 4, 5, 6, 8, 42, 65, 74, 86,
  671.         119, 149, 208, 265, 266, 267,
  672.         268, 269, 270, 271, 272, 273, 289
  673.     };
  674.     if (skinid < 0 || skinid > 299) return false;
  675.     for (new i = 0; i < MAX_BAD_SKINS; i++)
  676.     {
  677.         if (skinid == badSkins[i]) return false;
  678.     }
  679.     #undef MAX_BAD_SKINS
  680.     return 1;
  681. }
  682.  
  683. stock ClearChat( bool:global, playerid = -1)
  684. {
  685.     if ( global == true )
  686.     {
  687.         foreach(Player, i)
  688.         {
  689.             for( new g = 0; g < 30; g++ )
  690.             {
  691.                 SendClientMessage( i, -1, " " );
  692.             }
  693.         }
  694.     }
  695.     else
  696.     {
  697.         for(new i = 0; i < 30; i ++ )
  698.         {
  699.             SendClientMessage( playerid, -1, " " );
  700.         }
  701.     }
  702.     return 1;
  703. }
  704.  
  705. // Functions below allow loading vehicles from an exterior file.
  706. stock TokenByDelimiter(const szString[], szReturnStr[], Delimiter, iStartIndex )
  707. {
  708.     new x = 0;
  709.     while( szString[iStartIndex] != EOS && szString[iStartIndex] != Delimiter ) {
  710.         szReturnStr[x] = szString[iStartIndex];
  711.         x++;
  712.         iStartIndex++;
  713.     }
  714.     szReturnStr[x] = EOS;
  715.     if( szString[iStartIndex] == EOS ) iStartIndex = (-1);
  716.     return iStartIndex;
  717. }
  718.  
  719. stock LoadStaticVehiclesFromFile(const FileName[])
  720. {
  721.     new File:FileRoot;
  722.     new FileLine[256];
  723.     new VariableHatch[64];
  724.     new Type;
  725.     new Float:SpawnX;
  726.     new Float:SpawnY;
  727.     new Float:SpawnZ;
  728.     new Float:SpawnRot;
  729.     new Color1, Color2;
  730.     new Index;
  731.     new iLoadedVehicles;
  732.  
  733.     FileRoot = fopen(FileName,filemode:io_read);
  734.     if(!FileRoot) return 0;
  735.  
  736.     iLoadedVehicles = 0;
  737.  
  738.     while(fread(FileRoot,FileLine,256) > 0)
  739.     {
  740.         Index = 0;
  741.  
  742.         // Read type
  743.         Index = TokenByDelimiter(FileLine,VariableHatch,',',Index);
  744.         if(Index == (-1)) continue;
  745.         Type = strval(VariableHatch);
  746.         if(Type < 400 || Type > 611) continue;
  747.  
  748.         // Read X, Y, Z, Rotation
  749.         Index = TokenByDelimiter(FileLine,VariableHatch,',',Index+1);
  750.         if(Index == (-1)) continue;
  751.         SpawnX = floatstr(VariableHatch);
  752.  
  753.         Index = TokenByDelimiter(FileLine,VariableHatch,',',Index+1);
  754.         if(Index == (-1)) continue;
  755.         SpawnY = floatstr(VariableHatch);
  756.  
  757.         Index = TokenByDelimiter(FileLine,VariableHatch,',',Index+1);
  758.         if(Index == (-1)) continue;
  759.         SpawnZ = floatstr(VariableHatch);
  760.  
  761.         Index = TokenByDelimiter(FileLine,VariableHatch,',',Index+1);
  762.         if(Index == (-1)) continue;
  763.         SpawnRot = floatstr(VariableHatch);
  764.  
  765.         // Read Color1, Color2
  766.         Index = TokenByDelimiter(FileLine,VariableHatch,',',Index+1);
  767.         if(Index == (-1)) continue;
  768.         Color1 = strval(VariableHatch);
  769.  
  770.         Index = TokenByDelimiter(FileLine,VariableHatch,';',Index+1);
  771.         Color2 = strval(VariableHatch);
  772.  
  773.         //printf("%d,%d,%f,%f,%f,%f,%d,%d",total_vehicles_from_files+iLoadedVehicles+1,Type,SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2);
  774.  
  775.         AddStaticVehicleEx(Type,SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2,(30*60)); // respawn 30 minutes
  776.  
  777.         /*new numplate_test[32+1];
  778.         format(numplate_test,32,"GRLC{44AA33}%d",vid);
  779.         SetVehicleNumberPlate(vid, numplate_test);*/
  780.  
  781.         iLoadedVehicles++;
  782.     }
  783.    
  784.     fclose(FileRoot);
  785.     return iLoadedVehicles;
  786. }
  787.  
  788. stock ShowSettingsDialog( playerid )
  789. {
  790.     new Formatter[64];
  791.     new Final[256];
  792.     format( Formatter, 64, "{99FF99}Skin:\t {FFFFFF}%d\n", GetPlayerSkin( playerid ) );
  793.     strcat( Final, Formatter, sizeof( Final ) );
  794.     format( Formatter, 64, "%s", "{99FF99}Delete My Account" );
  795.     strcat( Final, Formatter, sizeof( Final ) );
  796.     ShowPlayerDialog( playerid, SETTINGS_DIALOG, DIALOG_STYLE_LIST, "{FFFFFF}Account Configuration Menu", Final, "Continue", "Close" );
  797.  
  798.     return 1;
  799. }
  800.  
  801. stock IsAirVehicle( vehicleid )
  802. {
  803.     new mod = GetVehicleModel(vehicleid);
  804.     return bool:( mod == 592 || mod == 577 || mod == 511 || mod == 512 ||
  805.                   mod == 593 || mod == 520 || mod == 553 || mod == 476 ||
  806.                   mod == 519 || mod == 460 || mod == 513 || mod == 548 ||
  807.                   mod == 417 || mod == 487 || mod == 488 || mod == 497 ||
  808.                   mod == 563 || mod == 447 || mod == 469 ) ? true : false;
  809. }
  810.  
  811. // Commands ZCMD
  812. CMD:kill( playerid, params[] )
  813. {
  814.     SetPlayerHealth(playerid,0);
  815.     return 1;
  816. }
  817.  
  818. CMD:settings( playerid, params[] )
  819. {
  820.     if ( PlayerInfo[playerid][LoggedIn] == false )
  821.     {
  822.         SendClientMessage( playerid, -1, " You have been kicked for security reasons." );
  823.         Kick( playerid );
  824.         return 1;
  825.     }
  826.    
  827.     ShowSettingsDialog( playerid );
  828.     return 1;
  829. }
  830.  
  831. CMD:help( playerid, params[] )
  832. {
  833.     ShowPlayerDialog( playerid, HELP_DIALOG, DIALOG_STYLE_LIST, "{99FF99}Help Menu", "{FFFFFF}Server Commands\nGame Concept\nAccount Setting Menu", "OK", "Close");
  834.     return 1;
  835. }
  836.  
  837. CMD:info( playerid, params[] )
  838. {
  839.     if ( ManhuntVictim == -1 )
  840.     {
  841.         SendClientMessage( playerid, -1, "{FF6347}No manhunt in progress.");
  842.         return 1;
  843.     }
  844.     else
  845.     {
  846.         new szFormat[128], DialogStr[182];
  847.         format( szFormat, 128, "{99FF99}Manhunt Victim:{FFFFFF} %s(id:%d)\n", ManhuntVictimName, ManhuntVictim );
  848.         strcat( DialogStr, szFormat, 182 );
  849.         format( szFormat, 128, "{99FF99}Money Reward for killing %s:{FFFFFF} $%d\n", ManhuntVictimName, ManhuntReward[1] );
  850.         strcat( DialogStr, szFormat, 182 );
  851.         format( szFormat, 128, "{99FF99}Score Reward for killing %s:{FFFFFF} %d", ManhuntVictimName, ManhuntReward[0] );
  852.         strcat( DialogStr, szFormat, 182 );
  853.         ShowPlayerDialog( playerid, MSG_DIALOG, DIALOG_STYLE_MSGBOX, "{99FF99}General Manhunt Information", DialogStr, "OK", "");
  854.     }
  855.     return 1;
  856. }
  857.  
  858. CMD:pm( playerid, params[] )
  859. {
  860.     new Victim, Message[128];
  861.     if ( sscanf ( params, "us[128]", Victim, Message ) )
  862.     {
  863.         return SendClientMessage( playerid, -1, "{c0c0c0}Syntax: /pm ");
  864.     }
  865.     return 1;
  866. }
  867.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement