这是CS公司一款游戏求生之路(L4D)的插件文件,文件中说明支持L4D和L4D2两代游戏的投票换图功能,国外的插件技术论坛上,由于作者的一些原因导致插件开发完毕后,没有继续更新插件的细节问题.因为我也不知道这个是不是C语言的,所以发上来求助一下各位.如果各位能看懂,希望各位在不麻烦的情况下,修改一下原文中的内容.希望这个插件具备一下内容:
1.管理员发起投票,直接更换地图
2.普通玩家也可以发起投票(在游戏中提示普通玩家没有权限,但是依然显示投票菜单,确认投票后并无任何反应)
3.普通玩家投票要有间隔时间
如果以上要求需要重新写代码,如果各位麻烦就不必了!因为我也不懂有多麻烦,但是请一定帮忙吧普通玩家可以投票的权限打开,因为在游戏中,建立游戏的主机使用插件可以直接更换地图,但是如果使用CS服务器,即使你拥有管理员权限,但是你不是服务器本身,所以执行!votemap语句依然提示你无权限.
// Force strict semicolon mode
#pragma semicolon 1
#include <sourcemod>#define PLUGIN_VERSION "0.666 beta"new String:g_gameMode[64];
new Handle:g_mapMenu = INVALID_HANDLE;
new Handle:g_mapVoteTime = INVALID_HANDLE;new bool: game_l4d2 = false;public Plugin:myinfo =
{
name = "[L4D2] Campaign/Map Voter",
author = "satannuts",
description = "Allows voting by players to change campaign/map",
version = PLUGIN_VERSION,
url = "..."
}public OnPluginStart()
{
decl String: game_name[64];
GetGameFolderName(game_name, sizeof(game_name));
if (!StrEqual(game_name, "left4dead", false) && !StrEqual(game_name, "left4dead2", false))
{
SetFailState("Use this in Left 4 Dead or Left 4 Dead 2 only.");
}
if (StrEqual(game_name, "left4dead2", false))
{
game_l4d2 = true;
} CreateConVar("l4d_mapvote_version", PLUGIN_VERSION, "[[L4D2] Campaign/Map Voter Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);
RegConsoleCmd("say", Command_Say);
RegConsoleCmd("say_team", Command_Say);
RegAdminCmd("sm_cancelvote", Command_CancelVote, ADMFLAG_VOTE);
RegAdminCmd("sm_mapvote", Command_MapVote, ADMFLAG_CHANGEMAP);
g_mapVoteTime = CreateConVar("sm_mapvotetime", "20", "投票时间",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY);
CreateConVar("l4d_mapvote_announce_mode", "1", "是否开启投票通告.");
AutoExecConfig(true, "l4d2_mapvote_beta");
}public OnMapStart()
{
new Handle:currentGameMode = FindConVar("mp_gamemode");
GetConVarString(currentGameMode, g_gameMode, sizeof(g_gameMode));
}public OnClientPutInServer(client)
{
if(GetConVarInt(FindConVar("l4d_mapvote_announce_mode")) != 0)
{
CreateTimer(50.0, Timer_WelcomeMessage, client);
}
}public Action:Timer_WelcomeMessage(Handle:timer, any:client) 
{
new String:announce[] = "\x01[SM] To call a vote to change map/campaign votes, Type: \x04!mapvote\x01 in chat.";
if (IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client)) 
{
switch (GetConVarInt(FindConVar("l4d_backpack_help_mode"))) 
{
case 1: 
{
PrintToChat(client, announce);
}
case 2: 
{
PrintHintText(client, announce);
}
case 3: 
{
PrintCenterText(client, announce);
}
default: 
{
PrintToChat(client, announce);
}
}
}
}public Action:Command_Say(client, args)
{
if(!client)
{
return Plugin_Continue;
} decl String:text[192];
if(!GetCmdArgString(text, sizeof(text)))
{
return Plugin_Continue;
}

new startidx = 0;
if(text[strlen(text)-1] == '"')
{
text[strlen(text)-1] = '\0';
startidx = 1;
}

if(strcmp(text[startidx], "!mapvote", false) == 0)
{
DoMapVoteList(client);
}
return Plugin_Continue;
}DoMapVoteList(client)
{
g_mapMenu = BuildMapMenu(false);
DisplayMenu(g_mapMenu, client, 60);
}public Handle_MapVoteList(Handle:mapMenu, MenuAction:action, param1, param2)
{
// Change the map to the selected item.
if(action == MenuAction_Select)
{
decl String:map[64];
GetMenuItem(mapMenu, param2, map, sizeof(map));
DoVoteMenu (map);
}
/* If the menu has ended, destroy it */
else if (action == MenuAction_End)
{
CloseHandle(mapMenu);
}
}
DoVoteMenu(const String:map[])
{
if(IsVoteInProgress())
{
return;
}
 
new Handle:voteMenu = CreateMenu(Handle_VoteMenu);
SetMenuTitle(voteMenu, "你同意更换地图: %s?", map);
AddMenuItem(voteMenu, map, "是");
AddMenuItem(voteMenu, "no", "否");
SetMenuExitButton(voteMenu, false);

new voteTime = GetConVarInt(g_mapVoteTime);
VoteMenuToAll(voteMenu, voteTime);

PrintToChatAll("等待其他玩家投票...");}public Handle_VoteMenu(Handle:voteMenu, MenuAction:action, param1, param2)
{
if(action == MenuAction_End)
{
CloseHandle(voteMenu);
}
else if(action == MenuAction_VoteEnd)
{
decl String:map[64];
GetMenuItem(voteMenu, param1, map, sizeof(map));
PrintToChatAll("投票成功!  Changing to %s");
ServerCommand("changelevel %s", map);
}
else if(action == MenuAction_VoteCancel)
{
// If we receive 0 votes, pick at random.
if (param1 == VoteCancel_NoVotes)
{
PrintToChatAll("投票失败.");
}
else
{
// We were actually cancelled. Guess we do nothing.
}
}
}
public Action:Command_CancelVote(client, args)
{
CancelVote();

return Plugin_Handled;
}public Action:Command_MapVote(client, args)
{
g_mapMenu = BuildMapMenu(true);
DisplayMenu(g_mapMenu, client, 60);
 
return Plugin_Handled;
}public Handle_AdminMapMenu(Handle:mapMenu, MenuAction:action, param1, param2)
{
// Change the map to the selected item.
if(action == MenuAction_Select)
{
decl String:map[64];
GetMenuItem(mapMenu, param2, map, sizeof(map));
ServerCommand("changelevel %s", map);
}
// If the menu was cancelled, choose a random map.
else if (action == MenuAction_Cancel)
{
CloseHandle(mapMenu);
}
// If the menu has ended, destroy it
else if (action == MenuAction_End)
{
CloseHandle(mapMenu);
}
}Handle:BuildMapMenu(bool:adminMode)
{
new Handle:mapMenu = INVALID_HANDLE;

if(adminMode)
{
mapMenu = CreateMenu(Handle_AdminMapMenu);
}
else
{
mapMenu = CreateMenu(Handle_MapVoteList);
}

SetMenuTitle(mapMenu, "选择地图");
SetMenuExitButton(mapMenu, false);
if(game_l4d2)
{
if(strcmp(g_gameMode, "coop", false) == 0)
{
AddMenuItem(mapMenu, "c1m1_hotel", "Dead Center");
}
else if(strcmp(g_gameMode, "realism", false) == 0)
{
AddMenuItem(mapMenu, "c1m1_hotel", "Dead Center");
}
else if(strcmp(g_gameMode, "versus", false) == 0)
{
AddMenuItem(mapMenu, "c1m1_hotel", "Dead Center");
}
else if(strcmp(g_gameMode, "teamversus", false) == 0)
{
AddMenuItem(mapMenu, "c1m1_hotel", "Dead Center");
}
else if(strcmp(g_gameMode, "survival", false) == 0)
{
AddMenuItem(mapMenu, "c1m4_atrium", "Atrium");
}
else if(strcmp(g_gameMode, "scavenge", false) == 0)
{
AddMenuItem(mapMenu, "c1m4_atrium", "Atrium");
}
else if(strcmp(g_gameMode, "teamscavenge", false) == 0)
{
AddMenuItem(mapMenu, "c1m4_atrium", "Atrium");
}
else
{
AddMenuItem(mapMenu, "c1m1_hotel", "Dead Center");
}
}
else
{
if(strcmp(g_gameMode, "coop", false) == 0)
{
AddMenuItem(mapMenu, "l4d_hospital01_apartment", "毫不留情");
else if(strcmp(g_gameMode, "versus", false) == 0)
{
AddMenuItem(mapMenu, "l4d_vs_hospital01_apartment", "Mercy Hospital");
}
else if(strcmp(g_gameMode, "survival", false) == 0)
{
AddMenuItem(mapMenu, "l4d_hospital02_subway", "Generator Room");
}
} return mapMenu;
}
/**
*public OnMapEnd()
*{
* if (g_mapMenu != INVALID_HANDLE)
* {
* CloseHandle(g_mapMenu);
* g_mapMenu = INVALID_HANDLE;
* }
*
* if (g_gameModeMenu != INVALID_HANDLE)
* {
* CloseHandle(g_gameModeMenu);
* g_gameModeMenu = INVALID_HANDLE;
* }
*}
*/

解决方案 »

  1.   

    不是c,不是c++,不是php,不是java.
    c#?
      

  2.   

    public Handle_VoteMenu(Handle:voteMenu, MenuAction:action, param1, param2)
    这种方法不是c++的语法
      

  3.   

    自定义的脚本语言。
    类似的技术在很多年前就使用了,尤其在游戏中,象90年代中期的Duke3D、Quake都是如此(Quake就使用一种称之为Quake C的类C代码),开发者先实现一个游戏引擎,然后写一个脚本(可以理解为“剧本”)来实现游戏的过程,脚本是由引擎来(解释)执行的,改一套脚本就可以创造出一个新游戏。对于楼主的问题,普通玩家能不能投票是由服务器决定的吧,准确说是服务器接不接受普通玩家的投票、承认不承认普通玩家投票的有效性。你更改客户端恐怕解决不了问题。