Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_concmd("gamble", "CmdGamble", _, "usage: gamble <cash>")
register_clcmd("say /gamble", "CmdGamble")
register_clcmd("say /gambleall", "CmdGambleAll")
register_clcmd("say /allin", "CmdGambleAll")
}
public CmdGamble(id) {
new cash = cs_get_user_money(id)
new szName[32]; get_user_name(id, szName, charsmax(szName))
if(cash < 300) {
console_print(id, "|AMXX| You need at least 300$ to gamble.")
client_print(id, print_chat, "|AMXX| You need at least 300$ to gamble.")
return PLUGIN_HANDLED
}
else {
new argv[35], gamblecash
read_argv(1, argv, charsmax(argv))
if(!argv[0]) {
client_print(id, print_chat, "|AMXX| /gamble <ammount>")
return PLUGIN_HANDLED
}
else {
gamblecash = str_to_num(argv)
if(gamblecash < 300) {
console_print(id, "|AMXX| You need to gamble at least 300$")
client_print(id, print_chat, "|AMXX| You need to gamble at least 300$.")
return PLUGIN_HANDLED
}
if(cash < gamblecash) {
console_print(id, "|AMXX| You only have %i$", cash)
client_print(id, print_chat, "|AMXX| You only have %i$", cash)
return PLUGIN_HANDLED
}
new dice = random_num(1, 100)
new woncash = gamblecash * 2
if(dice > 52) {
cs_set_user_money(id, cash += gamblecash)
console_print(id, "|AMXX| Congratulations, you won a total of %i$", gamblecash)
console_print(id, "|AMXX| You now have a total of %i$", cash)
client_print(0, print_chat, "|AMXX| %s gambled %i$ and WON a total of %i$.", szName, gamblecash, woncash)
return PLUGIN_HANDLED
}
else if(dice < 48) {
cs_set_user_money(id, cash -= gamblecash)
console_print(id, "|AMXX| Oh no... You lost %i cash", gamblecash)
console_print(id, "|AMXX| You now have a total of %i", cash)
client_print(0, print_chat, "|AMXX| %s gambled %i$ and LOST it.", szName, gamblecash)
return PLUGIN_HANDLED
}
}
}
return PLUGIN_HANDLED
}
public CmdGambleAll(id) {
new cash = cs_get_user_money(id)
if(cash < 300) {
console_print(id, "[GAMBLE] You need at least 300 cash to gamble.")
return PLUGIN_HANDLED
}
else {
new dice = random_num(1, 100)
if(dice > 52) {
cs_set_user_money(id, cash += cash)
client_print(id, print_chat, "[GAMBLE] Congratulations, you doubled your money")
}
else if(dice < 48) {
cs_set_user_money(id, cash -= cash)
client_print(id, print_chat, "[GAMBLE] Oh no... You lost all your cash.")
}
}
return PLUGIN_HANDLED
}