AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   CSDM spawn vote (https://forums.alliedmods.net/showthread.php?t=104446)

AcidoX 09-23-2009 14:37

CSDM spawn vote
 
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?

biscuit628 09-23-2009 15:10

Re: CSDM spawn vote
 
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
    
}



AcidoX 09-23-2009 19:29

Re: CSDM spawn vote
 
How to enable/disable CSDM spawns thru amxx?

AcidoX 09-24-2009 10:40

Re: CSDM spawn vote
 
Well, i have a problem :D 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
    }
}


KWo 09-25-2009 03:11

Re: CSDM spawn vote
 
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.

AcidoX 09-25-2009 05:40

Re: CSDM spawn vote
 
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 ?

KWo 09-26-2009 15:55

Re: CSDM spawn vote
 
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.


All times are GMT -4. The time now is 03:41.

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