PDA

View Full Version : [REQ] Roll the dice (very simple plugin)


dust2
07-01-2016, 00:46
Hello, I would be interested in having this kind of plugin that would let players on the cs:go server roll dices as many times as they want. This plugin would randomize the number between 1 and 100.

The dice command would be just !dice (sm_dice).
But there could be 60 second delay after player could roll the dice again.

And color support would be appreciated, like:

{purple}Player {green}has rolled number: {red}34 <--- print that to chat for everyone to see it

I would be also be interested in paying for this if needed :)
send me a pm or post a reply

josh

nosoop
07-01-2016, 06:02
CS:GO doesn't support all colors (https://forums.alliedmods.net/showpost.php?p=1909706&postcount=2) as far as I know, so that's ruled out.


#include <sourcemod>

float g_flNextAllowedRollTime[MAXPLAYERS+1];
float g_flCooldownTime = 60.0;

public void OnPluginStart() {
RegConsoleCmd("sm_dice", Command_Dice);
}

public void OnClientPutInServer(int client) {
g_flNextAllowedRollTime[client] = 0.0;
}

public Action Command_Dice(int client, int argc) {
if (GetGameTime() > g_flNextAllowedRollTime[client]) {
PrintToChatAll("%N has rolled number: %d", client, GetRandomInt(1, 100));
g_flNextAllowedRollTime[client] = GetGameTime() + g_flCooldownTime;
} else {
PrintToChat(client, "You rolled the dice recently.");
}
return Plugin_Handled;
}

Maxximou5
07-01-2016, 06:36
CS:GO doesn't support all colors (https://forums.alliedmods.net/showpost.php?p=1909706&postcount=2) as far as I know, so that's ruled out.

CS:GO may not use all the colors, but it certainly supports more colors than that post indicates.
You would use an include like this: https://git.tf/Bara/DanceDanceRevolution/blob/9abf902f721fced79ba97072179e632fcf147cca/addons/sourcemod/scripting/include/multicolors/colors.inc
Or this: https://github.com/KissLick/Timer/blob/master/addons/sourcemod/scripting/include/colors.inc

dust2
07-04-2016, 01:24
How I can add the color support to this plugin? I'm new to these kind of things.. I compiled the plugin and it works.