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

[REQ] Respawn Mod vote at the map beginning


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DIS
Senior Member
Join Date: Jul 2013
Location: Somewhere Here xD
Old 07-25-2013 , 04:20   [REQ] Respawn Mod vote at the map beginning
Reply With Quote #1

Hi,
I just need a simple plugin:-
At the beginning of the map, after round 3 or 4, a vote begins like this:-
[Public Mod] Do you want to enable Respawn Mod?
1- Yes
2- No

If option #1 is the winner, set cvar amx_respawn_on to 1 + server_cmd:- hostname "my server name" (I will edit it). After setting the hostname, server_cmd restart so server will restart to set the hostname
If option #2 is the winner, set cvar amx_respawn_on to 0 (However, it is 0 by default)
And:-
PHP Code:
register_dictionary("mapchooser.txt"
Any help would be appreciated
Thanks

Last edited by DIS; 07-25-2013 at 04:33. Reason: Forgot to say something xD
DIS is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 07-25-2013 , 09:11   Re: [REQ] Respawn Mod vote at the map beginning
Reply With Quote #2

Respawn Mod Vote
PHP Code:
#include <amxmodx>

#define PLUGIN        "Respawn Mod Vote"
#define VERSION        "1.5"
#define AUTHOR        "Shooting King"

new gizRound 0;
new 
gizVoting;
new 
gizVoteMenu;
new 
gizVotes[2];

new 
pcvar_round;
new 
pcvar_voteetime;
new 
pcvar_voterestime;
new 
pcvar_revote;
new 
pcvar_loop;
new 
pcvar_hname;

public 
plugin_init()
{
    
register_pluginPLUGINVERSIONAUTHOR );
    
    
register_logevent("Event_Roundstart"2"1=Round_Start");
    
register_event"TextMsg""ResetValues""a""2&#Game_will_restart_in""2&#Game_Commencing" );    

    
pcvar_round register_cvar"amx_sk_round""3" );
    
pcvar_voteetime register_cvar"amx_sk_vote_endtime""20" );
    
pcvar_voterestime register_cvar"amx_sk_vote_restarttime""10" );
    
pcvar_revote register_cvar"amx_sk_vote_restart""1" );
    
pcvar_loop register_cvar"amx_sk_vote_loop""0" );
    
pcvar_hname register_cvar"amx_sk_sv_name""Shooting King's Pro Server" );
}

public 
Event_Roundstart()
{
    
gizRound++;
    
    if( 
gizRound == get_pcvar_num(pcvar_round))
    {
        
StartVote();
        if(
get_pcvar_num(pcvar_loop))
        {
            
gizRound 0;
        }
    }
}

public 
StartVote()
{
    if( 
gizVoting )
        {
            
client_print0print_chat"There is already a vote going." );
            return 
PLUGIN_HANDLED;
        }
    
    
gizVotes[0] = 0;
    
gizVotes[1] = 0;
    
    
gizVoteMenu menu_create"\r[Public Mod] Do you want to enable Respawn Mod?""menu_handler" );

        
menu_additemgizVoteMenu"Yes""");
        
menu_additemgizVoteMenu"No""");
    
        new 
szPlayers[32], iNumiPlayeri;
        
get_playersszPlayersiNum );

        for( 
0iNumi++ )
        {
            
iPlayer szPlayers[i];
            
menu_displayiPlayergizVoteMenu);
        }
    
    
gizVoting++;

    
set_task(get_pcvar_float(pcvar_voteetime), "EndVote" );
    return 
PLUGIN_HANDLED;
}

public 
menu_handleridmenuitem )
{
        if( 
item == MENU_EXIT || !gizVoting )
        {
        return 
PLUGIN_HANDLED;
        }
    
        
gizVotes[item]++;
    
        new 
szPlayer[33];
        
get_user_name(idszPlayercharsmax(szPlayer));
        
client_print(0print_chat"%s choose %s"szPlayeritem);
    
    return 
PLUGIN_HANDLED;
}

public 
EndVote()
{
    if( 
gizVotes[0] > gizVotes[1] )
    {
        
client_print(0print_chat"Respawn Mod (%d) of votes, Its Enabled"gizVotes[0] );
        
set_cvar_num"amx_respawn_on");
        
        
MsgServerName();
    }
       else if( 
gizVotes[0] < gizVotes[1] )
    {
        
client_print(0print_chat"Respawn Mod is Disabled with (%d) of votes"gizVotes[1] );
        
set_cvar_num"amx_respawn_on");
    }
        else 
    {
        
client_print(0print_chat"The vote tied at %d votes each, Vote will start again in %d seconds"gizVotes[0], get_pcvar_num(pcvar_voterestime) );
        if(
get_pcvar_num(pcvar_revote))
        {
            
set_task(get_pcvar_float(pcvar_voterestime), "StartVote" );
        }
    }
    
        
