Raised This Month: $ Target: $400
 0% 

Gather plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sebastian Andersson
Junior Member
Join Date: Mar 2005
Old 03-29-2005 , 16:57   Gather plugin
Reply With Quote #1

Hello!

I am in the making of writing a gather plugin. I know C pretty well, and I recently started learning SmallC. I have written a bit of the gather plugin, but I am not sure if the current code is correct and how to proceed with the remaining tasks. All and any help will be much appreciated.

These are the tasks that the plugin should do.

* Firstly, a player with any access needs to call the function by typing "amx_gather" in the console.
* The plugin should then do nothing but wait for 10 players to join the server. If there already are 10 players on the server or when the player counter has reached 10, the plugin should then do a map vote to decide what map to play during the gather.
* If the wanted map is the current map, no change should be made. Otherwise, the plugin should change to the wanted map.
* Once the map has been decided, all players needs to type "ready" in the public chat (or the console).
* Once all 10 players has typed "ready", a match configuration file should be executed and the game should start.
* The plugin needs to monitor the rounds that has been played and temporarily stop the gather once 15 rounds has been played (for the second half).
* Once again, the players needs to type "ready" in the console to make sure that everyone is at the computer by the time the second half should start (to make sure that no one has gone for a drink or toilet ).
* Finally, the plugin should restart the round a couple of times and then announce that the second half is live. Once the second half is finished, it should also be announced that the gather is over.

The code below covers some of these tasks, but not all. There are bugs and missing tasks in the code below, but unfortunately, I am not sure what to do about it. Please point out a code, reference or a suggestion.

Note: Anyone is welcome to write some code for or with me as I am a newbie with SmallC and AMX Mod X plugin programming in general (this is my first attempt to develop a plugin), but if you do, please give a brief description of what the code you wrote does, so I learn.

Code:
/*
 * Gather plugin
 * by Sebastian "Seb" Andersson
 */

#include <amxmodx>
#include <amxmisc>

new rounds=0
new match=0 // 0=not running,1=first half,2=2nd half
new pplready
new pplhaveready[33]

public counter(id) {
if(pplhaveready[id]==1) {
client_print(id,print_chat,"* [Gather] You have already typed ^"ready^".")
return PLUGIN_HANDLED // check if the user already has done "ready"
}
pplready++
pplhaveready[id]=1
return PLUGIN_CONTINUE
}

public user_kick(id,reason[]) {
server_cmd("kick #%d ^"%s^"",get_user_userid(id),reason)
return PLUGIN_CONTINUE
}

public restart_round(time[]) {
server_cmd("sv_restartround %s",time)
return PLUGIN_CONTINUE
}

public client_connect(id) {
if(get_playersnum()==10) {
user_kick(id,"The gather is full")
return PLUGIN_CONTINUE
}
return PLUGIN_HANDLED
}

public client_putinserver(id) {
if(get_playersnum()==10) return PLUGIN_CONTINUE
return PLUGIN_HANDLED
}

public abortgather() {
pplready=0
pplhaveready[]=0
match=0
rounds=0
return PLUGIN_CONTINUE
}

public client_disconnect(id) {
if(!match) return PLUGIN_CONTINUE // gather is not running
new playername[32]
get_user_name(id,playername,31)
client_print(0,print_chat,"* [Gather] %s has left the gather. The gather has been aborted.",playername)
abortgather()
return PLUGIN_HANDLED
}

public game_restart() {
rounds=0
}

public round_end() {
rounds++
}

public live_msg() {
client_print(0,print_chat,"* [Gather] LIVE LIVE LIVE!")
client_print(0,print_chat,"* [Gather] LIVE LIVE LIVE!")
client_print(0,print_chat,"* [Gather] LIVE LIVE LIVE!")
return PLUGIN_CONTINUE
}

public start_firsthalf() {
client_print(0,print_chat,"* [Gather] Type ^"ready^" to indicate that you are ready to play.")
if(pplready<10) return PLUGIN_HANDLED
client_print(0,print_chat,"* [Gather] Starting first half! Get ready!")
set_task(2.0,"restart_round",0,"1",1)
set_task(4.0,"restart_round",0,"1",1)
set_task(6.0,"restart_round",0,"3",1)
set_task(11.0,"live_msg")
pplready=0
match=1
return PLUGIN_CONTINUE
}

