Yet again, another FF2 development thread. This time i'm working on a plugin similar to the ff2_boss plugin.
My goal is to build a menu so that certain steam ID's can choose certain blocked bosses. I have the STEAMID menu working with all the choices set. With the current options I can execute my script as I like, though, that leads me to why I'm asking this here.
I would like to know how to actually set a boss over FF2 to be client-sided similar to the link above I made. I don't want to use ff2_special because that will set just the next boss, not if YOU are the next boss only.
If it helps explain my cause, I would like to stuff this function under a menu choice, like:
PHP Code:
if (StrEqual(item, "first_choice_function_name"))
{
//Code I don't know here
ReplyToCommand(param1, "[Specials] Set your boss to Blah Blah");
}
else if (StrEqual(item, "another_choices_function_name"))
{
//Code I don't know again
ReplyToCommand(param1, "[Specials] Set your boss to Another Blah Blah");
}
etc, etc.
I believe that it has something to do with this function:
PHP Code:
Incoming[0] = i;
and
PHP Code:
Incoming[param1] = param2
PHP Code:
Incoming[client] = -1;
So I believe it has to do with the Incoming function, though I may be wrong.
Here are the codes for both of the plugins set-boss functions.
Freak Fortress 2 Default (Determined by next queued boss)
Spoiler
public Action:Command_MakeNextSpecial(client, args)
{
decl String:arg[32];
decl String:Special_Name[64];
if (args < 1)
{
ReplyToCommand(client, "[USE] Usage: ff2_amatoboss < boss > ");
return Plugin_Handled;
}
GetCmdArgString(arg, sizeof(arg));
decl i;
for (i = 0; i < Specials; i++)
{
KvRewind(BossKV[i]);
KvGetString(BossKV[i], "name",Special_Name, 64);
if (StrContains(Special_Name,arg,false) >= 0)
{
Incoming[0] = i;
ReplyToCommand(client, "[USE] Set the next Special to %s", Special_Name);
return Plugin_Handled;
}
KvGetString(BossKV[i], "filename",Special_Name, 64);
if (StrContains(Special_Name,arg,false) >= 0)
{
Incoming[0] = i;
KvGetString(BossKV[i], "name",Special_Name, 64);
ReplyToCommand(client, "[USE] Set the next Special to %s", Special_Name);
return Plugin_Handled;
}
}
ReplyToCommand(client, "[USE] Boss not be found.");
return Plugin_Handled;
}
ff2_boss (Is client dependant like I want, but uses an autogenerated menu, I would like to build mine)
new Incoming[MAXPLAYERS+1];
new Handle:cvarAdminOnly;
new bool:bAdminOnly;
public Plugin:myinfo = {
name = "Freak Fortress 2: Boss Selection",
description = "Allows players select their bosses by /ff2boss",
author = "RainBolt Dash",
};
public OnPluginStart()
{
cvarAdminOnly = CreateConVar("ff2_boss_foradmins", "0", "Only admins with Generic flag can use it", FCVAR_PLUGIN);
HookEvent("teamplay_round_start", event_round_start);
RegConsoleCmd("ff2_boss", Command_SetMyBoss);
RegConsoleCmd("ff2boss", Command_SetMyBoss);
LoadTranslations("ff2_boss_selection");
OnMapStart();
}
public OnMapStart()
{
for (new i = 0; i <= MaxClients; i++)
Incoming[i] = -1;
}
public Action:event_round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
if ((bAdminOnly=GetConVarBool(cvarAdminOnly)))
CreateTimer(2.0,Timer_FF2Panel1);
return Plugin_Continue;
}
public OnClientPutInServer(client)
{
Incoming[client] = -1;
}
public Action:Timer_FF2Panel1(Handle:hTimer)
{
new maxclient=1;
new maxpoints=FF2_GetQueuePoints(1);
decl points;
for(new client=2; client <= MaxClients; client++)
if (FF2_GetBossIndex(client)==-1)
{
points = FF2_GetQueuePoints(client);
if (points>maxpoints)
{
maxclient=client;
maxpoints=points;
}
}
CreateTimer(20.0,Timer_FF2Panel2,GetClientUse rId(maxclient));
return Plugin_Continue;
}
public Action:Timer_FF2Panel2(Handle:hTimer,any:user id)
{
new client=GetClientOfUserId(userid);
Command_SetMyBoss(client,0);
return Plugin_Continue;
}
public Action:Command_SetMyBoss(client, args)
{
if (bAdminOnly)
{
new AdminId:admin = GetUserAdmin(client);
if((admin == INVALID_ADMIN_ID) || !GetAdminFlag(admin, Admin_Generic))
return Plugin_Continue;
}
decl String:Special_Name[64];
decl String:s2[4];
decl Handle:BossKV;
new Handle:dMenu = CreateMenu(Command_SetMyBossH);
SetMenuTitle(dMenu, "%t","ff2boss_selected");
for (new i = 0; (BossKV=FF2_GetSpecialKV(i,true)); i++)
{
if (KvGetNum(BossKV, "blocked",0)) continue;
KvGetString(BossKV, "name", Special_Name, 64);
IntToString(i+1,s2,4);
AddMenuItem(dMenu,s2,Special_Name);
}
SetMenuExitButton(dMenu, true);
DisplayMenu(dMenu, client, 20);
return Plugin_Handled;
}
public Command_SetMyBossH(Handle:menu, MenuAction:action, param1, param2)
{
if (action != MenuAction_Select) return;
decl String:Special_Name[64];
decl Handle:BossKV;
for (new i = 0; (BossKV=FF2_GetSpecialKV(i,true)) && i < param2; i++)
if (KvGetNum(BossKV, "blocked",0)) param2++;
KvGetString(BossKV, "name",Special_Name, 64);
Incoming[param1] = param2;
ReplyToCommand(param1, "[FF2] Set your boss to %s", Special_Name);
}
public Action:FF2_OnSpecialSelected( index, &SpecialNum, String:SpecialName[])
{
new client=GetClientOfUserId(FF2_GetBossUserId(in dex));
if (!index && Incoming[client] != -1)
{
strcopy(SpecialName,2,"");
SpecialNum = Incoming[client];
Incoming[client] = -1;
return Plugin_Changed;
}
return Plugin_Continue;
}
I understand what I'm asking may not be well understood, but if I need to explain further I will.
Any help would be greatly appreciated, thanks in advance!
As a noob to sourcemod, I have no idea how to go around doing that
PHP Code:
public Action:FF2_OnSpecialSelected( index, &SpecialNum, String:SpecialName[]) { new client=GetClientOfUserId(FF2_GetBossUserId(index)); if (!index && Incoming[client] != -1) { strcopy(SpecialName,2,"BossNameHere/FileNameHere?"); SpecialNum = Incoming[client]; Incoming[client] = -1; return Plugin_Changed; } return Plugin_Continue; }
I would imagine something like that? But I would also like to know how I could like that to the menu choices themselves, I have the functions and choices working I just need to know what to throw in there.
btw, I think the latest version of the Boss Selection plugin is in this post.
Edit: Whoops, didn't mean to submit this yet... will add more stuff shortly.
My mistake, it's the name key that gets looked up rather than the config filename.
The reason that newer versions of FF2 ignore the SpecialNum in the callback is that boss sets change between maps, but this plugin doesn't handle that. Going by the name addresses this problem.
How the existing plugin works is that it basically starts at 0 and increments i forever until FF2_GetSpecialKV(i, true) returns false. In that loop, it checks if the boss is marked as blocked and if it isn't, it gets the boss name and adds it to a menu.
__________________
Not currently working on SourceMod plugin development.
btw, I think the latest version of the Boss Selection plugin is in this post.
Edit: Whoops, didn't mean to submit this yet... will add more stuff shortly.
My mistake, it's the name key that gets looked up rather than the config filename.
The reason that newer versions of FF2 ignore the SpecialNum in the callback is that boss sets change between maps, but this plugin doesn't handle that. Going by the name addresses this problem.
How the existing plugin works is that it basically starts at 0 and increments i forever until FF2_GetSpecialKV(i, true) returns false. In that loop, it checks if the boss is marked as blocked and if it isn't, it gets the boss name and adds it to a menu.
I still can't seem to get it working, I tried using
But with no success, though I do get a successful ReplyToCommand with
PHP Code:
ReplyToCommand(param1, "[FF2] Set your boss to %s", Incoming[param1]);
I've also tried
PHP Code:
case MenuAction_Select:
{
GetMenuItem(menu, param2, Incoming[param1], sizeof(Incoming[]));
ReplyToCommand(param1, "[FF2] Set your boss to %s", Incoming[param1]);
}
With no success either.
I have
PHP Code:
public Action:FF2_OnSpecialSelected( index, &SpecialNum, String:SpecialName[])
{
new client=GetClientOfUserId(FF2_GetBossUserId(index));
if (!index && !StrEqual(Incoming[client], ""))
{
strcopy(SpecialName, sizeof(Incoming[]), Incoming[client]);
Incoming[client] = "";
PrintToChatAll("Test Value");
return Plugin_Changed;
}
return Plugin_Continue;
}
At the bottom of the code (I added the PrintToChatAll() to test and thats appearing on every round start when a boss is chosen, but no effect on which boss is spawned. If it makes a difference:
PHP Code:
AddMenuItem(menu, "The Hidden", "The Hidden");
Is my menu form. So yes, the menu and everything is working now (Thanks), but I still don't have the function to change the boss itself