menu_destroygizVoteMenu );
        
gizVoting 0;
}

public 
MsgServerName()
{
    new 
szHName[64];
    
get_pcvar_string(pcvar_hname szHName64);

    
message_begin(MSG_BROADCASTget_user_msgid("ServerName"));
    
write_string(szHName);
    
message_end();
}

public 
ResetValues()
{
    
gizRound 0;
    
gizVoting 0;
    
gizVoteMenu 0;
    
gizVotes[0] = 0;
    
gizVotes[1] = 0;

Cvars:

Time is Seconds.
amx_sk_round - How many rounds after should the vote start ? Default: 3
amx_sk_vote_endtime - How much time should the vote prolong ? Default: 20
amx_sk_vote_restart - If the vote has been tied, should the vote restart ? Default: 1
amx_sk_vote_restarttime - If the vote has been tied, After how much time should the vote begin ? Default:10
amx_sk_vote_loop - Do you want to loop vote ? If set to 1 the vote loops for every amx_sk_round cvar's rounds. Default: 0
amx_sk_sv_name - What name do you want to set to your server after Respawn Mod is enabled.

Note:

1. Don't forget to change
PHP Code:
amx_sk_sv_name 
or else ..

Attached Files
File Type: sma Get Plugin or Get Source (respm_mod_vote.sma - 434 views - 3.2 KB)
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here

Last edited by Shooting King; 07-27-2013 at 11:39.
Shooting King is offline
DIS
Senior Member
Join Date: Jul 2013
Location: Somewhere Here xD
Old 07-25-2013 , 09:40   Re: [REQ] Respawn Mod vote at the map beginning
Reply With Quote #3

Quote:
Originally Posted by Shooting King View Post
Respawn Mod Vote
PHP Code:
#include <amxmodx>

#define PLUGIN        "Respawn Mod Vote"
#define VERSION        "1.0"
#define AUTHOR        "Shooting King"

#define HOSTNAME    "Shooting's Kings Pro Server"

new gizRound 0;
new 
gizVoting;
new 
gizVoteMenu;
new 
gizVotes[2];

new 
pcvar_round;
new 
pcvar_voteetime;
new 
pcvar_voterestime;
new 
pcvar_revote;
new 
pcvar_loop;
new 
pcvar_restime;

public 
plugin_init()
{
    
register_pluginPLUGINVERSIONAUTHOR );
    
    
register_logevent("Event_Roundstart"2"1=Round_Start");

    
pcvar_round register_cvar"amx_sk_round""3" );
    
pcvar_voteetime register_cvar"amx_sk_vote_endtime""20" );
    
pcvar_voterestime register_cvar"amx_sk_vote_restarttime""10" );
    
pcvar_revote register_cvar"amx_sk_vote_restart""1" );
    
pcvar_loop register_cvar"amx_sk_vote_loop""0" );
    
pcvar_restime register_cvar"amx_sk_sv_restarttime""5" );
}

public 
Event_Roundstart()
{
    
gizRound++;
    
    if( 
gizRound == get_pcvar_num(pcvar_round))
    {
        
StartVote();
        if(
get_pcvar_num(pcvar_loop))
        {
            
gizRound 0;
        }
    }
}

public 
StartVote()
{
    if( 
gizVoting )
        {
            
client_print0print_chat"There is already a vote going." );
            return 
PLUGIN_HANDLED;
        }
    
    
gizVotes[0] = 0;
    
gizVotes[1] = 0;
    
    
gizVoteMenu menu_create"\r[Public Mod] Do you want to enable Respawn Mod?""menu_handler" );

        
menu_additemgizVoteMenu"Yes""");
        
menu_additemgizVoteMenu"No""");
    
        new 
szPlayers[32], iNumiPlayeri;
        
get_playersszPlayersiNum );

        for( 
0iNumi++ )
        {
            
iPlayer szPlayers[i];
            
menu_displayiPlayergizVoteMenu);
        }
    
    
gizVoting++;

    
set_task(get_pcvar_float(pcvar_voteetime), "EndVote" );
        return 
PLUGIN_HANDLED;
}

public 
menu_handleridmenuitem )
{
        if( 
item == MENU_EXIT || !gizVoting )
        {
        return 
PLUGIN_HANDLED;
        }
    
        
gizVotes[item]++;
    
        new 
szPlayer[33];
        
get_user_name(idszPlayercharsmax(szPlayer));
        
client_print(0print_chat"%s choose %s"szPlayeritem);
    
       return 
PLUGIN_HANDLED;
}

