Un plugin que hice para mi server de surf aunque no necesariamente tiene que ser para mapas de surf.
#include
#include
#include
new g_SayText, RespawnMap;
public plugin_init()
{
register_plugin("Surf Respawn", "1.0", "ILUSION");
register_clcmd("say /respawn", "cmdRespawn");
register_clcmd("say", "cmdSay");
RegisterHam(Ham_Spawn, "weaponbox", "fw_SpawnWeaponBox", 1);
g_SayText = get_user_msgid("SayText");
LoadMaps();
}
public cmdSay(id)
{
if (!RespawnMap)
return PLUGIN_CONTINUE;
new say[192];
read_args(say, charsmax(say));
if (containi(say, "respawn") != -1)
ChatColor(0, "!g[Hunter Gamers] !yEn este mapa el !teamrespawn !yesta activado. Escribe !g/respawn !ypara revivir!");
return PLUGIN_CONTINUE;
}
public cmdRespawn(id)
{
if (!RespawnMap)
ChatColor(id, "!g[Hunter Gamers] !yEn este mapa el !teamrespawn !yesta !gdeshabilitado");
else if (get_user_team(id) != 1 && get_user_team(id) != 2)
ChatColor(id, "!g[Hunter Gamers] !yNo podes usar este comando siendo !teamespectador");
else if (!is_user_alive(id))
ExecuteHamB(Ham_CS_RoundRespawn, id);
else
ChatColor(id, "!g[Hunter Gamers] !yPara usar este comando tenes que estar !gmuerto");
return PLUGIN_HANDLED;
}
public fw_SpawnWeaponBox(iEntity) // xPaw
{
if (RespawnMap)
{
set_pev(iEntity, pev_flags, FL_KILLME);
dllfunc(DLLFunc_Think, iEntity);
}
return HAM_IGNORED;
}
LoadMaps()
{
new curmap[32], szMap[64][32];
get_mapname(curmap, charsmax(curmap));
if (containi(curmap, "surf_") == -1)
pause("a");
new szFile[] = "addons/amxmodx/configs/surf_respawn.ini";
if (!file_exists(szFile))
RespawnMap = false;
new file = fopen(szFile, "rt");
new szLine[255], linea;
while (!feof(file))
{
szLine[0] = '^0';
fgets(file, szLine, charsmax(szLine));
trim(szLine);
if (szLine[0] == ';' || !szLine[0] || szLine[0] == '^n')
continue;
copy(szMap[linea], sizeof szMap, szLine);
linea++;
}
fclose(file);
for (new i = 0; i < linea; i++)
{
if (equal(curmap, szMap[i]))
{
RespawnMap = true;
break;
}
}
}
stock ChatColor(const id, const input[], any:...)
{
new count = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!g", "^4"); // Green Color
replace_all(msg, 190, "!y", "^1"); // Default Color
replace_all(msg, 190, "!team", "^3"); // Team Color
replace_all(msg, 190, "!team2", "^0"); // Team2 Color
new iPlayer;
if (id) players[0] = id; else get_players(players, count, "ch");
{
for (new i = 0; i < count; i++)
{
iPlayer = players[i];
if (is_user_connected(iPlayer))
{
message_begin(MSG_ONE_UNRELIABLE, g_SayText, _, iPlayer);
write_byte(iPlayer);
write_string(msg);
message_end();
}
}
}
}
Si no lo van a usar exclusivamente para mapas de surf saquen la parte que dice
if (containi(curmap, "surf_") == -1)
pause("a");
Es simple la función del plugin, tienen que crear un archivo que se llame surf_respawn.ini y lo ponen en addons/amxmodx/configs, en ese archivo ponen los nombre de los mapas donde está permitido el respawn por ej:
surf_green
surf_ski_2
surf_water-run
Para evitar que tiren el server respawneando muchas veces (muchas armas droppeadas) al caer un arma desaparece automáticamente.