Member
|
07-24-2012
, 11:00
Re: Terrorists Only v1.1.0
|
#34
|
How should I change the plugin to work with 32 players. I do not understand how to program amxx
Quote:
/* AMX Mod X script.
Terrorists Only plugin
(c) Copyright 2007, Simon Logic '[email protected]'
This file is provided AS IS (no warranties).
Info:
Removes all CT spawn points & doubles the number of T spawn points.
Use with random respawn engine only (e.g. built-in CSDM).
Requirements:
* CS/CZ mod (may work on others)
* AMX/X 1.7x or higher
* Fakemeta module
FAQ:
1) Q: I don't want to double spawn points. What to do?
A: Change g_iMultiplier var default value to 1 & recompile plugin
2) Q: What can i do if the map has less than 16 T spawn points
but i wanna be able to play full 32 players server?
A: Alter g_sExclusiveMaps array & recompile plugin
3) Q: Can i make a 'CT Only' plugin?
A: Yes, exchange values of g_sClass2Remove & g_sClass2Spawn
constants, make a revision of g_sExclusiveMaps array & recompile
plugin
Changelog:
1.1.0 [2007-11-17]
+ spawn point multiplier var
+ array g_sExclusiveMaps to customize spawn point multiplier per map
* plugin renamed from 'All Terrors' to 'Terrorists Only'
* first public release
1.0.0 [2007-10-23]
* initial release (not available for public)
*/
#include <amxmodx>
#include <amxmisc>
#include <fakemeta_stocks>
#pragma tabsize 4
#pragma ctrlchar '\'
#define MAX_CLIENTS 32
#define MAX_MAPNAME 64
//#define __DEBUG
new const MY_PLUGIN_NAME[] = "Terrorists Only"
new const MY_PLUGIN_VERSION[] = "1.1.0"
new const MY_PLUGIN_AUTHOR[] = "Simon Logic"
new const
g_sClass2Remove[] = "info_player_start",
g_sClass2Spawn[] = "info_player_deathmatch"
// point here custom multiplier for maps which have less than 16 spawn points
// per team; 0 as multiplier makes plugin ignore current map
new const g_sExclusiveMaps[][] = {
"basekill:10", // 3T
"cobase:5" // 6T
// NOTE: extend list on your own
}
new bool:g_bValidSP
new g_iMultiplier = 2 // default multiplier value is 2
new g_iSpawnCount
new g_asSpawnEntity
//-----------------------------------------------------------------------------
public plugin_precache()
{
g_asSpawnEntity = EF_AllocString(g_sClass2Spawn)
new i, iPos, sMapname[64]
get_mapname(sMapname, sizeof(sMapname)-1)
for(i=0; i<sizeof(g_sExclusiveMaps); i++)
{
iPos = charPos(g_sExclusiveMaps[i], ':')
if(iPos >= 0)
{
g_sExclusiveMaps[i][iPos] = 0
if(equali(sMapname, g_sExclusiveMaps[i]))
{
g_iMultiplier = str_to_num(g_sExclusiveMaps[i][iPos+1])
#if defined __DEBUG
log_amx("new multiplier: %d", g_iMultiplier)
#endif
break
}
}
}
if(g_iMultiplier > 0)
if(g_iMultiplier > MAX_CLIENTS)
log_amx("Too big multiplier: %d", g_iMultiplier)
else {
register_forward(FM_Spawn, "onSpawn")
register_forward(FM_Spawn, "onSpawn_Post", 1)
}
}
//-----------------------------------------------------------------------------
public plugin_init()
{
register_plugin(MY_PLUGIN_NAME, MY_PLUGIN_VERSION, MY_PLUGIN_AUTHOR)
register_cvar("version_only_terrors", MY_PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY)
}
//-----------------------------------------------------------------------------
public onSpawn(id)
{
if(!pev_valid(id))
return FMRES_IGNORED
static sClassname[32]
pev(id, pev_classname, sClassname, sizeof(sClassname) - 1)
if(equal(sClassname, g_sClass2Remove))
{
EF_RemoveEntity(id)
return FMRES_SUPERCEDE
}
else if(g_iMultiplier > 1 && equal(sClassname, g_sClass2Spawn))
{
g_bValidSP = true
}
return FMRES_IGNORED
}
//-----------------------------------------------------------------------------
public onSpawn_Post(id)
{
if(g_bValidSP)
{
new iAngle
new Float:fVector[3], Float:fAngles[3]
g_bValidSP = false
pev(id, pev_origin, fVector)
pev(id, pev_angles, fAngles)
vector_to_angle(fAngles, fAngles)
iAngle = floatround(fAngles[1])
for(new i=1; i<g_iMultiplier; i++)
{
spawnPlayerSpawn(g_sClass2Spawn, fVector, iAngle)
g_iSpawnCount++
}
}
}
//-----------------------------------------------------------------------------
stock spawnPlayerSpawn(const classname[], const Floatrigin[3], const angle)
{
new entity; entity = EF_CreateNamedEntity(g_asSpawnEntity)
if(!entity)
return 0
#if defined __DEBUG
log_amx("spawnPlayerSpawn(%s, {%.0f,%.0f,%.0f}, %d)", classname, origin[0], origin[1], origin[2], angle)
#endif
new sValue[32]
new iVector[3]
FVecIVec(origin, iVector)
formatex(sValue, sizeof(sValue)-1, "%d %d %d", iVector[0], iVector[1], iVector[2])
fm_set_kvd(entity, "origin", sValue, classname)
num_to_str(angle, sValue, sizeof(sValue) - 1)
fm_set_kvd(entity, "angle", sValue)
DF_Spawn(entity)
return 1
}
//-----------------------------------------------------------------------------
// taken from fakemeta_util.inc (by VEN)
stock fm_set_kvd(entity, const key[], const value[], const classname[] = "")
{
if (classname[0])
set_kvd(0, KV_ClassName, classname)
else {
new class[32]
pev(entity, pev_classname, class, sizeof class - 1)
set_kvd(0, KV_ClassName, class)
}
set_kvd(0, KV_KeyName, key)
set_kvd(0, KV_Value, value)
set_kvd(0, KV_fHandled, 0)
return dllfunc(DLLFunc_KeyValue, entity, 0)
}
//-----------------------------------------------------------------------------
stock charPos(const str[], const chr)
{
for(new i=0; str[i]; i++)
if(chr == str[i])
return i
return -1
}
//-----------------------------------------------------------------------------
|
Last edited by fiury; 07-24-2012 at 11:01.
|
|