View Full Version : amx_teams
Hood [10th MD]
04-18-2007, 03:20 PM
See this thread:
http://www.dodplugins.net/forums/showthread.php?t=763
For background on what this plugin is supposed to do...
This 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.
The 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...
Basically, I need help with the respawning correctly.
Also, this is something I cannot control or find away around:
Switching people into spec works perfectly. Switching people out does not work, and is not supposed to according to dod_set_user_team()'s documentation
Anyone 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:
amx_shift <1/2/3 (allies/axis/spec)> forces all players to a team
amx_spectate <player>
amx_allies <player>
amx_axis <player>
amx_rifle <player>
The rifle one also works fine it seems, but again no guarantees - someone please review and correct!
=|[76AD]|= TatsuSaisei
04-18-2007, 04:58 PM
;5192']Basically, I need help with the respawning correctly
I 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...
public respawnAxis(plr)
{
dod_set_user_team(plr, 2, 1)
dod_set_user_class(plr, DODC_KAR)
spawn(plr)
spawn(plr)
}
not tested and not too sure... but the spawning players and reading a post I DO remember..
Wilson [29th ID]
04-18-2007, 05:09 PM
No, just strip_user_weapons and then use spawn() after and it will work fine.
=|[76AD]|= TatsuSaisei
04-18-2007, 06:21 PM
;5194']No, just strip_user_weapons and then use spawn() after and it will work fine.
nice one !!
Hood [10th MD]
04-19-2007, 03:40 PM
ok, so the strip goes right before the spawn?
The only trouble is, right now, sometimes they flat out don't spawn...
Long after the task should've been called to, there's just no spawn, should I strip and double spawn?
=|[76AD]|= TatsuSaisei
04-19-2007, 05:11 PM
;5209']ok, so the strip goes right before the spawn?
The only trouble is, right now, sometimes they flat out don't spawn...
Long after the task should've been called to, there's just no spawn, should I strip and double spawn?
well.. 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...
It 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...
Hood [10th MD]
04-19-2007, 05:25 PM
It never seems to reach that, I've tried with double spawn, double spawn and strip, just strip, etc.
It never even seems to spawn.
Once 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]
04-19-2007, 07:31 PM
Post code.
You 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
04-20-2007, 01:36 AM
dod_set_user_team works fine....and you don't need to swap people into spec....
This method has never failed for me.....
http://www.dodplugins.net/forums/showthread.php?t=608
MBosta
04-20-2007, 01:33 PM
yea i just tested this plugin, and it switches you to the right team, but doesn't actually let you spawn. Weird.
Hood [10th MD]
04-20-2007, 03:43 PM
so the code to switch to axis looks like this:
public amx_axis(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new Arg1 [32]
read_argv(1, Arg1, 31)
new player = cmd_target(id, Arg1, 2)
if (!player)
{
console_print(id, "Sorry, player %s could not be found or targetted!", Arg1)
return PLUGIN_HANDLED
}
else
{
new plrname[32]
get_user_name(player, plrname, 31)
client_print(0, print_chat, "Player %s has been forced to Axis.", plrname)
if(is_user_alive(player))
{
dod_user_kill(player)
}
set_task(0.1, "respawnAxis", player)
}
return PLUGIN_HANDLED
}
and here's the respawn function code:
public respawnAxis(plr)
{
dod_set_user_team(plr, 2, 1)
dod_set_user_class(plr, DODC_KAR)
strip_user_weapons(plr)
spawn(plr)
}
I think it just never reaches the spawn, but i can't figure out why.
MBosta
04-27-2007, 05:16 PM
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.
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <dodfun>
#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"
public plugin_init() {
register_plugin("Team Shift", "1.0", "Hood [10th MD]")
register_concmd("amx_shift", "shift_team", ADMIN_BAN, "<1/2/3 = Allies/Axis/Spec>")
}
public shift_team(id, level, cid){
if(!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new teamnumber[1]
read_argv(1, teamnumber, 1)
new teamNum = str_to_num(teamnumber [0])
new players[32], numplayers, i
get_players(players, playersnum)
for(i=0; i<playersnum; i++)
{
if(get_user_team(players[i])!=teamNum)
dod_set_user_team(players[i], teamNum)
}
return PLUGIN_HANDLED
}
Hood [10th MD]
04-30-2007, 11:29 PM
Yes, switching doesn't work on spectators.
MBosta
05-01-2007, 12:32 AM
What seemed to be an easy task, turned to be a pain in the ass. This sucks.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.