Day of Defeat End of Round Team Swap
by gunsofnavarone · 2009-01-21 · 12 replies · 4947 views · 11 downloads
From the first post
rn
rnhttp://djeyl.net/forum/index.php?showtopic=24909
rn
rnThe reason why I desire this plugin is specific for a map which I created for DoD. It is a camp assault map whereas the allies simulate liberating captive allies (pows: designated by allied models) in a barracks. The map is designed that the capture point cannot be captured by the axis and can only be captured by the allies. The allies have 10 minutes to achieve it's objective. If the allies fail, the points and victory go to the axis.
rn
rnThe design of the map is to foster teamwork. But, what I have noticed is people tend to go into "CS-mode" whereas they strike out to obtain kills rather than maintain a defensive posture within the camp/compound area to fend off the assault.
rn
rnThis leads me to where I am requesting this plugin. I hope that by giving each player the opportunity to swap sides, they too can have their chance to get their kills as a means to obtain the objective requirement of the map and not have to sit throughout the whole game after each round of essentially camping.
rn
rnI am striving as I stated to foster teamwork in the map and keep true, as best as I can the difference that DoD is supposed to bring to gaming a opposed to what CS offers. Namely, objective (goal) oriented gaming.
rn
rnSo, can anybody help me with this?
The thread
All 13 posts from 6 people on Day of Defeat End of Round Team Swap, kept as they were written.
Threads: 28
Joined: Sep 2008
As the title indicates, I am looking for a plugin which would switch allies to axis and axis to allies once the round has ended. I found a plugin written for Counterstrike which supposedly does this, but I know nothing about scripting and so I cannot modify it's code to accomplish my needs. This is the link where I found the plugin: rnrnhttp://djeyl.net/forum/index.php?showtopic=24909rnrnThe reason why I desire this plugin is specific for a map which I created for DoD. It is a camp assault map whereas the allies simulate liberating captive allies (pows: designated by allied models) in a barracks. The map is designed that the capture point cannot be captured by the axis and can only be captured by the allies. The allies have 10 minutes to achieve it's objective. If the allies fail, the points and victory go to the axis.rnrnThe design of the map is to foster teamwork. But, what I have noticed is people tend to go into "CS-mode" whereas they strike out to obtain kills rather than maintain a defensive posture within the camp/compound area to fend off the assault.rnrnThis leads me to where I am requesting this plugin. I hope that by giving each player the opportunity to swap sides, they too can have their chance to get their kills as a means to obtain the objective requirement of the map and not have to sit throughout the whole game after each round of essentially camping.rnrnI am striving as I stated to foster teamwork in the map and keep true, as best as I can the difference that DoD is supposed to bring to gaming a opposed to what CS offers. Namely, objective (goal) oriented gaming.rnrnSo, can anybody help me with this?
Threads: 28
Joined: Sep 2008
One other note, though this request is for 1 map in specific which I created, with the ability to turn-off plugins (thanks for your previous help in this area) on a specified map, it would be a useful tool for existing maps and hopefully the creation of other maps in the future.rnrnIn advance, thank you for your help.
Threads: 28
Joined: Sep 2008
A friend of mine who frequents these forums answered the call for this plugin. His name is Beek, and is new to scripting.rnrnHe gave me permission to share the code with the rest of the community, so here it is:rnrn#include <amxmodx>rn#include <amxmisc>rn#include <dodfun>rn#include <dodx>rnrn
rnrnnew team_swap_enabled_varrnrnrnpublic plugin_init() {rn register_plugin("Team Swap", "2.0", "Beek")rn register_concmd("amx_team_swap","team_swap",ADMIN_LEVEL_A,"Team Swap")rn register_event("RoundState", "auto_team_swap", "a", "1=3", "1=4", "1=5")rn team_swap_enabled_var = register_cvar("team_swap_enabled", "1")rn}rnrnpublic team_swap(id,level,cid)rn{rn if (!cmd_access(id,level,cid,0))rn return PLUGIN_HANDLEDrn rn new tclassrn new player[32], countrn get_players(player,count,"c") rn if (count==0)rn { rn //Nobodyrn return PLUGIN_HANDLED rn } rn for(new a=0;a<count;++a)rn {rn if (get_user_team (player[a])==1)rn {rn tclass= dod_get_user_class(player[a])rn dod_set_user_team (player[a], 2,1)rn if (tclass==1) rn dod_set_user_class(player[a],10)rn else if (tclass==2)rn dod_set_user_class(player[a],11)rn else if (tclass==3)rn dod_set_user_class(player[a],12) rn else if (tclass==4)rn dod_set_user_class(player[a],12)rn else if (tclass==5)rn dod_set_user_class(player[a],14) rn else if (tclass==6)rn dod_set_user_class(player[a],13) rn else if (tclass==7)rn dod_set_user_class(player[a],18) rn else if (tclass==8)rn dod_set_user_class(player[a],19)rn }rn else if(get_user_team (player[a])==2)rn {rn tclass= dod_get_user_class(player[a])rn dod_set_user_team (player[a], 1,1)rn if (tclass==10) rn dod_set_user_class(player[a],1)rn else if (tclass==11)rn dod_set_user_class(player[a],2)rn else if (tclass==12)rn dod_set_user_class(player[a],3) rn else if (tclass==14)rn dod_set_user_class(player[a],5) rn else if (tclass==13)rn dod_set_user_class(player[a],6) rn else if (tclass==18)rn dod_set_user_class(player[a],7) rn else if (tclass==19)rn dod_set_user_class(player[a],8)rn }rn }rn}rnrnpublic auto_team_swap(id,level,cid)rn{rn if (get_pcvar_num(team_swap_enabled_var)==1)rn {rn new tclassrn new player[32], countrn get_players(player,count,"c") rn if (count==0)rn { rn //Nobodyrn return PLUGIN_HANDLED rn } rn for(new a=0;a<count;++a)rn {rn if (get_user_team (player[a])==1)rn {rn tclass= dod_get_user_class(player[a])rn dod_set_user_team (player[a], 2,1)rn if (tclass==1) rn dod_set_user_class(player[a],10)rn else if (tclass==2)rn dod_set_user_class(player[a],11)rn else if (tclass==3)rn dod_set_user_class(player[a],12) rn else if (tclass==4)rn dod_set_user_class(player[a],12)rn else if (tclass==5)rn dod_set_user_class(player[a],14) rn else if (tclass==6)rn dod_set_user_class(player[a],13) rn else if (tclass==7)rn dod_set_user_class(player[a],18) rn else if (tclass==8)rn dod_set_user_class(player[a],19)rn }rn else if(get_user_team (player[a])==2)rn {rn tclass= dod_get_user_class(player[a])rn dod_set_user_team (player[a], 1,1)rn if (tclass==10) rn dod_set_user_class(player[a],1)rn else if (tclass==11)rn dod_set_user_class(player[a],2)rn else if (tclass==12)rn dod_set_user_class(player[a],3) rn else if (tclass==14)rn dod_set_user_class(player[a],5) rn else if (tclass==13)rn dod_set_user_class(player[a],6) rn else if (tclass==18)rn dod_set_user_class(player[a],7) rn else if (tclass==19)rn dod_set_user_class(player[a],8) rn }rn }rn }rn elsern {rn //nothingrn }rn}rnrnThis plugin is effective for allies and axis, and there is no coding for british soldiers. The reason for this is that when a player changes team, it is coded to maintain the class they had prior to the change. With the British soldiers there is a "mismatch" if you will on the number of classes available, and thus created a problem where to put some of them when the change occurred.rnrnIf used on a British map though, a player would start out random and like normal, they can select the class they desire and thus upon their next respawn, they will have the weapon they desire.Threads: 28
Joined: Sep 2008
My apologies, the includes indicated above the "coding" should be included as part of the coding.rnrnAlso, if there are those who have some input to improve the coding without sacrificing the functionality, he welcomes any assistance in that area.
Threads: 75
Joined: Nov 2007
you should attach the sma file. This plugin handles the classes in another way, it might be better idk https://www.dodplugins.net/forums/showthread.php?t=608&highlight=swap
Threads: 59
Joined: Jan 2007
I noticed he used the "if-then-else" statement a lot. Perhaps the following piece of text found at http://wiki.amxmodx.org/Optimizing_Plugins_%28AMX_Mod_X_Scripting%29#Switch_instead_of_Ifrnrn
Switch instead of IfrnIf you can, you should use switch cases instead of if. This is because for an if statement, the compiler must branch to each consecutive if case. Using the example from above, observe the switch version: rnrnnew team = get_user_team(player)rnswitch (team)rn{rn case TEAM_T:rn //code...rn case TEAM_CT:rn //code...rn case TEAM_SPECTATOR:rn //code...rn}This will generate what's called a "case table". Rather than worm through displaced if tests, the compiler generates a table of possible values, which the virtual machine knows to browse through: rnrn CALL get_user_teamrn COMPARErn COMPARErn COMPARErn
Threads: 75
Joined: Nov 2007
lol u dont think he should remove thernrn
elsern {rn //nothingrn }rn}rnrnand the ==1 's things before using cases? :D
Threads: 23
Joined: Aug 2007
I've seen maps that do this,dod_rital and dod_bloodhill2. I'll have to look at the .bsp to find out how. Anybody got the down and dirty on how its done?
Threads: 28
Joined: Sep 2008
As requestedhere are the files. Sorry for the delay.
Threads: 59
Joined: Jan 2007
Don't include the *.amxx file, this forum will generate it's own compiled amxx file.nnAlso perhaps you or your friend wants to have a small go at the plugin to clean it up a bit.nn
if (count==0)n { n //Nobodyn return PLUGIN_HANDLED n } nIf an IF-statement only has one line of code, there is no need to put in { and }. Like this:nnnif (count==0)n return PLUGIN_HANDLED // nobodynnnif (get_user_team (player[a])==1)n {n tclass= dod_get_user_class(player[a])n dod_set_user_team (player[a], 2,1)n if (tclass==1) n dod_set_user_class(player[a],10)n else if (tclass==2)n dod_set_user_class(player[a],11)n else if (tclass==3)n dod_set_user_class(player[a],12) n else if (tclass==4)n dod_set_user_class(player[a],12)n else if (tclass==5)n dod_set_user_class(player[a],14) n else if (tclass==6)n dod_set_user_class(player[a],13) n else if (tclass==7)n dod_set_user_class(player[a],18) n else if (tclass==8)n dod_set_user_class(player[a],19)n }nnIm not sure, have been out of coding for a while due to server issues of my own. However I believe it goes something like this, if this is wrong, some please correct mennnif (get_user_team (player[a])==1)n {n tclass = dod_get_user_class(player[a])n dod_set_user_team (player[a], 2,1)n switch (tclass)n {n case 0: n dod_set_user_class(player[a],10)n case 1:n dod_set_user_class(player[a],11)n case 2:n dod_set_user_class(player[a],12)n case 3:n dod_set_user_class(player[a],13)n case 4:n dod_set_user_class(player[a],14)n case 5:n dod_set_user_class(player[a],15)n case 6:n dod_set_user_class(player[a],16)n case 7:n dod_set_user_class(player[a],17)n case 8:n dod_set_user_class(player[a],18)n etc.n etc.nnOk, someone really should look at my addition on the switch statement cause Im not quite sure...lets just say its earlyThreads: 103
Joined: May 2005
the original if statements dont have a tclass==0 so you start with case 1: not case 0:nn
nif (get_user_team (player[a])==1)n {n tclass = dod_get_user_class(player[a])n dod_set_user_team (player[a], 2,1)n switch (tclass)n {n case 1: dod_set_user_class(player[a],10)n case 2: dod_set_user_class(player[a],11)n case 3: dod_set_user_class(player[a],12)n case 4: dod_set_user_class(player[a],12)n case 5: dod_set_user_class(player[a],14)n case 6: dod_set_user_class(player[a],13)n case 7: dod_set_user_class(player[a],18)n case 8: dod_set_user_class(player[a],19)n etc.n etc.nnand if tclass isnt used anywhere else.. you could just use the switch to set tclass to whatever value, then have just one dod_set_user_class after the switchThreads: 26
Joined: Nov 2005
Any mores news on this, i'm interested in each team swapping spawns automatically on round end.rnrnIt's a real bitch being an allie running uphill all the time on avalanche! :)
Threads: 28
Joined: Sep 2008
Ba5ic, as far as functionality is concerned, the plugin works for Axis and Allies as written. So, it should be fine for Avalanche. There are no built-in definitions if you will, for British. The ongoing discussion at this point is optimizing/cleaning up the code.rnrnI cannot speak for the author of the plugin as to whether or not he intends to do anymore on it. He does come in here periodically, so in that area I leave it up to him. I personally don't know anything about coding, so I'm out on this.rnrnIf you intend to use it as I do on a per map basis, follow the discussions on the subject that I initiated a short time ago at https://www.dodplugins.net/forums/showthread.php?t=1456 as this put me on the right track for using plugins in the same way.

