Guest User

Untitled

a guest
Jan 1st, 2013
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 14.29 KB | None | 0 0
  1. #include <a_samp>
  2. #include "../include/gl_common.inc"
  3. #include <streamer>
  4. #include <YSI\y_ini>
  5.  
  6. #define TEAM_GROVE 1
  7. #define TEAM_BALLAS 2
  8. #define TEAM_GROVE_COLOR 0x00FF00AA
  9. #define TEAM_BALLAS_COLOR 0xFF00FFAA
  10.  
  11. #define DIALOG_CARSHOP 1
  12. #define DIALOG_JETPACKANDPARACHUTESHOP 2
  13. #define DIALOG_AIRCRAFTSHOP 3
  14. #define DIALOG_HEAVYWEAPONSSHOP 4
  15. #define DIALOG_NOTENOUGHMONEY 5
  16. #define DIALOG_RULES 6
  17.  
  18. new total_vehicles_from_files=0;
  19. new gTeam[MAX_PLAYERS];
  20. new Checkpoint[4];
  21. new CarShopCar[MAX_PLAYERS];
  22. new AircraftShopVehicle[MAX_PLAYERS];
  23. new iniplayermoney, iniplayerscore;
  24. new rulesnotaccepted;
  25.  
  26. main()
  27. {
  28.     print("\n----------------------------------");
  29.     print(" Grove vs Ballas by Sydcul");
  30.     print("----------------------------------\n");
  31. }
  32.  
  33. public OnGameModeInit()
  34. {
  35.     SetGameModeText("Grove vs Ballas");
  36.     AddPlayerClass(105, 2512.0581, -1672.3823, 13.4813, 66.2349, WEAPON_KNIFE, 1, WEAPON_COLT45, 0x7FFFFFFF, WEAPON_TEC9, 0x7FFFFFFF);
  37.     AddPlayerClass(106, 2512.0581, -1672.3823, 13.4813, 66.2349, WEAPON_KNIFE, 1, WEAPON_COLT45, 0x7FFFFFFF, WEAPON_TEC9, 0x7FFFFFFF);
  38.     AddPlayerClass(107, 2512.0581, -1672.3823, 13.4813, 66.2349, WEAPON_KNIFE, 1, WEAPON_COLT45, 0x7FFFFFFF, WEAPON_TEC9, 0x7FFFFFFF);
  39.     AddPlayerClass(102, 2172.8787, -1672.7426, 15.0859, 286.4139, WEAPON_BAT, 1, WEAPON_COLT45, 0x7FFFFFFF, WEAPON_UZI, 0x7FFFFFFF);
  40.     AddPlayerClass(103, 2172.8787, -1672.7426, 15.0859, 286.4139, WEAPON_BAT, 1, WEAPON_COLT45, 0x7FFFFFFF, WEAPON_UZI, 0x7FFFFFFF);
  41.     AddPlayerClass(104, 2172.8787, -1672.7426, 15.0859, 286.4139, WEAPON_BAT, 1, WEAPON_COLT45, 0x7FFFFFFF, WEAPON_UZI, 0x7FFFFFFF);
  42.    
  43.     total_vehicles_from_files += LoadStaticVehiclesFromFile("tdm/vehicles.txt");
  44.     return 1;
  45. }
  46.  
  47. public OnGameModeExit() {
  48.     for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
  49.     {
  50.         new playername[MAX_PLAYER_NAME+1], filename[16+MAX_PLAYER_NAME];
  51.  
  52.         GetPlayerName(playerid, playername, sizeof(playername));
  53.         format(filename, sizeof(filename), "tdm/players/%s.ini", playername);
  54.  
  55.         new INI:iniFile = INI_Open(filename);
  56.  
  57.         INI_SetTag(iniFile, "playerdata");
  58.         INI_WriteInt(iniFile, "money", GetPlayerMoney(playerid));
  59.         INI_WriteInt(iniFile, "score", GetPlayerScore(playerid));
  60.  
  61.         INI_Close(iniFile);
  62.     }
  63. }
  64.  
  65. public OnPlayerRequestClass(playerid, classid)
  66. {
  67.     SetPlayerPos(playerid, 2121.7322, -1623.2563, 26.8368);
  68.     SetPlayerFacingAngle(playerid, 60.2360);
  69.     SetPlayerCameraPos(playerid, 2111.9089 ,-1623.7340, 24.2307);
  70.     SetPlayerCameraLookAt(playerid, 2121.7322, -1623.2563, 26.8368);
  71.     switch(classid)
  72.     {
  73.     case 0,1,2:
  74.     {
  75.         GameTextForPlayer(playerid, "~g~GROVE~w~", 3000, 5);
  76.         gTeam[playerid] = TEAM_GROVE;
  77.     }
  78.     case 3,4,5:
  79.     {
  80.         GameTextForPlayer(playerid, "~b~BALLAS~w~", 3000, 5);
  81.         gTeam[playerid] = TEAM_BALLAS;
  82.     }
  83.     }
  84.     return 1;
  85. }
  86.  
  87.  
  88. SetPlayerToTeamColor(playerid)
  89. {
  90.     if (gTeam[playerid] == TEAM_GROVE)
  91.     {
  92.         SetPlayerColor(playerid, TEAM_GROVE_COLOR);
  93.     }
  94.     else if (gTeam[playerid] == TEAM_BALLAS)
  95.     {
  96.         SetPlayerColor(playerid, TEAM_BALLAS_COLOR);
  97.     }
  98. }
  99.  
  100. forward ini_playerdata(name[], value[]);
  101.  
  102. public ini_playerdata(name[], value[])
  103. {
  104.     INI_Int("money", iniplayermoney);
  105.     INI_Int("score", iniplayerscore);
  106.     return 1;
  107. }
  108.  
  109. public OnPlayerConnect(playerid)
  110. {
  111.     new playername[MAX_PLAYER_NAME+1], filename[16+MAX_PLAYER_NAME];
  112.     rulesnotaccepted = 0;
  113.  
  114.     GetPlayerName(playerid, playername, sizeof(playername));
  115.     format(filename, sizeof(filename), "tdm/players/%s.ini", playername);
  116.  
  117.     if(!fexist(filename))
  118.     {
  119.     ShowPlayerDialog(playerid, DIALOG_RULES, DIALOG_STYLE_MSGBOX, "Welcome!", "Welcome to Grove vs Ballas TDM!\nYou can do pretty much everything you want here, but there are some rules!\n\n1. No cheating/hacking\n2. No spawnkilling/trolling\n3. Behave like a normal human being and use your brains!\n\nDo you accept these rules?", "No", "Yes");
  120.     } else {
  121.  
  122.     INI_ParseFile(filename, "ini_%s");
  123.  
  124.     CarShopCar[playerid] = -1;
  125.     AircraftShopVehicle[playerid] = -1;
  126.     SendDeathMessage(INVALID_PLAYER_ID, playerid, 200);
  127.  
  128.     GivePlayerMoney(playerid, iniplayermoney);
  129.     SetPlayerScore(playerid, iniplayerscore);
  130.     }
  131.     return 1;
  132. }
  133.  
  134. public OnPlayerDisconnect(playerid, reason)
  135. {
  136.     if (rulesnotaccepted==0) {
  137.     new playername[MAX_PLAYER_NAME+1], filename[16+MAX_PLAYER_NAME];
  138.    
  139.     GetPlayerName(playerid, playername, sizeof(playername));
  140.     format(filename, sizeof(filename), "tdm/players/%s.ini", playername);
  141.  
  142.     new INI:iniFile = INI_Open(filename);
  143.  
  144.     INI_SetTag(iniFile, "playerdata");
  145.     INI_WriteInt(iniFile, "money", GetPlayerMoney(playerid));
  146.     INI_WriteInt(iniFile, "score", GetPlayerScore(playerid));
  147.  
  148.     INI_Close(iniFile);
  149.     }
  150.     SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);
  151.     return 1;
  152. }
  153.  
  154. public OnPlayerSpawn(playerid)
  155. {
  156.     SetPlayerToTeamColor(playerid);
  157.    
  158.     Checkpoint[0] = CreateDynamicCP(1772.1460,-1929.1642,13.5534, 2, -1, -1, -1, 100); //Car shop
  159.     SetPlayerMapIcon(playerid, 0, 1772.1460,-1929.1642,13.5534, 55, 0, MAPICON_GLOBAL);
  160.     Checkpoint[1] = CreateDynamicCP(1954.6067,-2188.5210,13.5469, 2, -1, -1, -1, 100); //Jetpack and parachute shop
  161.     SetPlayerMapIcon(playerid, 1, 1954.6067,-2188.5210,13.5469, 5, 0, MAPICON_GLOBAL);
  162.     Checkpoint[2] = CreateDynamicCP(1683.3267,-2638.3318,13.5469, 2, -1, -1, -1, 100); //Aircraft shop
  163.     SetPlayerMapIcon(playerid, 2, 1683.3267,-2638.3318,13.5469, 5, 0, MAPICON_GLOBAL);
  164.     Checkpoint[3] = CreateDynamicCP(2444.6648,-1975.5310,13.5469, 2, -1, -1, -1, 100); //Heavy weapons shop
  165.     SetPlayerMapIcon(playerid, 3, 2444.6648,-1975.5310,13.5469, 18, 0, MAPICON_GLOBAL);
  166. }
  167.  
  168. public OnPlayerDeath(playerid, killerid, reason)
  169. {
  170.     if(killerid == INVALID_PLAYER_ID) {
  171.         SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
  172.         GivePlayerMoney(playerid, -100);
  173.         SetPlayerScore(playerid,GetPlayerScore(playerid)-1);
  174.     } else if(gTeam[killerid] == gTeam[playerid]) {
  175.         SetPlayerScore(killerid,GetPlayerScore(killerid)-2);
  176.         GivePlayerMoney(killerid, -50);
  177.         SendDeathMessage(killerid,playerid,reason);
  178.     } else {
  179.         GivePlayerMoney(playerid, -100);
  180.         SetPlayerScore(playerid,GetPlayerScore(playerid)-1);
  181.         SendDeathMessage(killerid,playerid,reason);
  182.         SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
  183.         GivePlayerMoney(killerid, 100);
  184.     }
  185.     return 1;
  186. }
  187.  
  188. public OnPlayerEnterDynamicCP(playerid, checkpointid)
  189. {
  190.     if(checkpointid == Checkpoint[0]) //Car shop
  191.     {
  192.         if (!IsPlayerInAnyVehicle(playerid)) {
  193.         ShowPlayerDialog(playerid, DIALOG_CARSHOP, DIALOG_STYLE_LIST, "Car shop", "Infernus ($250)\nTurismo ($350)", "Buy", "Cancel");
  194.         } else {
  195.         SendClientMessage(playerid, 0xFF0000AA, "You must be on foot to use this shop!");
  196.         }
  197.     }
  198.     if(checkpointid == Checkpoint[1]) //Jetpack and parachute shop
  199.     {
  200.         if (!IsPlayerInAnyVehicle(playerid)) {
  201.         ShowPlayerDialog(playerid, DIALOG_JETPACKANDPARACHUTESHOP, DIALOG_STYLE_LIST, "Jetpack and parachute shop", "Jetpack ($300)\nParachute ($50)", "Buy", "Cancel");
  202.         } else {
  203.         SendClientMessage(playerid, 0xFF0000AA, "You must be on foot to use this shop!");
  204.         }
  205.     }
  206.     if(checkpointid == Checkpoint[2]) //Aircraft shop
  207.     {
  208.         if (!IsPlayerInAnyVehicle(playerid)) {
  209.         ShowPlayerDialog(playerid, DIALOG_AIRCRAFTSHOP, DIALOG_STYLE_LIST, "Aircraft shop", "Hydra ($500)\nHunter ($600)", "Buy", "Cancel");
  210.         } else {
  211.         SendClientMessage(playerid, 0xFF0000AA, "You must be on foot to use this shop!");
  212.         }
  213.     }
  214.     if(checkpointid == Checkpoint[3]) //Heavy weapons shop
  215.     {
  216.         if (!IsPlayerInAnyVehicle(playerid)) {
  217.         ShowPlayerDialog(playerid, DIALOG_HEAVYWEAPONSSHOP, DIALOG_STYLE_LIST, "Heavy weapons shop", "Minigun ($800)\nRPG ($400)\nFlamethrower ($200)", "Buy", "Cancel");
  218.         } else {
  219.         SendClientMessage(playerid, 0xFF0000AA, "You must be on foot to use this shop!");
  220.         }
  221.     }
  222.     return 1;
  223. }
  224.  
  225. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  226. {
  227.     if(dialogid == DIALOG_CARSHOP)
  228.     {
  229.         if(response)
  230.         {
  231.             if(listitem == 0)
  232.             {
  233.                 new playermoney;
  234.                 playermoney = GetPlayerMoney(playerid);
  235.                 if (playermoney >= 250) {
  236.                 if (CarShopCar[playerid] != -1) {
  237.                 DestroyVehicle(CarShopCar[playerid]);
  238.                 CarShopCar[playerid] = -1;
  239.                 }
  240.                 CarShopCar[playerid] = CreateVehicle(411,1776.6417,-1929.3938,13.1665,0.6010,-1,-1,-1);
  241.                 GivePlayerMoney(playerid, -250);
  242.                 } else {
  243.                 ShowPlayerDialog(playerid, DIALOG_NOTENOUGHMONEY, DIALOG_STYLE_MSGBOX, "Notice", "You don't have enough money to but this item!", "Close", "");
  244.                 }
  245.             }
  246.             if(listitem == 1)
  247.             {
  248.                 new playermoney;
  249.                 playermoney = GetPlayerMoney(playerid);
  250.                 if (playermoney >= 350) {
  251.                 if (CarShopCar[playerid] != -1) {
  252.                 DestroyVehicle(CarShopCar[playerid]);
  253.                 CarShopCar[playerid] = -1;
  254.                 }
  255.                 CarShopCar[playerid] = CreateVehicle(451,1776.6417,-1929.3938,13.1665,0.6010,-1,-1,-1);
  256.                 GivePlayerMoney(playerid, -350);
  257.                 } else {
  258.                 ShowPlayerDialog(playerid, DIALOG_NOTENOUGHMONEY, DIALOG_STYLE_MSGBOX, "Notice", "You don't have enough money to but this item!", "Close", "");
  259.                 }
  260.             }
  261.         }
  262.         return 1;
  263.     }
  264.    
  265.     if(dialogid == DIALOG_JETPACKANDPARACHUTESHOP)
  266.     {
  267.         if(response)
  268.         {
  269.             if(listitem == 0)
  270.             {
  271.                 new playermoney;
  272.                 playermoney = GetPlayerMoney(playerid);
  273.                 if (playermoney >= 300) {
  274.                 SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USEJETPACK);
  275.                 GivePlayerMoney(playerid, -300);
  276.                 } else {
  277.                 ShowPlayerDialog(playerid, DIALOG_NOTENOUGHMONEY, DIALOG_STYLE_MSGBOX, "Notice", "You don't have enough money to but this item!", "Close", "");
  278.                 }
  279.             }
  280.             if(listitem == 1)
  281.             {
  282.                 new playermoney;
  283.                 playermoney = GetPlayerMoney(playerid);
  284.                 if (playermoney >= 50) {
  285.                 GivePlayerWeapon(playerid, 46, 1);
  286.                 GivePlayerMoney(playerid, -50);
  287.                 } else {
  288.                 ShowPlayerDialog(playerid, DIALOG_NOTENOUGHMONEY, DIALOG_STYLE_MSGBOX, "Notice", "You don't have enough money to but this item!", "Close", "");
  289.                 }
  290.             }
  291.         }
  292.         return 1;
  293.     }
  294.        
  295.     if(dialogid == DIALOG_AIRCRAFTSHOP)
  296.     {
  297.         if(response)
  298.         {
  299.             if(listitem == 0)
  300.             {
  301.                 new playermoney;
  302.                 playermoney = GetPlayerMoney(playerid);
  303.                 if (playermoney >= 500) {
  304.                 if (AircraftShopVehicle[playerid] != -1) {
  305.                 DestroyVehicle(AircraftShopVehicle[playerid]);
  306.                 AircraftShopVehicle[playerid] = -1;
  307.                 }
  308.                 AircraftShopVehicle[playerid] = CreateVehicle(520,1681.7134,-2612.5090,14.2579,2.3501,-1,-1,-1);
  309.                 GivePlayerMoney(playerid, -500);
  310.                 } else {
  311.                 ShowPlayerDialog(playerid, DIALOG_NOTENOUGHMONEY, DIALOG_STYLE_MSGBOX, "Notice", "You don't have enough money to but this item!", "Close", "");
  312.                 }
  313.             }
  314.             if(listitem == 1)
  315.             {
  316.                 new playermoney;
  317.                 playermoney = GetPlayerMoney(playerid);
  318.                 if (playermoney >= 600) {
  319.                 if (AircraftShopVehicle[playerid] != -1) {
  320.                 DestroyVehicle(AircraftShopVehicle[playerid]);
  321.                 AircraftShopVehicle[playerid] = -1;
  322.                 }
  323.                 AircraftShopVehicle[playerid] = CreateVehicle(425,1681.7134,-2612.5090,14.2579,2.3501,-1,-1,-1);
  324.                 GivePlayerMoney(playerid, -600);
  325.                 } else {
  326.                 ShowPlayerDialog(playerid, DIALOG_NOTENOUGHMONEY, DIALOG_STYLE_MSGBOX, "Notice", "You don't have enough money to but this item!", "Close", "");
  327.                 }
  328.             }
  329.             return 1;
  330.         }
  331.     }
  332.     if(dialogid == DIALOG_HEAVYWEAPONSSHOP)
  333.     {
  334.         if(response)
  335.         {
  336.             if(listitem == 0)
  337.             {
  338.                 new playermoney;
  339.                 playermoney = GetPlayerMoney(playerid);
  340.                 if (playermoney >= 50) {
  341.                 GivePlayerWeapon(playerid, 38, 150);
  342.                 GivePlayerMoney(playerid, -50);
  343.                 } else {
  344.                 ShowPlayerDialog(playerid, DIALOG_NOTENOUGHMONEY, DIALOG_STYLE_MSGBOX, "Notice", "You don't have enough money to but this item!", "Close", "");
  345.                 }
  346.             }
  347.             if(listitem == 1)
  348.             {
  349.                 new playermoney;
  350.                 playermoney = GetPlayerMoney(playerid);
  351.                 if (playermoney >= 50) {
  352.                 GivePlayerWeapon(playerid, 35, 10);
  353.                 GivePlayerMoney(playerid, -50);
  354.                 } else {
  355.                 ShowPlayerDialog(playerid, DIALOG_NOTENOUGHMONEY, DIALOG_STYLE_MSGBOX, "Notice", "You don't have enough money to but this item!", "Close", "");
  356.                 }
  357.             }
  358.             if(listitem == 2)
  359.             {
  360.                 new playermoney;
  361.                 playermoney = GetPlayerMoney(playerid);
  362.                 if (playermoney >= 50) {
  363.                 GivePlayerWeapon(playerid, 37, 150);
  364.                 GivePlayerMoney(playerid, -50);
  365.                 } else {
  366.                 ShowPlayerDialog(playerid, DIALOG_NOTENOUGHMONEY, DIALOG_STYLE_MSGBOX, "Notice", "You don't have enough money to but this item!", "Close", "");
  367.                 }
  368.             }
  369.         }
  370.         return 1;
  371.     }
  372.    
  373.     if(dialogid == DIALOG_RULES)
  374.     {
  375.         if(response)
  376.         {
  377.             rulesnotaccepted = 1;
  378.             SendClientMessage(playerid, 0xFF0000AA, "You must read and accept the rules to play on Grove vs Ballas!");
  379.             Kick(playerid);
  380.         }
  381.         return 1;
  382.     }
  383.     return 0;
  384. }
  385. public OnVehicleDeath(vehicleid, killerid)
  386. {
  387.     for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
  388.     {
  389.         if (vehicleid == CarShopCar[playerid]) {
  390.         DestroyVehicle(CarShopCar[playerid]);
  391.         CarShopCar[playerid] = -1;
  392.         }
  393.         if (vehicleid == AircraftShopVehicle[playerid]) {
  394.         DestroyVehicle(AircraftShopVehicle[playerid]);
  395.         AircraftShopVehicle[playerid] = -1;
  396.         }
  397.     }
  398.     return 1;
  399. }
  400.  
  401. public OnPlayerCommandText(playerid, cmdtext[])
  402. {
  403.     if (strcmp("/suicide", cmdtext, true, 8) == 0)
  404.     {
  405.         SetPlayerHealth(playerid, 0);
  406.         return 1;
  407.     }
  408.     return 0;
  409. }
Advertisement
Add Comment
Please, Sign In to add comment