public 
EndVote()
{
        if( 
gizVotes[0] > gizVotes[1] )
    {
            
client_print(0print_chat"Respawn Mod (%d) of votes, Its Enabled"gizVotes[0] );
            
set_cvar_num"amx_respawn_on");
        
set_cvar_string"hostname"HOSTNAME );

        
client_print(0print_chat"Server will restart in %d seconds"get_pcvar_float(pcvar_restime));
        
set_task(get_pcvar_float(pcvar_restime), "Restart" );
    }
       else if( 
gizVotes[0] < gizVotes[1] )
    {
            
client_print(0print_chat"Respawn Mod is Disabled with (%d) of votes"gizVotes[1] );
            
set_cvar_num"amx_respawn_on");
    }
        else 
    {
            
client_print(0print_chat"The vote tied at %d votes each, Vote will start again in 10 seconds"gizVotes[0] );
            if(
get_pcvar_num(pcvar_revote))
        {
            
set_task(get_pcvar_float(pcvar_voterestime), "StartVote" );
        }
        }
    
        
menu_destroygizVoteMenu );
        
gizVoting 0;
}

public 
Restart()
{
    
server_cmd"restart" );

Cvars:

Time is Seconds.
amx_sk_round - How many rounds after should the vote start ? Default: 3
amx_sk_vote_endtime - How much time should the vote prolong ? Default: 20
amx_sk_vote_restart - If the vote has been tied, should the vote restart ? Default: 1
amx_sk_vote_restarttime - If the vote has been tied, After how much time should the vote begin ? Default:10
amx_sk_vote_loop - Do you want to loop vote ? If set to 1 the vote loops for every amx_sk_round cvar's rounds. Default: 0
amx_sk_sv_restarttime - For your 'server_cmd("restart")' to exec on server. Default: 5

Note:

1. Don't forget to change
PHP Code:
#define HOSTNAME    "Shooting's Kings Pro Server" 
or else ..
2. PLUGIN IS NOT TESTED THOROUGHLY, IF ANY BUGS EXIST POST HERE.


Thanks man I love your fast answering
EDIT: It doesn't change the hostname I think you didn't do server_cmd to change hostname you used another way. Can you please change it to server_cmd ?
EDIT2: Yes you used set_cvar_string please change it to server_cmd
EDIT3: Also loose indention warning when compiling

Last edited by DIS; 07-25-2013 at 10:04.
DIS is offline
Old 07-25-2013, 12:17
DIS
This message has been deleted by YamiKaitou. Reason: wait 14 days before you bump
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 07-25-2013 , 12:19   Re: [REQ] Respawn Mod vote at the map beginning
Reply With Quote #4

Quote:
Originally Posted by DIS View Post
EDIT2: Yes you used set_cvar_string please change it to server_cmd
UPDATED.
Quote:
Originally Posted by DIS View Post
EDIT3: Also loose indention warning when compiling
Why do you think I have posted code in [php] as well as attached .sma ?? When a code is kept in [php] its tabs will be automatically replaced with 5-6 spaces. So some how loose indentation error occurs. If you want the plugin download .sma and compile it. The [php] is only for reading and preview purpose.
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here

Last edited by Shooting King; 07-25-2013 at 12:20.
Shooting King is offline
DIS
Senior Member
Join Date: Jul 2013
Location: Somewhere Here xD
Old 07-25-2013 , 12:30   Re: [REQ] Respawn Mod vote at the map beginning
Reply With Quote #5

Quote:
Originally Posted by Shooting King View Post
UPDATED.

Why do you think I have posted code in [php] as well as attached .sma ?? When a code is kept in [php] its tabs will be automatically replaced with 5-6 spaces. So some how loose indentation error occurs. If you want the plugin download .sma and compile it. The [php] is only for reading and preview purpose.
Ok thank you very much
EDIT: 2 Problems:
1- Hostname still not changing even with server_cmd and even I replaced %s with my hostname and didn't work
2- (See the attached picture, however, I can replace it with a number in the sma file)
If you're going to fix it, please add amx_gamename "mygamename" command (if the results are yes) please, and if u cant fix hostname, no problem ill do something anyways
Thanks
Attached Thumbnails
Click image for larger version

Name:	o-o.jpg
Views:	97
Size:	60.5 KB
ID:	123160  

Last edited by DIS; 07-26-2013 at 00:38.
DIS is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 07-27-2013 , 11:38   Re: [REQ] Respawn Mod vote at the map beginning
Reply With Quote #6

UPDATED.

I am done with those server_cmds. Directly edited game message "ServerName". Now, No need of restart. And what you have shown in the image is a typo, instead of %f i have written %d although I am not using that now.

When server has restarted, Hostname will be reseted by the name in your server.cfg that why the plugin is not working before.

When you are reporting a bug or an error, write a new post, Don't edit your old post. In that way it will get the author's notice.
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here

Last edited by Shooting King; 07-27-2013 at 11:40.
Shooting King is offline
Reply



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 08:57.


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