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

CSDM spawn vote


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AcidoX
Senior Member
Join Date: Oct 2007
Location: Vilnius
Old 09-23-2009 , 14:37   CSDM spawn vote
Reply With Quote #1

Hi, i've like to suggest someone to make a plugin like this. When you connect to the server, or maybe better when min 4 players connect to the server, it starts a vote for csdm spawn, random or none. Is that hard to code?
__________________
Who need lockerz invite? Pm me.
AcidoX is offline
Send a message via Skype™ to AcidoX
biscuit628
Senior Member
Join Date: Jun 2007
Location: 香港HongKong
Old 09-23-2009 , 15:10   Re: CSDM spawn vote
Reply With Quote #2

PHP Code:
public plugin_init
{
    
register_menucmd(register_menuid("VoteMenu"), 1023"CountVotes")
}
new 
ga_Choice[3]
new 
bool:voting false


public client_putinserver(id)
{

    new 
g_iPlayers[32]
    new 
g_iNum;
    
get_players(g_iPlayersg_iNum"ch");
    
    if(
g_iNum >= && !voting)
    {
        
InitVote()
    }
}

public 
InitVote()
{
    
voting true
    
static menuBody[512]
    
format(menuBody,511,"\rRandom Spawn?^n1. Yes^n2. No");
    
ga_Choice[1] = 0
    ga_Choice
[2] = 0
    show_menu
0, (1<<1)|(1<<2), menuBody14"VoteMenu" )
    
set_task(15.0,"showResult");
}

public 
CountVotes(key)
{
    ++
ga_Choice[key]
}

public 
showResult()
{
    new 
TotalVotes ga_Choice[1] + ga_Choice[2]
    new 
Float:result = (float(ga_Choice[1]) / float(TotalVotes))
    if( 
result >= 5.0)
    {
        
//trun on
    
}
    else
    {
        
//turn off
    
}

__________________
My Plugins

C4man with fun

Sniper Skill bonus
-------------------------
Sorry for my poor English!

Last edited by biscuit628; 09-23-2009 at 15:25.
biscuit628 is offline
AcidoX
Senior Member
Join Date: Oct 2007
Location: Vilnius
Old 09-23-2009 , 19:29   Re: CSDM spawn vote
Reply With Quote #3

How to enable/disable CSDM spawns thru amxx?
__________________
Who need lockerz invite? Pm me.
AcidoX is offline
Send a message via Skype™ to AcidoX
AcidoX
Senior Member
Join Date: Oct 2007
Location: Vilnius
Old 09-24-2009 , 10:40   Re: CSDM spawn vote
Reply With Quote #4

Well, i have a problem I dont know how to set CSDM spawns random or none Thru amxx.

Code:
#include <amxmodx>

#define PLUGIN "CSDM Spawn Voter"
#define VERSION "1.0"
#define AUTHOR "AciD"

new ga_Choice[3]
new bool:voting = false

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_menucmd(register_menuid("VoteMenu"), 1023, "CountVotes")
}

public client_putinserver(id)
{
    new g_iPlayers[32], g_iNum
    get_players(g_iPlayers, g_iNum, "ch")
    
    if(g_iNum >= 4 && !voting)
    {
        InitVote()
    }
}

public InitVote()
{
    static menuBody[512]
    format(menuBody,511,"\rRandom Spawn?^n1. Yes^n2. No")
    ga_Choice[1] = 0
    ga_Choice[2] = 0
    voting = true
    show_menu(0, (1<<1)|(1<<2), menuBody, 14, "VoteMenu")
    set_task(15.0,"showResult")
}

public CountVotes(key)
{
    ++ga_Choice[key]
}

public showResult()
{
    new TotalVotes = ga_Choice[1] + ga_Choice[2]
    new Float:result = (float(ga_Choice[1]) / float(TotalVotes))
    if(result >= 5.0)
    {
        //trun on
    }
    else
    {
        //turn off
    }
}
__________________
Who need lockerz invite? Pm me.
AcidoX is offline
Send a message via Skype™ to AcidoX
KWo
AMX Mod X Beta Tester
Join Date: Jul 2004
Location: Poland
Old 09-25-2009 , 03:11   Re: CSDM spawn vote
Reply With Quote #5

Since spawnmode = preset/none is an internal variable, there is no way to change it from external plugin... The only way is to modify csdm_main.sma and include there Your code.
__________________
The Fullpack of podbot mm V3B22 - 24 apr 2012!!! is available here.
The All-In-One 3.2a package - 02 jun 2013 (AMX X 1.8.2 [with ATAC 3.0.1b , CSDM2.1.3c beta, CM OE 0.6.5, podbot mm V3B22c and mm 1.20) is available here.
The newest Beta V3B23a (rel. 28 august 2018!!!) is available here.
KWo is offline
AcidoX
Senior Member
Join Date: Oct 2007
Location: Vilnius
Old 09-25-2009 , 05:40   Re: CSDM spawn vote
Reply With Quote #6

Hm... Ok, thnx for your help I will see, what can i find in csdm_main.

Edit: Is this what your talking about?

Code:
        } else if (equali(setting, "spawnmode")) {
            new var = csdm_setstyle(value)
            if (var)
            {
                log_amx("CSDM spawn mode set to %s", value)
            } else {
                log_amx("CSDM spawn mode %s not found", value)
            }
csdm.inc

Code:
//Sets the current spawn style handler by name.
//The handler registered to this name will be called after every spawn.
native csdm_setstyle(const name[]);
Edit2:
What is the value of csdm_setstyle 1,2 or none/random ?
__________________
Who need lockerz invite? Pm me.

Last edited by AcidoX; 09-25-2009 at 05:50. Reason: csdm_main.sma editing
AcidoX is offline
Send a message via Skype™ to AcidoX
KWo
AMX Mod X Beta Tester
Join Date: Jul 2004
Location: Poland
Old 09-26-2009 , 15:55   Re: CSDM spawn vote
Reply With Quote #7

Code:
static cell AMX_NATIVE_CALL csdm_setstyle(AMX *amx, cell *params)
{
	int len;
	char *name = MF_GetAmxString(amx, params[1], 0, &len);

	if (strcmp(name, "none") == 0)
	{
		g_SpawnMethod = -1;
		return 1;
	}

	SpawnMethod *pSpawn = NULL;

	for (size_t i=0; i<g_SpawnMngr.Spawns(); i++)
	{
		pSpawn = g_SpawnMngr.GetSpawn(i);
		if (strcmpi(pSpawn->GetName(), name) == 0)
		{
			g_SpawnMethod = i;
			return 1;
		}
	}

	return 0;
}
The value the function returns is "1" for each defined spawn method, "0" - if the spawn method is not defined. It looks like with that function You can probably somehow modify the spawn method from external plugin (but it needs csdm.inc for compilation), but every map change the method will be changed back to that what You have defined in csdm.cfg.
__________________
The Fullpack of podbot mm V3B22 - 24 apr 2012!!! is available here.
The All-In-One 3.2a package - 02 jun 2013 (AMX X 1.8.2 [with ATAC 3.0.1b , CSDM2.1.3c beta, CM OE 0.6.5, podbot mm V3B22c and mm 1.20) is available here.
The newest Beta V3B23a (rel. 28 august 2018!!!) is available here.
KWo 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 06:38.


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