AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Block jointeam T but allow CT and SPEC (https://forums.alliedmods.net/showthread.php?t=318703)

MihailoZ 09-15-2019 17:16

Block jointeam T but allow CT and SPEC
 
Hello,

is it possible to block joining Terrorists but allow joining CT and SPEC?

Thanks.

LearninG 09-15-2019 18:09

Re: Block jointeam T but allow CT and SPEC
 
Auto join also blocked :
Code:
#include <amxmodx> public plugin_init() {     register_clcmd("jointeam", "join_team") } public join_team(id) {     new arg[2]     read_argv(1, arg, charsmax(arg))     if ( str_to_num(arg) == 1 || str_to_num(arg) == 5)     {         engclient_cmd(id,"chooseteam")         return PLUGIN_HANDLED     }     return PLUGIN_CONTINUE }

Natsheh 09-16-2019 00:03

Re: Block jointeam T but allow CT and SPEC
 
Quote:

Originally Posted by LearninG (Post 2667096)
Auto join also blocked :
Code:
#include <amxmodx> public plugin_init() {     register_clcmd("jointeam", "join_team") } public join_team(id) {     new arg[2]     read_argv(1, arg, charsmax(arg))     if ( str_to_num(arg)-1 == 0 || str_to_num(arg)-1 == 4)     {         engclient_cmd(id,"chooseteam")         return PLUGIN_HANDLED     }     return PLUGIN_CONTINUE }

Why hard coding stuff ?

Instead of

str_to_num(arg)-1 == 0

Simply str_to_num(arg) == 1

And also this won't block joining team fully.

OP : plugins such like are already exists don't be lazy to search for them.

MihailoZ 09-16-2019 13:09

Re: Block jointeam T but allow CT and SPEC
 
Well, I tried searching forums and google but I was not lucky but I think this plugin works just fine.

MihailoZ 09-16-2019 13:30

Re: Block jointeam T but allow CT and SPEC
 
Quote:

Originally Posted by LearninG (Post 2667096)
Auto join also blocked :
Code:
#include <amxmodx> public plugin_init() {     register_clcmd("jointeam", "join_team") } public join_team(id) {     new arg[2]     read_argv(1, arg, charsmax(arg))     if ( str_to_num(arg)-1 == 0 || str_to_num(arg)-1 == 4)     {         engclient_cmd(id,"chooseteam")         return PLUGIN_HANDLED     }     return PLUGIN_CONTINUE }

Can you explain to me what is what, so I can add some custom code? Thanks.

LearninG 09-16-2019 13:51

Re: Block jointeam T but allow CT and SPEC
 
hooking "jointeam" cmd
Code:
register_clcmd("jointeam", "join_team")
retrieving arguments of client command as string
Code:
new arg[2] read_argv(1, arg , charsmax(arg))
converting string (arg ) to num and checking if it matches with some numbers : (1= Team T , 2= Team CT , 5=Auto join and 6=Team Spectate)
Code:
if ( str_to_num(arg) == 1 || str_to_num(arg) == 5)
showing them chooseteam menu again , and blocking user from joining that team
Code:
engclient_cmd(id,"chooseteam") return PLUGIN_HANDLED
allow joining
Code:
return PLUGIN_CONTINUE

MihailoZ 09-16-2019 14:13

Re: Block jointeam T but allow CT and SPEC
 
Quote:

Originally Posted by LearninG (Post 2667174)
hooking "jointeam" cmd
Code:
register_clcmd("jointeam", "join_team")
retrieving arguments of client command as string
Code:
new arg[2] read_argv(1, arg , charsmax(arg))
converting string (arg ) to num and checking if it matches with some numbers : (1= Team T , 2= Team CT , 5=Auto join and 6=Team Spectate)
Code:
if ( str_to_num(arg) == 1 || str_to_num(arg) == 5)
showing them chooseteam menu again , and blocking user from joining that team
Code:
engclient_cmd(id,"chooseteam") return PLUGIN_HANDLED
allow joining
Code:
return PLUGIN_CONTINUE

This is a bit new for me.

What if I wanted to do this:

IF CT wants to join T; return PLUGIN_HANDLED;
IF CT wants to join CT; return PLUGIN_HANDLED;
IF SPEC wants to join T; return PLUGIN_HANDLED;
IF SPEC wants to join CT; return PLUGIN_CONTINUE;

How would I write this?

LearninG 09-16-2019 14:21

Re: Block jointeam T but allow CT and SPEC
 
Code:
#include <cstrike>
IF CT wants to join T; return PLUGIN_HANDLED;
Code:
if (cs_get_user_team(id) == CS_TEAM_CT && str_to_num(arg) == 1) {     engclient_cmd(id , "chooseteam")     return PLUGIN_HANDLED }
IF CT wants to join CT; return PLUGIN_HANDLED;
Code:
if (cs_get_user_team(id) == CS_TEAM_CT && str_to_num(arg) == 2) {     engclient_cmd(id , "chooseteam")     return PLUGIN_HANDLED }
IF SPEC wants to join T; return PLUGIN_HANDLED;
Code:
if (cs_get_user_team(id) == CS_TEAM_SPECTATOR && str_to_num(arg) == 1) {     engclient_cmd(id , "chooseteam")     return PLUGIN_HANDLED }
IF SPEC wants to join CT; return PLUGIN_CONTINUE;
Code:
if (cs_get_user_team(id) == CS_TEAM_SPECTATOR && str_to_num(arg) == 2) {     return PLUGIN_CONTINUE }
this means "and"
Code:
&&

Natsheh 09-16-2019 14:43

Re: Block jointeam T but allow CT and SPEC
 
Quote:

Originally Posted by MihailoZ (Post 2667169)
Well, I tried searching forums and google but I was not lucky but I think this plugin works just fine.

https://forums.alliedmods.net/showthread.php?t=69819

MihailoZ 09-16-2019 14:56

Re: Block jointeam T but allow CT and SPEC
 
Quote:

Originally Posted by Natsheh (Post 2667189)

That plugin blocks every changeteam try.


All times are GMT -4. The time now is 10:37.

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