Advertisement
Guest User

Random Hit/Mission System

a guest
Apr 8th, 2017
576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. #define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <zcmd>
  7.  
  8. #define COLOR_LIGHTBLUE 0x33CCFFAA
  9.  
  10. #define MISSIONTIME (2) //2 minutes
  11.  
  12. #define BOUNTYMONEY 500000
  13.  
  14. new connectedids[MAX_PLAYERS], onlineplayers, playername[MAX_PLAYER_NAME+5], hiton = -1, recenthit = 0, bounty, bonus;
  15.  
  16. forward NewHit();
  17. forward HitKilled(playerid);
  18.  
  19. public OnFilterScriptInit()
  20. {
  21. return 1;
  22. }
  23.  
  24. public OnFilterScriptExit()
  25. {
  26. return 1;
  27. }
  28.  
  29. public OnGameModeInit()
  30. {
  31. // Don't use these lines if it's a filterscript
  32. SetGameModeText("Blank Script");
  33. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  34. return 1;
  35. }
  36.  
  37. public OnGameModeExit()
  38. {
  39. return 1;
  40. }
  41.  
  42. public OnPlayerRequestClass(playerid, classid)
  43. {
  44. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  45. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  46. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  47. return 1;
  48. }
  49.  
  50. public OnPlayerDeath(playerid, killerid, reason)
  51. {
  52. if(hiton == killerid)
  53. {
  54. new pName[ MAX_PLAYER_NAME ], vName[ MAX_PLAYER_NAME ], string[ 128 ];
  55. GetPlayerName(killerid,pName,sizeof pName);
  56. GetPlayerName(playerid,vName,sizeof vName);
  57. GivePlayerMoney(playerid, bounty + bonus);
  58. format(string,sizeof string,"[HIT] {FFFFFF}%s has killed the victim %s and won (%d{6EF83C}${FFFFFF}) with a bonus of (%d{6EF83C}${FFFFFF})",pName, vName, bounty, bonus);
  59. SendClientMessageToAll(0x48977996,string);
  60. hiton = -1;
  61. recenthit = 0;
  62. }
  63. return 1;
  64. }
  65.  
  66. CMD:startnewhit(playerid, params[])
  67. {
  68. if(IsPlayerAdmin(playerid))
  69. {
  70. if(recenthit >= 1)
  71. {
  72. SendClientMessageToAll(COLOR_LIGHTBLUE, "An Administrator has just started a random hit picked by the server. Details will be given in 2 minutes");
  73. SetTimer("NewHit",(1000*60*MISSIONTIME),1);
  74. recenthit = 0;
  75. }
  76. }
  77. return 1;
  78. }
  79.  
  80. public NewHit()
  81. {
  82. new string[180];
  83. new playersid;
  84. bounty = random(BOUNTYMONEY);
  85. for(new i=0; i<MAX_PLAYERS; i++)
  86. {
  87. if(IsPlayerConnected(i))
  88. {
  89. connectedids[onlineplayers] = i;
  90. onlineplayers++;
  91. }
  92. }
  93. GetPlayerName(connectedids[random(onlineplayers)], playername, sizeof(playername));
  94. playersid = GetPlayerIdFromName(playername);
  95.  
  96. bonus = GetPlayerScore(playersid) + random(10000);
  97.  
  98. SendClientMessageToAll(COLOR_LIGHTBLUE, "|_______________Hit Details_______________|");
  99. format(string, sizeof(string), "Victim: %s", playername);
  100. format(string, sizeof(string), "Bounty: $%i", bounty);
  101. format(string, sizeof(string), "Bonus: $%i", bonus);
  102. SendClientMessageToAll(COLOR_LIGHTBLUE, string);
  103.  
  104. hiton = playersid;
  105. return 1;
  106. }
  107.  
  108. stock GetPlayerIdFromName(pname[])
  109. {
  110. for(new i = 0; i <= MAX_PLAYERS; i++)
  111. {
  112. if(IsPlayerConnected(i))
  113. {
  114. new playername2[MAX_PLAYER_NAME];
  115. GetPlayerName(i, playername2, sizeof(playername2));
  116. if(strcmp(playername2, pname, true, strlen(pname)) == 0)
  117. {
  118. return i;
  119. }
  120. }
  121. }
  122. return INVALID_PLAYER_ID;
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement