Day of Defeat Plugins Community
This site is an archive — everything is readable and downloadable, nothing can be posted. Admin

amx_teams

by Hood [10th MD] · 2007-04-18 · 13 replies · 8999 views · 63 downloads

Read the thread (14 posts)

From the first post

See this thread:
nhttps://www.dodplugins.net/forums/showthread.php?t=763
nFor background on what this plugin is supposed to do...
n
nThis is what I've coded based on our talking Bosta, it is glitchy at best, I'd really like someone to look over it and make some suggestions - basically, we find out if user is alive/not, kill if they are, switch them to the team desired, and set their class (check map info for british/american), then spawn them.
nThe team switch, class switch and respawn are in a task with timer of 0.1 - these respawns sometimes work, sometimes don't - but without them, it's unreliable to just use the reinforcement counter...
nBasically, I need help with the respawning correctly.
n
nAlso, this is something I cannot control or find away around:
nSwitching people into spec works perfectly. Switching people out does not work, and is not supposed to according to dod_set_user_team()'s documentation
n
nAnyone is free to try this out - it doesn't crash my server, but it does not work well. Download the source, and read the comments for the commands:
namx_shift <1/2/3 (allies/axis/spec)> forces all players to a team
namx_spectate
namx_allies
namx_axis
namx_rifle
n
nThe rifle one also works fine it seems, but again no guarantees - someone please review and correct!

Files

amx_teams.sma Plugin Source 7 KB 63 dl Download Compile

The thread

All 14 posts from 5 people on amx_teams, kept as they were written.

H Hood [10th MD]
started this thread
Posts: 84
Threads: 7
Joined: Nov 2006
04-18-2007, 02:20 PM #1

See this thread:nhttps://www.dodplugins.net/forums/showthread.php?t=763nFor background on what this plugin is supposed to do...nnThis is what I've coded based on our talking Bosta, it is glitchy at best, I'd really like someone to look over it and make some suggestions - basically, we find out if user is alive/not, kill if they are, switch them to the team desired, and set their class (check map info for british/american), then spawn them.nThe team switch, class switch and respawn are in a task with timer of 0.1 - these respawns sometimes work, sometimes don't - but without them, it's unreliable to just use the reinforcement counter...nBasically, I need help with the respawning correctly.nnAlso, this is something I cannot control or find away around:nSwitching people into spec works perfectly. Switching people out does not work, and is not supposed to according to dod_set_user_team()'s documentationnnAnyone is free to try this out - it doesn't crash my server, but it does not work well. Download the source, and read the comments for the commands:namx_shift <1/2/3 (allies/axis/spec)> forces all players to a teamnamx_spectate <player>namx_allies <player>namx_axis <player>namx_rifle <player>nnThe rifle one also works fine it seems, but again no guarantees - someone please review and correct!

=|[76AD]|= TatsuSaisei
posted here
Posts: 794
Threads: 54
Joined: May 2005
04-18-2007, 03:58 PM #2
;5192']Basically, I need help with the respawning correctly
n nI will find the post later, but I do remembering reading about this on the AMXX forums, about spawning player entities and having to make the call twice...n n
 npublic respawnAxis(plr)n{ndod_set_user_team(plr, 2, 1)ndod_set_user_class(plr, DODC_KAR)nspawn(plr)nspawn(plr)n}n
nnot tested and not too sure... but the spawning players and reading a post I DO remember..

Wilson [29th ID]
posted here
Posts: 623
Threads: 57
Joined: Oct 2005
04-18-2007, 04:09 PM #3

No, just strip_user_weapons and then use spawn() after and it will work fine.

=|[76AD]|= TatsuSaisei
posted here
Posts: 794
Threads: 54
Joined: May 2005
04-18-2007, 05:21 PM #4
;5194']No, just strip_user_weapons and then use spawn() after and it will work fine.
nnice one !!

H Hood [10th MD]
started this thread
Posts: 84
Threads: 7
Joined: Nov 2006
04-19-2007, 02:40 PM #5

ok, so the strip goes right before the spawn?rnrnThe only trouble is, right now, sometimes they flat out don't spawn...rnLong after the task should've been called to, there's just no spawn, should I strip and double spawn?

=|[76AD]|= TatsuSaisei
posted here
Posts: 794
Threads: 54
Joined: May 2005
04-19-2007, 04:11 PM #6
;5209']ok, so the strip goes right before the spawn?n nThe only trouble is, right now, sometimes they flat out don't spawn...nLong after the task should've been called to, there's just no spawn, should I strip and double spawn?
n n nwell.. locally I had no issue with Wilson's "method" strip then spawn... but as I said... I DO remember reading about some issue involving spawning players and one of the suggestions that still stands out is the double spawn() call...n nIt NEVER hurts to try if you try it locally... and well.. sometime you have to take a crash or two to "learn" why somethig does or not do what you expect... so make it "double" spawn and see what it does... obviously the strip then spawn alone is not enough... OR something else is going on...

H Hood [10th MD]
started this thread
Posts: 84
Threads: 7
Joined: Nov 2006
04-19-2007, 04:25 PM #7

It never seems to reach that, I've tried with double spawn, double spawn and strip, just strip, etc.rnIt never even seems to spawn.rnOnce before, I had gotten it to glitch when it should've spawned, but now it's like it never even hits that task... any reason why?

Wilson [29th ID]
posted here
Posts: 623
Threads: 57
Joined: Oct 2005
04-19-2007, 06:31 PM #8

Post code.rnrnYou do not have to use spawn() twice - i've been using the strip then spawn method for a good year now. Never once failed - not even with one person.

strontiumdog
posted here
Posts: 27
Threads: 6
Joined: Nov 2006
04-20-2007, 12:36 AM #9

dod_set_user_team works fine....and you don't need to swap people into spec....rnrnThis method has never failed for me.....rnrnhttps://www.dodplugins.net/forums/showthread.php?t=608

M MBosta
posted here
Posts: 208
Threads: 30
Joined: Sep 2006
04-20-2007, 12:33 PM #10

yea i just tested this plugin, and it switches you to the right team, but doesn't actually let you spawn. Weird.

H Hood [10th MD]
started this thread
Posts: 84
Threads: 7
Joined: Nov 2006
04-20-2007, 02:43 PM #11

so the code to switch to axis looks like this:rn

public amx_axis(id, level, cid)rn{rn	if(!cmd_access(id, level, cid, 2))rn		return PLUGIN_HANDLEDrn	new Arg1 [32]rn	read_argv(1, Arg1, 31)rn	new player = cmd_target(id, Arg1, 2)rn	if (!player)rn         {rn		console_print(id, "Sorry, player %s could not be found or targetted!", Arg1)rn		return PLUGIN_HANDLEDrn         } rn	else rn	{rn		new plrname[32]rn		get_user_name(player, plrname, 31)rn		client_print(0, print_chat, "Player %s has been forced to Axis.", plrname)rn		if(is_user_alive(player))rn		{rn			dod_user_kill(player)rn		}rn		set_task(0.1, "respawnAxis", player)rn         }rn	return PLUGIN_HANDLEDrn}
rnrnand here's the respawn function code:rnrn
public respawnAxis(plr)rn{rn	dod_set_user_team(plr, 2, 1)rn	dod_set_user_class(plr, DODC_KAR)rn	strip_user_weapons(plr)rn	spawn(plr)rn}
rnrnI think it just never reaches the spawn, but i can't figure out why.

M MBosta
posted here
Posts: 208
Threads: 30
Joined: Sep 2006
04-27-2007, 04:16 PM #12

hey hood, i found the sma you helped me out with. This version actually lets you spawn, but as a random weapon. Also, you can put ppl in spec, but once in spec, you can't shift them to allies.rnrn

/* Plugin generated by AMXX-Studio */rnrn#include <amxmodx>rn#include <amxmisc>rn#include <dodfun>rnrn#define PLUGIN "New Plugin"rn#define VERSION "1.0"rn#define AUTHOR "Author"rnrnrnpublic plugin_init() {rn	rnregister_plugin("Team Shift", "1.0", "Hood [10th MD]")rn	rn	rnregister_concmd("amx_shift", "shift_team", ADMIN_BAN, "<1/2/3 = Allies/Axis/Spec>")rn}rnrnrnpublic shift_team(id, level, cid){rnif(!cmd_access(id, level, cid, 1))rnreturn PLUGIN_HANDLEDrnrnnew teamnumber[1]rnrnread_argv(1, teamnumber, 1)rnrnnew teamNum = str_to_num(teamnumber [0])rnrnnew players[32], numplayers, irnrnrnget_players(players, playersnum)rnrnfor(i=0; i<playersnum; i++) rnrn{ rnif(get_user_team(players[i])!=teamNum)rnrndod_set_user_team(players[i], teamNum)rn}rnrnreturn PLUGIN_HANDLEDrn}rn
H Hood [10th MD]
started this thread
Posts: 84
Threads: 7
Joined: Nov 2006
04-30-2007, 10:29 PM #13

Yes, switching doesn't work on spectators.

M MBosta
posted here
Posts: 208
Threads: 30
Joined: Sep 2006
04-30-2007, 11:32 PM #14

What seemed to be an easy task, turned to be a pain in the ass. This sucks.

DoD Plugins Archive · Repository · Old Forum Threads · Maps · Admin · built 14 Sep 2026 00:34 UTC