public start_secondhalf() {
client_print(0,print_chat,"* [Gather] Type ^"ready^" to indicate that you are ready to play.")
if(pplready<10) return PLUGIN_HANDLED
client_print(0,print_chat,"* [Gather] Starting second half! Get ready!")
set_task(2.0,"restart_round",0,"1",1)
set_task(4.0,"restart_round",0,"1",1)
set_task(6.0,"restart_round",0,"3",1)
set_task(11.0,"live_msg")
pplready=0
match=2
return PLUGIN_CONTINUE
}

public gather() {
if(get_playersnum()<10) return PLUGIN_HANDLED // not enough players on the server
/*if(pplready<10) {
client_print(0,print_chat,"* [Gather] %d players haven't typed ^"ready"^ yet. The gather has been aborted.",10-pplready)
return PLUGIN_HANDLED
}*/
client_print(0,print_chat,"* [Gather] Type ^"votemap <map>^" in your game console to vote for a map to play.")
return 
if(!match) {
start_firsthalf()
return PLUGIN_HANDLED
} else if(match==1) {
start_secondhalf()
return PLUGIN_HANDLED
} else {
client_print(0,print_chat,"* [Gather] The gather is now over.")
return PLUGIN_HANDLED
}

}

public plugin_init() {
register_plugin("Gather plugin","1.0","Sebastian ^"Seb^" Andersson")
register_clcmd("amx_gather","gather",0,"Starts the gather")
register_clcmd("say ready","counter")
register_event("TextMsg","game_restart","a","1=4","2&#Game_C","2&#Game_w")
register_event("SendAudio","round_end","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw")
}
Thanks in advance,

Regards,
Sebastian Andersson
Sebastian Andersson is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 03-29-2005 , 17:00  
Reply With Quote #2

and the sense of "the gather" is?
FeuerSturm is offline
Sebastian Andersson
Junior Member
Join Date: Mar 2005
Old 03-29-2005 , 17:01  
Reply With Quote #3

Quote:
Originally Posted by FireStorm
and the sense of "the gather" is?
I am not sure what you mean by "the sense of the gather"?
Sebastian Andersson is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 03-29-2005 , 17:01  
Reply With Quote #4

what is "the gather"? all it should do is play 15 rounds with 10 players twice?
FeuerSturm is offline
Sebastian Andersson
Junior Member
Join Date: Mar 2005
Old 03-29-2005 , 17:05  
Reply With Quote #5

Quote:
Originally Posted by FireStorm
what is "the gather"? all it should do is play 15 rounds with 10 players twice?
Oh, yeah, that's correct. What you mentioned is basically it, but I would like to add some other features like I stated in the first thread. The game is Counter-Strike by the way.
Sebastian Andersson is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 03-29-2005 , 17:17  
Reply With Quote #6

i know that it's for CS, i just like to understand what you're actually
aiming for with this plugin.

what happens after the two 15 rounds?
sorry, but i really have no clue what this plugin could be usefull
for besides doing nothing if players leave while playing so you
don't have 10 "ready"s anymore for the second half
FeuerSturm is offline
Sebastian Andersson
Junior Member
Join Date: Mar 2005
Old 03-29-2005 , 17:24  
Reply With Quote #7

Quote:
Originally Posted by FireStorm
i know that it's for CS, i just like to understand what you're actually
aiming for with this plugin.
I am aiming for an easy-to-use gather plugin for one of my friends server. We usually gather, and we always have to rely on a configuration file (not as useful as a plugin) or doing the settings and stuff manually. Since I am the programmer among us, they asked me to code a plugin.

Quote:
Originally Posted by FireStorm
what happens after the two 15 rounds?
sorry, but i really have no clue what this plugin could be usefull
for besides doing nothing if players leave while playing so you
don't have 10 "ready"s anymore for the second half
The gather is over after the two 15 rounds (first half and second half). If a player leaves during or before the gather, the plugin should (as in the code) abort the gather and wait for the remaining player(s) to rejoin.

The purpose of this plugin is as described above, provide an easier way to gather together (for me and my friends). We run AMXX and a plugin for a gather is something that we all wanted.
Sebastian Andersson 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 10:03.


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