View Single Post
Author Message
Zapdos1
BANNED
Join Date: Jul 2009
Location: Chile - La Serena
Old 07-01-2010 , 14:19   Create customs Modes
Reply With Quote #1

Well, i was doing a plugin about modes like zombie plague but for normal gameplay (not zp).

So, i took the zp code and passed it to a normal code (without zombie plague include)

(Sorry my english)

Here is:

So we add the includes and definitions:

PHP Code:
/* Create Modes with Zombie Plague style, but for normal Counter Strike */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich> 

#define VERSION "1.0"

new cvar_modecvar_min_playerscvar_chance //We register our pcvars
new g_newround
new g_endround
new g_lastmode
new g_modexample //And the Variables

/*Also we have to enum our modes for the game */
enum
{
    
MODE_NONE 0,
    
MODE_ONE

Here our plugin_init()
PHP Code:
public plugin_init() 
{
    
register_plugin("My Modes"VERSION"Zapdos1"//We register the Plugin Name and the Plugin Author
    
    
register_event"HLTV""RoundStart""a""1=0""2=0" //Here the RoundStart event (When the round starts)
    
register_logevent("Round_end"2"1=Round_End"//Here the round_end event (When the round ends)
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage"//Here when the player takes damage
    
    //Aquí registramos las pcvars
    
cvar_mode register_cvar("modes_toggle""1"//If the modes are enabled
    
cvar_min_players register_cvar("mode_min_players""2")
    
cvar_chance register_cvar("mode_chances""50")

Later ours RoundStart and Round_end events
PHP Code:
public RoundStart()
{
    
g_newround true
    g_endround 
false
    g_modexample 
false
    
    set_task
(2.0"go_to_mode"//Later of setting the Variables true or false, we set a task to the public "go_to_mode"
}

public 
Round_end()
{
    
g_newround false //We set again this false
    
g_endround true //And this true

The modes code:

PHP Code:
public go_to_mode()
{
    
start_mode(NO_MODE
}

start_mode(mode)
{
    static 
iPlayersnum
    iPlayersnum 
get_playersnum() //We get the number of players 
    
    
if (iPlayersnum 1//If players number < 1, start with no mode 
    
{
        
set_task(2.0"go_to_mode")
        return;
    }
    
    
g_newround false 
    
    
if ((mode == MODE_NONE || (g_lastmode != MODE_ONE) && random_num(1get_pcvar_num(cvar_chance)) && get_pcvar_num(cvar_modo) && iPlayersnum >= get_pcvar_num(cvar_min_jugadores)) || mode == MODE_ONE)
    { 
        
g_modexample true //Our mode is now true
        
g_lastmode MODE_ONE  
        
        set_hudmessage
(25500, -1.0, -1.006.05.0//So we send a message to the players
        
show_hudmessage(0"The example mode was started!")
    }

If you compile now your plugin, the Amxx-Studio is going to tells you, than you are not using the Variables

So we are going to use them...

PHP Code:
public fw_TakeDamage(victim)
{
    if (
g_newround || g_endround)
    return 
HAM_SUPERCEDE;
    
    if (
g_modexample
    return 
HAM_IGNORED//The mode can't affect the gameplay, so we return it 
    
    
return PLUGIN_CONTINUE;

Any dudes, questions, anything, just leave the comment...

Remember than i passed from the zombie plague code to the normal code, and I'm posting this to help you if you want to do modes for your plugin

Quote:
Thanks to:

Alucard^
(Sorry my english, I'm trying to do my best)

Last edited by Zapdos1; 07-17-2010 at 22:55.
Zapdos1 is offline