Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- #include <sourcemod>
- #include <sdktools>
- #include <store>
- #include <zephstocks>
- new Handle:countdownTimer = INVALID_HANDLE;
- new d_credits;
- new countdownTimeLeft;
- public Plugin:myinfo =
- {
- name = "Raffle re-make",
- author = "Grandpa",
- description = "Gives credits to random client.",
- version = "1.0",
- url = "redtube.com"
- }
- public OnPluginStart()
- {
- RegAdminCmd("sm_test", Countdown, ADMFLAG_CHAT, "Generates a random number for a raffle.");
- }
- public OnMapStart()
- {
- PrecacheModel("materials/raffle_overlay.vtf");
- AddFileToDownloadsTable("materials/raffle_overlay.vmt");
- AddFileToDownloadsTable("materials/raffle_overlay.vtf");
- }
- public Action:Countdown(client)
- {
- countdownTimer = CreateTimer(1.0, Timer_Countdown1, INVALID_HANDLE, TIMER_REPEAT);
- countdownTimeLeft = 10;
- d_credits = GetRandomInt(200, 1000);
- ShowOverlay("");
- return Plugin_Handled;
- }
- ShowOverlay(client)
- {
- for (new x = 1; x <= MaxClients; x++)
- {
- if (IsClientInGame(x) && !IsFakeClient(x))
- {
- ClientCommand(x, "r_screenoverlay \"materials\raffle_overlay.vtf"");
- }
- }
- }
- public Action:Timer_Countdown1(Handle:timer)
- {
- if(countdownTimeLeft <= -1)
- {
- new target = -1;
- new targets[MAXPLAYERS] = {0,...};
- new itargets = 0;
- for(new i=1;i<MaxClients;++i)
- {
- if(IsClientInGame(i))
- {
- targets[itargets++]=i;
- }
- }
- new winner = targets[GetRandomInt(0,itargets-1)];
- PrintCenterTextAll("%N won the raffle!", winner);
- PrintToChatAll("\x04%N \x01won \x03%d \x01credits on the \x06Raffle!", winner, d_credits);
- Store_SetClientCredits(winner, Store_GetClientCredits(winner)+d_credits);
- return Plugin_Stop;
- } else {
- PrintCenterTextAll("A Raffle for %d credits, is starting in: %i seconds.", d_credits, countdownTimeLeft);
- countdownTimeLeft--;
- return Plugin_Continue;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement