Member
|
03-02-2011
, 00:52
Re: [Problema] codigo Respawn e InfiniteRound
|
#7
|
Broo ese codigo es muy distinto al mio no se mucho sobre codear asi q no concuerdo nada de donde colocar ese codigo ve acontinuacion te dejare los 2 codigos que uso
Respawn
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <fun>
new g_MONEY, g_PRACTICA
public TeamSelect(id)
{
if (get_pcvar_num(g_PRACTICA)) {
new sId[2]
sId[0] = id
set_task(10.0,"respawn",0,sId,2)
}
return PLUGIN_CONTINUE
}
public death_msg()
{
if (get_pcvar_num(g_PRACTICA)) {
new vIndex = read_data(2)
new svIndex[2]
svIndex[0] = vIndex
set_task(0.5,"respawn",0,svIndex,2)
}
return PLUGIN_CONTINUE
}
public respawn(svIndex[])
{
new vIndex = svIndex[0]
if(get_user_team(vIndex) == 3 || is_user_alive(vIndex))
return PLUGIN_CONTINUE
spawn(vIndex)
return PLUGIN_CONTINUE
}
public event_money(id)
{
if(get_pcvar_num(g_PRACTICA))
{
cs_set_user_money(id, get_pcvar_num(g_MONEY), 0)
}
}
public plugin_init()
{
register_plugin("Practica","0.2","kung fu")
register_event("DeathMsg","death_msg","a")
register_event("ShowMenu","TeamSelect","b","4&Team_Select")
register_event("VGUIMenu","TeamSelect","b","1=2")
register_event("Money", "event_money", "be")
g_PRACTICA = register_cvar("amx_practica","0")
g_MONEY = register_cvar("round_money","16000")
return PLUGIN_CONTINUE
}
Infinite Round
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <orpheu>
#include <orpheu_memory>
/* PLUGIN INFORMATIONS */
#define PLUGIN_NAME "Infinite Round"
#define PLUGIN_VERSION "1.0.1"
#define PLUGIN_AUTHOR "Arkshine"
/* ORPHEU HOOK HANDLES */
new OrpheuHook:handleHookCheckMapConditions;
new OrpheuHook:handleHookCheckWinConditions;
new OrpheuHook:handleHookHasRoundTimeExpired;
/* CONSTANTS */
new memoryIdentifierRoundTime[] = "roundTimeCheck";
enum /* plugin state */
{
DISABLED = 0,
ENABLED
};
/* VARIABLES */
new currentPluginState = ENABLED;
new bool:isLinuxServer;
public plugin_init()
{
register_plugin( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR );
register_cvar( "infiniteround_version", PLUGIN_VERSION, FCVAR_SERVER | FCVAR_SPONLY );
register_concmd( "infiniteround_toggle", "ConsoleCommand_TogglePlugin", ADMIN_RCON, "<0|1> - Toggle plugin state" );
isLinuxServer = bool:is_linux_server();
state disabled;
EnableForwards();
}
/**
* Command to toggle the plugin state,
* then to enable/disable properly the forwards used.
*/
public ConsoleCommand_TogglePlugin ( const player, const level, const cid )
{
if ( cmd_access( player, level, cid, 2 ) )
{
new newPluginState[ 2 ];
read_argv( 1, newPluginState, charsmax( newPluginState ) );
new statePluginWanted = clamp( str_to_num( newPluginState ), DISABLED, ENABLED );
switch ( statePluginWanted )
{
case DISABLED : DisableForwards();
case ENABLED : EnableForwards();
}
( currentPluginState == statePluginWanted ) ?
console_print( player, "%s", statePluginWanted ? "Plugin already enabled!" : "Plugin already disabled!" ) :
console_print( player, "%s", statePluginWanted ? "Plugin is now enabled!" : "Plugin is now disabled!" );
currentPluginState = statePluginWanted;
}
return PLUGIN_HANDLED;
}
/**
* The plugin was disabled. A user has enabled the plugin with the command.
* Enable properly all the forwards and patch the memory for windows only.
*/
public EnableForwards () <> {}
public EnableForwards () <disabled>
{
handleHookCheckMapConditions = OrpheuRegisterHook( OrpheuGetFunction( "CheckMapConditions" , "CHalfLifeMultiplay" ), "CheckConditions" );
handleHookCheckWinConditions = OrpheuRegisterHook( OrpheuGetFunction( "CheckWinConditions" , "CHalfLifeMultiplay" ), "CheckConditions" );
if ( isLinuxServer )
{
handleHookHasRoundTimeExpired = OrpheuRegisterHook( OrpheuGetFunction( "HasRoundTimeExpired" , "CHalfLifeMultiplay" ), "CheckConditions" );
}
else
{
/*
| Windows - CHalfLifeMultiplay::HasRoundTimeExpired() is somehow integrated in CHalfLifeMultiplay::Think(),
| we must patch some bytes directly into this function to avoid the check. Ugly trick but no choice.
| 0x90 = NOP = does nothing. Don't modify the values.
*/
BytesToReplace( memoryIdentifierRoundTime, { 0x90, 0x90, 0x90 } );
}
state enabled;
}
/**
* The plugin was enabled. A user has disabled the plugin with the command.
* Disable properly all the forwards and patch the memory for windows only.
*/
public DisableForwards () <> {}
public DisableForwards () <enabled>
{
OrpheuUnregisterHook( handleHookCheckMapConditions );
OrpheuUnregisterHook( handleHookCheckWinConditions );
if ( isLinuxServer )
{
OrpheuUnregisterHook( handleHookHasRoundTimeExpired );
}
else
{
/*
| Windows - We restore the original value.
| We restart to reinitialize the game.
| Don't modify the values.
*/
BytesToReplace( memoryIdentifierRoundTime, { 0xF6, 0xC4, 0x41 } );
}
state disabled;
}
/**
* Block CHalfLifeMultiplay::CheckMapConditions(), CHalfLifeMultiplay::CheckWinConditions()
* and CHalfLifeMultiplay::HasRoundTimeExpired() so the round won't stop whatever the situation.
*/
public OrpheuHookReturn:CheckConditions () <> { return OrpheuIgnored; }
public OrpheuHookReturn:CheckConditions () <enabled>
{
OrpheuSetReturn( false );
return OrpheuSupercede;
}
/**
* Replace at a specific memory address a value byte by byte.
*
* @param identifier The name of the block that qualifies memory.
* @param bytes The bytes we want to patch.
*/
stock BytesToReplace ( identifier[], const bytes[], const bytesLength = sizeof bytes )
{
new address;
OrpheuMemoryGet( identifier, address );
for ( new i; i < bytesLength; i++)
{
OrpheuMemorySetAtAddress( address, "roundTimeCheck|dummy", 1, bytes[ i ], address );
address++;
}
/*
| It needs to reiniatiliaze some things.
*/
server_cmd( "sv_restart 1" );
}
si puedes me ayudas mas personal mente para no alarga el post.
|
|