Advertisement
Guest User

LVDMod.pwn

a guest
Aug 3rd, 2011
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 14.92 KB | None | 0 0
  1. #include <a_samp>
  2. #include <core>
  3. #include <float>
  4. #include "../include/gl_common.inc"
  5.  
  6. #pragma tabsize 0
  7.  
  8. #define TEAM_GROVE_COLOR 0x33AA33AA
  9. #define TEAM_AZTECA_COLOR 0x00FFFFFF
  10. #define TEAM_VAGOS_COLOR 0xFFFF22FF
  11. #define TEAM_COPS_COLOR 0x0000C4FF
  12. #define COLOR_GREY 0xAFAFAFAA
  13. #define COLOR_GREEN 0x33AA33AA
  14. #define COLOR_RED 0xAA3333AA
  15. #define COLOR_YELLOW 0xFFFF00AA
  16. #define COLOR_WHITE 0xFFFFFFAA
  17. #define PocketMoney 1000 // Amount player recieves on spawn.
  18. #define INACTIVE_PLAYER_ID 255
  19. #define GIVECASH_DELAY 5000 // Time in ms between /givecash commands.
  20.  
  21. #define NUMVALUES 4
  22. #define TEAM_GROVE 1
  23. #define TEAM_AZTECA 2
  24. #define TEAM_VAGOS 3
  25. #define TEAM_COPS 4
  26.  
  27. forward MoneyGrubScoreUpdate();
  28. forward Givecashdelaytimer(playerid);
  29. forward SetPlayerRandomSpawn(playerid);
  30. forward SetupPlayerForClassSelection(playerid);
  31. forward GameModeExitFunc();
  32. forward SendPlayerFormattedText(playerid, const str[], define);
  33. forward public SendAllFormattedText(playerid, const str[], define);
  34.  
  35. //----------------------------------------------------------------------
  36.  
  37. new gTeam[MAX_PLAYERS];
  38. new total_vehicles_from_files=0;
  39. new gActivePlayers[MAX_PLAYERS];
  40. new gLastGaveCash[MAX_PLAYERS];
  41. new CashScoreOld;
  42. new iSpawnSet[MAX_PLAYERS];
  43.  
  44. new Float:gGrovePlayerSpawns[9][4] = {
  45. {1751.1097,-2106.4529,13.5469,183.1979},
  46. {2652.6418,-1989.9175,13.9988,182.7107},
  47. {2689.5203,-1695.9354,10.0517,39.5312},
  48. {1654.7091,-1656.8516,22.5156,177.9729},
  49. {1299.1859,-801.4249,84.1406,269.5274},
  50. {842.5260,-1007.7679,28.4185,213.9953},
  51. {2495.0720,-1687.5278,13.5150,359.6696},
  52. {2807.9282,-1176.8883,25.3805,173.6018},
  53. {1219.0851,-1812.8058,16.5938,190.0045}
  54. };
  55.  
  56. new Float:gAztecaPlayerSpawns[9][4] = {
  57. {-2723.4639,-314.8138,7.1839,43.5562},
  58. {-2694.5344,64.5550,4.3359,95.0190},
  59. {-2796.6589,219.5733,7.1875,88.8288},
  60. {-2764.9543,785.6434,52.7813,357.6817},
  61. {-1674.1964,430.3246,7.1797,226.1357},
  62. {-1983.3458,1117.0645,53.1243,271.2390},
  63. {-1427.0858,-288.9430,14.1484,137.0812},
  64. {-2173.0654,-392.7444,35.3359,237.0159},
  65. {-1867.5022,-141.9203,11.8984,22.4499}
  66. };
  67.  
  68. new Float:gVagosPlayerSpawns[6][4] = {
  69. {2097.6855,2491.3313,14.8390,181.8117},
  70. {1893.1000,2423.2412,11.1782,269.4385},
  71. {1860.9672,1030.2910,10.8203,271.6988},
  72. {1673.2345,1316.1067,10.8203,177.7294},
  73. {2633.3203,2349.7061,10.6719,178.7175},
  74. {1435.8024,2662.3647,11.3926,1.1650}
  75. };
  76.  
  77. new Float:gCopPlayerSpawns[3][4] = {
  78. {1568.2250,-1693.5483,5.8906,177.0983},
  79. {-1604.8442,732.9442,-5.2344,37.6041},
  80. {2343.4553,2455.5994,14.9688,96.5022}
  81. };
  82.  
  83. //------------------------------------------------------------------------------------------------------
  84.  
  85. main()
  86. {
  87.         print("\n----------------------------------");
  88.         print("  Running LVDMod ~MoneyGrub\n");
  89.         print("         Modded By");
  90.         print("            LuCiD");
  91.         print("----------------------------------\n");
  92. }
  93.  
  94. //------------------------------------------------------------------------------------------------------
  95.  
  96. public OnPlayerRequestSpawn(playerid)
  97. {
  98.     //printf("OnPlayerRequestSpawn(%d)",playerid);
  99.     return 1;
  100. }
  101.  
  102. //------------------------------------------------------------------------------------------------------
  103.  
  104. public MoneyGrubScoreUpdate()
  105. {
  106.     new CashScore;
  107.     new name[MAX_PLAYER_NAME];
  108.     //new string[256];
  109.     for(new i=0; i<MAX_PLAYERS; i++)
  110.     {
  111.         if (IsPlayerConnected(i))
  112.         {
  113.             GetPlayerName(i, name, sizeof(name));
  114.             CashScore = GetPlayerMoney(i);
  115.             SetPlayerScore(i, CashScore);
  116.             if (CashScore > CashScoreOld)
  117.             {
  118.                 CashScoreOld = CashScore;
  119.                 //format(string, sizeof(string), "$$$ %s is now in the lead $$$", name);
  120.                 //SendClientMessageToAll(COLOR_YELLOW, string);
  121.             }
  122.         }
  123.     }
  124. }
  125.  
  126. //------------------------------------------------------------------------------------------------------
  127.  
  128. /*public GrubModeReset()
  129. {
  130.     for(new i=0; i<MAX_PLAYERS; i++)
  131.     {
  132.         if (IsPlayerConnected(i))
  133.         {
  134.             SetPlayerScore(i, PocketMoney);
  135.             SetPlayerRandomSpawn(i, classid);
  136.         }
  137.     }
  138.  
  139. }*/
  140.  
  141. //------------------------------------------------------------------------------------------------------
  142.  
  143. public OnPlayerConnect(playerid)
  144. {
  145.     GameTextForPlayer(playerid,"~w~SA-MP: ~r~Las Venturas ~g~MoneyGrub",5000,5);
  146.     SendPlayerFormattedText(playerid, "Welcome to Las Venturas MoneyGrub, For help type /help.", 0);
  147.     gActivePlayers[playerid]++;
  148.     gLastGaveCash[playerid] = GetTickCount();
  149.     return 1;
  150. }
  151.  
  152. //------------------------------------------------------------------------------------------------------
  153. public OnPlayerDisconnect(playerid)
  154. {
  155.     gActivePlayers[playerid]--;
  156. }
  157. //------------------------------------------------------------------------------------------------------
  158.  
  159. public OnPlayerCommandText(playerid, cmdtext[])
  160. {
  161.     new string[256];
  162.     new playermoney;
  163.     new sendername[MAX_PLAYER_NAME];
  164.     new giveplayer[MAX_PLAYER_NAME];
  165.     new cmd[256];
  166.     new giveplayerid, moneys, idx;
  167.  
  168.  cmd = strtok(cmdtext, idx);
  169.  
  170.     if(strcmp(cmd, "/help", true) == 0) {
  171.         SendPlayerFormattedText(playerid,"Las Venturas Deathmatch: Money Grub Coded By Jax and the SA-MP Team.",0);
  172.         SendPlayerFormattedText(playerid,"Type: /objective : to find out what to do in this gamemode.",0);
  173.         SendPlayerFormattedText(playerid,"Type: /givecash [playerid] [money-amount] to send money to other players.",0);
  174.         SendPlayerFormattedText(playerid,"Type: /tips : to see some tips from the creator of the gamemode.", 0);
  175.     return 1;
  176.     }
  177.     if(strcmp(cmd, "/objective", true) == 0) {
  178.         SendPlayerFormattedText(playerid,"This gamemode is faily open, there's no specific win / endgame conditions to meet.",0);
  179.         SendPlayerFormattedText(playerid,"In LVDM:Money Grub, when you kill a player, you will receive whatever money they have.",0);
  180.         SendPlayerFormattedText(playerid,"Consequently, if you have lots of money, and you die, your killer gets your cash.",0);
  181.         SendPlayerFormattedText(playerid,"However, you're not forced to kill players for money, you can always gamble in the", 0);
  182.         SendPlayerFormattedText(playerid,"Casino's.", 0);
  183.     return 1;
  184.     }
  185.     if(strcmp(cmd, "/tips", true) == 0) {
  186.         SendPlayerFormattedText(playerid,"Spawning with just a desert eagle might sound lame, however the idea of this",0);
  187.         SendPlayerFormattedText(playerid,"gamemode is to get some cash, get better guns, then go after whoever has the",0);
  188.         SendPlayerFormattedText(playerid,"most cash. Once you've got the most cash, the idea is to stay alive(with the",0);
  189.         SendPlayerFormattedText(playerid,"cash intact)until the game ends, simple right? But make sure to store money in a Bank.", 0);
  190.     return 1;
  191.     }
  192.     if(strcmp(cmd, "/p", true) == 0) {
  193.     GivePlayerWeapon(playerid, 46, 1);
  194.     return 1;
  195.     }
  196.     if(strcmp(cmd, "/givecash", true) == 0) {
  197.         new tmp[256];
  198.         tmp = strtok(cmdtext, idx);
  199.  
  200.         if(!strlen(tmp)) {
  201.             SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
  202.             return 1;
  203.         }
  204.         giveplayerid = strval(tmp);
  205.  
  206.         tmp = strtok(cmdtext, idx);
  207.         if(!strlen(tmp)) {
  208.             SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
  209.             return 1;
  210.         }
  211.         moneys = strval(tmp);
  212.  
  213.         //printf("givecash_command: %d %d",giveplayerid,moneys);
  214.  
  215.  
  216.         if (IsPlayerConnected(giveplayerid)) {
  217.             GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
  218.             GetPlayerName(playerid, sendername, sizeof(sendername));
  219.             playermoney = GetPlayerMoney(playerid);
  220.             if (moneys > 0 && playermoney >= moneys) {
  221.                 GivePlayerMoney(playerid, (0 - moneys));
  222.                 GivePlayerMoney(giveplayerid, moneys);
  223.                 format(string, sizeof(string), "You have sent %s(player: %d), $%d.", giveplayer,giveplayerid, moneys);
  224.                 SendClientMessage(playerid, COLOR_YELLOW, string);
  225.                 format(string, sizeof(string), "You have recieved $%d from %s(player: %d).", moneys, sendername, playerid);
  226.                 SendClientMessage(giveplayerid, COLOR_YELLOW, string);
  227.                 printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
  228.             }
  229.             else {
  230.                 SendClientMessage(playerid, COLOR_YELLOW, "Invalid transaction amount.");
  231.             }
  232.         }
  233.         else {
  234.                 format(string, sizeof(string), "%d is not an active player.", giveplayerid);
  235.                 SendClientMessage(playerid, COLOR_YELLOW, string);
  236.             }
  237.         return 1;
  238.     }
  239.  
  240.     // PROCESS OTHER COMMANDS
  241.  
  242.  
  243.     return 0;
  244. }
  245.  
  246.  
  247. //------------------------------------------------------------------------------------------------------
  248.  
  249. public OnPlayerSpawn(playerid)
  250. {
  251.     GivePlayerMoney(playerid, PocketMoney);
  252.     SetPlayerInterior(playerid,0);
  253.     SetPlayerRandomSpawn(playerid);
  254.     TogglePlayerClock(playerid,1);
  255.     return 1;
  256. }
  257. forward SetPlayerToTeamColor(playerid);
  258. public SetPlayerToTeamColor(playerid)
  259. {
  260. if (gTeam[playerid] == TEAM_GROVE) //|| GetPlayerTeam(playerid) == 1)
  261. {
  262. SetPlayerColor(playerid, TEAM_GROVE_COLOR);
  263. SetPlayerInterior(playerid,0);
  264. }
  265. else if (gTeam[playerid] == TEAM_AZTECA)
  266. {
  267. SetPlayerColor(playerid, TEAM_AZTECA_COLOR);
  268. SetPlayerInterior(playerid,0);
  269. }
  270. else if (gTeam[playerid] == TEAM_VAGOS)
  271. {
  272. SetPlayerColor(playerid, TEAM_VAGOS_COLOR);
  273. SetPlayerInterior(playerid,0);
  274. }
  275. else if (gTeam[playerid] == TEAM_COPS)
  276. {
  277. SetPlayerColor(playerid, TEAM_COPS_COLOR);
  278. SetPlayerInterior(playerid,0);
  279. }
  280. }
  281.  
  282. //------------------------------------------------------------------------------
  283.  
  284. public SetPlayerRandomSpawn(playerid)
  285. {
  286.     if (iSpawnSet[playerid] == 1)
  287.     {
  288.         new rand = random(sizeof(gGrovePlayerSpawns));
  289.         SetPlayerPos(playerid, gGrovePlayerSpawns[rand][0], gGrovePlayerSpawns[rand][1], gGrovePlayerSpawns[rand][2]); // Warp the player
  290.         SetPlayerFacingAngle(playerid, 270.0);
  291.     }
  292.     else if (iSpawnSet[playerid] == 0)
  293.     {
  294.         new rand = random(sizeof(gAztecaPlayerSpawns));
  295.         SetPlayerPos(playerid, gAztecaPlayerSpawns[rand][0], gAztecaSpawns[rand][1], gAztecePlayerSpawns[rand][2]); // Warp the player
  296.         SetPlayerFacingAngle(playerid, 270.0);
  297.     }
  298.     else if (iSpawnSet[playerid] == 2)
  299.     {
  300.         new rand = random(sizeof(gVagoPlayerSpawns));
  301.         SetPlayerPos(playerid, gVagoPlayerSpawns[rand][0], gVagoPlayerSpawns[rand][1], gVagoPlayerSpawns[rand][2]);
  302.         SetPlayerFacingAngle(playerid, 270.0);
  303.     }
  304.     else if (iSpawnSet[playerid] == 3)
  305.     {
  306.         new rand = random(sizeof(gCopsPlayerSpawns));
  307.         SetPlayerPos(playerid, gCopsPlayerSpawns[rand][0], gCopsPlayerSpawns[rand][1], gCopsPlayerSpawns[rand][2]);
  308.     }
  309.     return 1;
  310. }
  311.  
  312. //------------------------------------------------------------------------------------------------------
  313.  
  314. public OnPlayerDeath(playerid, killerid, reason)
  315. {
  316.     new playercash;
  317.     if(killerid == INVALID_PLAYER_ID) {
  318.         SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
  319.         ResetPlayerMoney(playerid);
  320.     } else {
  321.             SendDeathMessage(killerid,playerid,reason);
  322.             SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
  323.             playercash = GetPlayerMoney(playerid);
  324.             if (playercash > 0)  {
  325.                 GivePlayerMoney(killerid, playercash);
  326.                 ResetPlayerMoney(playerid);
  327.             }
  328.             else
  329.             {
  330.             }
  331.         }
  332.     return 1;
  333. }
  334.  
  335. //------------------------------------------------------------------------------------------------------
  336.  
  337. public OnPlayerRequestClass(playerid, classid)
  338. {
  339.     iSpawnSet[playerid] = 0;
  340.     SetupPlayerForClassSelection(playerid);
  341.     return 1;
  342. }
  343.  
  344. public SetupPlayerForClassSelection(playerid)
  345. {
  346.     SetPlayerInterior(playerid,14);
  347.     SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
  348.     SetPlayerFacingAngle(playerid, 270.0);
  349.     SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
  350.     SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
  351. }
  352.  
  353. public GameModeExitFunc()
  354. {
  355.     GameModeExit();
  356. }
  357.  
  358. public OnGameModeInit()
  359. {
  360.     SetGameModeText("LVDMod ~LuCiD~");
  361.     ShowPlayerMarkers(1);
  362.     ShowNameTags(1);
  363.     EnableStuntBonusForAll(0);
  364.     DisableInteriorEnterExits();
  365.  
  366.     // Player Class's
  367.     AddPlayerClass(266,1958.3783,1343.1572,15.3746,270.1425,0,0,24,300,-1,-1);
  368.     AddPlayerClass(267,1958.3783,1343.1572,15.3746,270.1425,0,0,24,300,-1,-1);
  369.    
  370.     AddPlayerClass(280,1958.3783,1343.1572,15.3746,270.1425,0,0,24,300,-1,-1);
  371.     AddPlayerClass(281,1958.3783,1343.1572,15.3746,270.1425,0,0,24,300,-1,-1);
  372.     AddPlayerClass(282,1958.3783,1343.1572,15.3746,270.1425,0,0,24,300,-1,-1);
  373.     AddPlayerClass(283,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
  374.     AddPlayerClass(284,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
  375.     AddPlayerClass(285,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
  376.     AddPlayerClass(286,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
  377.     AddPlayerClass(287,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
  378.    
  379.     AddPlayerClass(1,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
  380.  
  381.     AddPlayerClass(105,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
  382.     AddPlayerClass(106,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
  383.     AddPlayerClass(107,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
  384.     AddPlayerClass(108,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
  385.     AddPlayerClass(109,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
  386.     AddPlayerClass(110,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
  387.     AddPlayerClass(114,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
  388.     AddPlayerClass(115,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
  389.     AddPlayerClass(116,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
  390.    
  391.  
  392.     // Car Spawns
  393.  
  394.     // SPECIAL
  395.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/trains.txt");
  396.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/pilots.txt");
  397.  
  398.     // LAS VENTURAS
  399.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_law.txt");
  400.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_airport.txt");
  401.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_gen.txt");
  402.  
  403.     // SAN FIERRO
  404.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_law.txt");
  405.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_airport.txt");
  406.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_gen.txt");
  407.  
  408.     // LOS SANTOS
  409.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_law.txt");
  410.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_airport.txt");
  411.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_gen_inner.txt");
  412.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_gen_outer.txt");
  413.  
  414.     // OTHER AREAS
  415.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/whetstone.txt");
  416.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/bone.txt");
  417.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/flint.txt");
  418.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/tierra.txt");
  419.     total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/red_county.txt");
  420.  
  421.     printf("Total vehicles from files: %d",total_vehicles_from_files);
  422.  
  423.     return 1;
  424. }
  425.  
  426.  
  427.  
  428. public SendPlayerFormattedText(playerid, const str[], define)
  429. {
  430.     new tmpbuf[256];
  431.     format(tmpbuf, sizeof(tmpbuf), str, define);
  432.     SendClientMessage(playerid, 0xFF004040, tmpbuf);
  433. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement