AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   set_user_godmode for whole T (https://forums.alliedmods.net/showthread.php?t=168809)

iplayz 10-04-2011 09:33

set_user_godmode for whole T
 
Im new to scripting and I wonder if by using 0, instead of id would give the WHOLE team instead of just the person using the command
This is what I got now and only gives the person whos using it godmode
Code:

                case 1:
                {
                        if (get_user_team(id) == 2)
                        {
                                set_user_godmode(id, 1)
                                ColorChat(0, RED, "[EventManager]^4 Every CT have received godmode!^3")
                               
                        }
                }

This is what I was thinking what might work:
Code:

                case 1:
                {
                        if (get_user_team(id) == 2)
                        {
                                set_user_godmode(0, 1)
                                ColorChat(0, RED, "[EventManager]^4 Every CT have received godmode!^3")
                               
                        }
                }

Will the second one work, if not please explain and show me how to make the whole CT team godmode:)

Napoleon_be 10-04-2011 09:45

Re: set_user_godmode for whole T
 
Normally it should work yes..

sake 10-04-2011 11:56

Re: set_user_godmode for whole T
 
Sorry, but what?

This won't work and why should it? if you pass 0 as the first argument to set_user_godmode ALL players will be invulnerable if you check for the team first or not.

PHP Code:

new players[32];
new 
playerCounti;
get_players(playersplayerCount);
for (
i=0i<playerCounti++) 
{
   if(
get_user_team(players[i])==2)
     {
         
set_user_godmode(players[i], 1);
     }


That's how it has to be done. An even better way would be to do sth like get_players(players, playerCount, "e=CT") but I don't know if that would work.

http://www.amxmodx.org/doc/index.htm...er_godmode.htm

EDIT:

"We don't really support get_players() with flags anymore. It was a bad idea and if it was our choice, it would have never been added to the original AMX Mod." - BAILOPAN.

Okay the way that's described above is good :).

Xellath 10-04-2011 15:15

Re: set_user_godmode for whole T
 
Above example is correct, but there are optimizations (dont re-index players array) that can be made. Also, cs_get_user_team() is more reliable than get_user_team() in certain cases.

sake 10-04-2011 17:05

Re: set_user_godmode for whole T
 
Ah. Okay. Then it's like this:

PHP Code:

new players[32];
new 
playerCountiplayer;
get_players(playersplayerCount);
for (
i=0i<playerCounti++) 
{
   
player players[i];
   if(
cs_get_user_team(player)==2)
     {
         
set_user_godmode(player1);
     }



Blue Snake. 10-06-2011 01:25

Re: set_user_godmode for whole T
 
PHP Code:

new players[32];
new 
playerCountiplayer;
get_players(playersplayerCount"e""TERRORIST"); /*And for CT: get_players(players, playerCount, "e", "CT");*/
for (i=0i<playerCounti++) 
{
    
player players[i];
    
set_user_godmode(player1);



iplayz 10-06-2011 05:40

Re: set_user_godmode for whole T
 
Thanks guys! <3

sake 10-06-2011 12:20

Re: set_user_godmode for whole T
 
@Blue Snake: Thx for not reading others postings:

Quote:

Originally Posted by Bailopan
"We don't really support get_players() with flags anymore. It was a bad idea and if it was our choice, it would have never been added to the original AMX Mod." - BAILOPAN.


Erox902 10-06-2011 12:31

Re: set_user_godmode for whole T
 
Quote:

Originally Posted by sake (Post 1569541)
@Blue Snake: Thx for not reading others postings:

"Note: "e" flag can return incorrect results (for cstrike/czero at least) when not used with the "a" flag."
It would be kind of stupid to set godmode to dead players anyway.

Quote:

Originally Posted by Blue Snake. (Post 1569254)
PHP Code:

new players[32];
new 
playerCountiplayer;
get_players(playersplayerCount"e""TERRORIST"); /*And for CT: get_players(players, playerCount, "e", "CT");*/
for (i=0i<playerCounti++) 
{
    
player players[i];
    
set_user_godmode(player1);



Just add a "a" to the flags and there won't be any problems.
This will be a much better way if he isn't using cstrike module for anything else.


All times are GMT -4. The time now is 19:32.

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