Raised This Month: $12 Target: $400
 3% 

Create customs Modes


Post New Thread Reply   
 
Thread Tools Display Modes
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
Lure.d
BANNED
Join Date: Dec 2009
Location: Lithuania->USA
Old 07-05-2010 , 01:42   Re: Create customs Modes
Reply With Quote #2

Typo in "The modes code" :

PHP Code:
g_lastmode MODO_ONE 

PHP Code:
g_lastmode MODE_ONE 
Lure.d is offline
Send a message via Skype™ to Lure.d
Zapdos1
BANNED
Join Date: Jul 2009
Location: Chile - La Serena
Old 07-05-2010 , 07:22   Re: Create customs Modes
Reply With Quote #3

Quote:
Originally Posted by Lure.d View Post
Typo in "The modes code" :

PHP Code:
g_lastmode MODO_ONE 

PHP Code:
g_lastmode MODE_ONE 
fixed, thanks
Zapdos1 is offline
Lure.d
BANNED
Join Date: Dec 2009
Location: Lithuania->USA
Old 07-06-2010 , 20:44   Re: Create customs Modes
Reply With Quote #4

kekekekeke
Lure.d is offline
Send a message via Skype™ to Lure.d
PattyBiena
BANNED
Join Date: Jul 2010
Location: Argentina
Old 07-17-2010 , 22:07   Re: Create customs Modes
Reply With Quote #5

Espanglish.

PHP Code:
NO_MODE
-->
MODE_NONE
----------------------------
g_examplemode
-->
g_modexample 
PattyBiena is offline
Zapdos1
BANNED
Join Date: Jul 2009
Location: Chile - La Serena
Old 07-17-2010 , 22:56   Re: Create customs Modes
Reply With Quote #6

Quote:
Originally Posted by PattyBiena View Post
Espanglish.

PHP Code:
NO_MODE
-->
MODE_NONE
----------------------------
g_examplemode
-->
g_modexample 
changed the "espanglish" to english lol
thanks
Zapdos1 is offline
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 07-19-2010 , 06:05   Re: Create customs Modes
Reply With Quote #7

Why are you using hltv event to hook round start and not the normal logevent?
__________________
I am out of order!
grimvh2 is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viña del Mar, Chile
Old 07-19-2010 , 17:03   Re: Create customs Modes
Reply With Quote #8

Quote:
Originally Posted by grimvh2 View Post
Why are you using hltv event to hook round start and not the normal logevent?
Quote:
So, i took the zp code and passed it to a normal code
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 07-20-2010 , 03:35   Re: Create customs Modes
Reply With Quote #9

Don't blindly take codes if you don't know the difference, if you post in this section its because you can help others.
__________________
I am out of order!
grimvh2 is offline
Zapdos1
BANNED
Join Date: Jul 2009
Location: Chile - La Serena
Old 07-20-2010 , 09:45   Re: Create customs Modes
Reply With Quote #10

Quote:
Originally Posted by grimvh2 View Post
Don't blindly take codes if you don't know the difference, if you post in this section its because you can help others.
i posted that code, just to help to anybody than wants to do modes for his plugin
Zapdos1 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:45.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode