Code:
#include <sourcemod>
#include <sdktools>
new target1[MAXPLAYERS+1];
new xxxxx[MAXPLAYERS+1];
new String:money[MAXPLAYERS+1][64];
new money1[MAXPLAYERS+1];
public Plugin:myinfo =
{
name = "TF2 Money give",
author = "Tom1314",
description = "Player can send money via menu",
version = "",
url = "www.POHEART.COM"
}
public OnPluginStart()
{
RegConsoleCmd("sm_gmm", CmdGiveMoneyMenu);
RegConsoleCmd("sm_gm", CmdGiveMoney);
}
public Action:CmdGiveMoney(client, args)
{
//Player:
new Player;
//Default:
if(args < 2) return;
//Player:
else
{
//Retrieve Arguments:
decl MaxClients;
decl String:ArgumentName[32], String:PlayerName[32];
//Initialize:
MaxClients = GetMaxClients();
GetCmdArg(1, ArgumentName, sizeof(ArgumentName));
//Find:
for(new X = 1; X <= MaxClients; X++)
{
//Invalid:
if(!IsClientConnected(X)) continue;
//Initialize:
GetClientName(X, PlayerName, sizeof(PlayerName));
//Compare:
if(StrContains(PlayerName, ArgumentName, false) != -1) Player = X;
}
}
if(!IsClientConnected(Player)) return;
new String:aaa[32];
GetCmdArg(2, aaa, sizeof(aaa));
new b = StringToInt(aaa);
xxxxx[Player] =xxxxx[Player] + b;
return;
}
public Action:CmdGiveMoneyMenu(client, args)
{
GiveMMenu(client);
}
public GiveMMenu(client)
{
decl String:name[256], String:number[32];
// Take client number and put it into g_Selector
// Create the menu
new Handle:menu = CreateMenu(GiveMMenu1);
SetMenuTitle(menu, "Send Money to Player:");
for (new i=1; i<=MaxClients; i++)
{
if (!IsClientInGame(i)) continue; //not ingame? skip
Format(name, sizeof(name), "%N", i);
Format(number, sizeof(number), "%i", i);
AddMenuItem(menu, number, name);
}
SetMenuExitButton(menu, true);
DisplayMenu(menu, client, 60);
return Plugin_Handled;
}
public GiveMMenu1(Handle:menu, MenuAction:action, param1, param2)
{
// if a player was selected
if (action == MenuAction_Select)
{
decl String:item[256], String:display[256];
GetMenuItem(menu, param2, item, sizeof(item), _, display, sizeof(display));
new target = StringToInt(item);
if (target == 0)
{
target = 1;
}
target1[param1]=target;
GiveMMenu2(param1);
}
else if (action == MenuAction_Cancel)
{
}
else if (action == MenuAction_End)
{
CloseHandle(menu);
}
}
public GiveMMenu2(client)
{
new Handle:menu = CreateMenu(GiveMMenu3);
SetMenuTitle(menu, "Please Select Amount");
AddMenuItem(menu, "500", "$500[Min]");
AddMenuItem(menu, "1000", "$1000");
AddMenuItem(menu, "1500", "$1500");
AddMenuItem(menu, "2000", "$2000");
AddMenuItem(menu, "1500", "$2500");
AddMenuItem(menu, "2000", "$3000");
AddMenuItem(menu, "2000", "$5000");
SetMenuExitButton(menu, true);
DisplayMenu(menu, client, 60);
}
public GiveMMenu3(Handle:menu, MenuAction:action, param1, param2)
{
// if a player was selected
if (action == MenuAction_Select)
{
decl String:item[256], String:display[256];
GetMenuItem(menu, param2, item, sizeof(item), _, display, sizeof(display));
new target = StringToInt(item);
Format(money[param1], 64, display);
money1[param1]=target;
GiveMMenu4(param1);
}
else if (action == MenuAction_Cancel)
{
}
else if (action == MenuAction_End)
{
CloseHandle(menu);
}
}
public GiveMMenu4(client)
{
new Handle:menu = CreateMenu(GiveMMenu5);
decl String:name[64];
GetClientName( target1[client], name, 64);
SetMenuTitle(menu, "Are you sure you gonna give money to %s?\nThis action cannot be undone once confirmed.", name);
AddMenuItem(menu, money1[client], money[client]);
AddMenuItem(menu, "-1", "No");
SetMenuExitButton(menu, true);
DisplayMenu(menu, client, 60);
}
public GiveMMenu5(Handle:menu, MenuAction:action, param1, param2)
{
// if a player was selected
if (action == MenuAction_Select)
{
decl String:item[256], String:display[256];
GetMenuItem(menu, param2, item, sizeof(item), _, display, sizeof(display));
new x = StringToInt(item);
if (x !=-1)
{
decl String:name[64];
GetClientName( target1[param1], name, 64); // get client username
FakeClientCommand(param1, "sm_gm \"%d\" \"%s\"",x,name);
}
}
else if (action == MenuAction_Cancel)
{
}
else if (action == MenuAction_End)
{
CloseHandle(menu);
}
}