|
Senior Member
Join Date: Jun 2009
Location: California , United Stat
|

08-08-2013
, 19:54
Re: Rock Paper Scissors v1.0 BETA by Rejack
|
#14
|
Code:
#include <amxmodx>
#include <cstrike>
new gReqMoney
new gReward
public plugin_init()
{
register_plugin("Rock, Paper, Scissors", "1.0", "hib")
register_clcmd( "say /rps", "RockPaperScissorsMenu" )
register_clcmd( "say_team /rps", "RockPaperScissorsMenu" )
gReqMoney = register_cvar("amx_rps_reqmoney", "300")
gReward = register_cvar("amx_rps_reward", "600")
}
public RockPaperScissorsMenu(id)
{
new onhandmoney = cs_get_user_money(id)
if ( onhandmoney < get_pcvar_num(gReqMoney) )
return PLUGIN_CONTINUE
cs_set_user_money(id, onhandmoney - get_pcvar_num(gReward))
new menu = menu_create("\rChoose an option:", "RockPaperScissors_Select")
menu_additem(menu,"Rock", "1", 0)
menu_additem(menu,"Paper", "2", 0)
menu_additem(menu,"Scissors", "3", 0)
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menu, 0)
return PLUGIN_HANDLED
}
public RockPaperScissors_Select(id, menu, item)
{
new onhandmoney = cs_get_user_money(id)
// While they select, lets also give the computer a random number
new computerPlay = random(3) // Random Generated number
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[6], iName[64]
new acces, callback
menu_item_getinfo(menu, item, acces, data,5, iName, 63, callback)
new key = str_to_num(data)
switch(key)
{
case 1: // ROCK
{
new personPlay = 1;
if (personPlay == computerPlay)
{
client_print(id, print_chat, "computerPlay = %d", computerPlay)
client_print(id, print_chat, "It's a tie!")
}
else if (computerPlay == 3)
{
client_print(id, print_chat, "computerPlay = %d", computerPlay)
client_print(id, print_chat, "Rock crushes scissors.");
client_print(id, print_chat, "You've won $%d", get_pcvar_num(gReward))
cs_set_user_money(id, onhandmoney + get_pcvar_num(gReward))
}
else if (computerPlay == 2)
{
client_print(id, print_chat, "computerPlay = %d", computerPlay)
client_print(id, print_chat, "Paper catches rock. You Lose!!");
}
}
case 2: // PAPER
{
new personPlay = 2;
if (personPlay == computerPlay)
{
client_print(id, print_chat, "computerPlay = %d", computerPlay)
client_print(id, print_chat, "It's a tie!")
}
else if (computerPlay == 1)
{
client_print(id, print_chat, "computerPlay = %d", computerPlay)
client_print(id, print_chat, "Paper catches rock.");
client_print(id, print_chat, "You've won $%d", get_pcvar_num(gReward))
cs_set_user_money(id, onhandmoney + get_pcvar_num(gReward))
}
else if (computerPlay == 3)
{
client_print(id, print_chat, "computerPlay = %d", computerPlay)
client_print(id, print_chat, "Scissors cuts paper. You Lose!!");
}
}
case 3: // SCISSORS
{
new personPlay = 3;
if (personPlay == computerPlay)
{
client_print(id, print_chat, "computerPlay = %d", computerPlay)
client_print(id, print_chat, "It's a tie!")
}
else if (computerPlay == 2)
{
client_print(id, print_chat, "computerPlay = %d", computerPlay)
client_print(id, print_chat, "Scissors cuts paper.");
client_print(id, print_chat, "You've won $%d", get_pcvar_num(gReward))
cs_set_user_money(id, onhandmoney + get_pcvar_num(gReward))
}
else if (computerPlay == 3)
{
client_print(id, print_chat, "computerPlay = %d", computerPlay)
client_print(id, print_chat, "Rock crushes scissors. You Lose!!");
}
}
}
menu_destroy(menu)
return PLUGIN_HANDLED
}
Here is a menu version of RPS.
- Play versus the computer
- Has Required Money Check to play as well as Bonus after you win.
__________________
- Steam: Lobopack23 - Link
Contact me if you need any help with Pokemod.
- 2nd Generation Pokemod - Link
( new skills, items, and pokemons)
- Buy Xp - Link
Last edited by lobopack23; 08-08-2013 at 19:55.
|
|