Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. #pragma semicolon 1
  2. #include <sourcemod>
  3. #include <sdktools>
  4. #include <store>
  5. #include <zephstocks>
  6.  
  7. new Handle:countdownTimer = INVALID_HANDLE;
  8. new d_credits;
  9. new countdownTimeLeft;
  10.  
  11. public Plugin:myinfo =
  12. {
  13. name = "Raffle re-make",
  14. author = "Grandpa",
  15. description = "Gives credits to random client.",
  16. version = "1.0",
  17. url = "redtube.com"
  18. }
  19.  
  20. public OnPluginStart()
  21. {
  22. RegAdminCmd("sm_test", Countdown, ADMFLAG_CHAT, "Generates a random number for a raffle.");
  23. }
  24.  
  25. public OnMapStart()
  26. {
  27. PrecacheModel("materials/raffle_overlay.vtf");
  28. AddFileToDownloadsTable("materials/raffle_overlay.vmt");
  29. AddFileToDownloadsTable("materials/raffle_overlay.vtf");
  30. }
  31.  
  32. public Action:Countdown(client)
  33. {
  34. countdownTimer = CreateTimer(1.0, Timer_Countdown1, INVALID_HANDLE, TIMER_REPEAT);
  35. countdownTimeLeft = 10;
  36. d_credits = GetRandomInt(200, 1000);
  37. ShowOverlay("");
  38. return Plugin_Handled;
  39.  
  40. }
  41.  
  42. ShowOverlay(client)
  43. {
  44. for (new x = 1; x <= MaxClients; x++)
  45. {
  46. if (IsClientInGame(x) && !IsFakeClient(x))
  47. {
  48. ClientCommand(x, "r_screenoverlay \"materials\raffle_overlay.vtf"");
  49. }
  50. }
  51. }
  52.  
  53.  
  54. public Action:Timer_Countdown1(Handle:timer)
  55. {
  56. if(countdownTimeLeft <= -1)
  57. {
  58. new target = -1;
  59. new targets[MAXPLAYERS] = {0,...};
  60. new itargets = 0;
  61. for(new i=1;i<MaxClients;++i)
  62. {
  63. if(IsClientInGame(i))
  64. {
  65. targets[itargets++]=i;
  66. }
  67. }
  68.  
  69. new winner = targets[GetRandomInt(0,itargets-1)];
  70.  
  71. PrintCenterTextAll("%N won the raffle!", winner);
  72. PrintToChatAll("\x04%N \x01won \x03%d \x01credits on the \x06Raffle!", winner, d_credits);
  73. Store_SetClientCredits(winner, Store_GetClientCredits(winner)+d_credits);
  74. return Plugin_Stop;
  75. } else {
  76.  
  77. PrintCenterTextAll("A Raffle for %d credits, is starting in: %i seconds.", d_credits, countdownTimeLeft);
  78. countdownTimeLeft--;
  79. return Plugin_Continue;
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement