Raised This Month: $ Target: $400
 0% 

set_user_godmode for whole T


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iplayz
Junior Member
Join Date: Oct 2011
Old 10-04-2011 , 09:33   set_user_godmode for whole T
Reply With Quote #1

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
iplayz is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-04-2011 , 09:45   Re: set_user_godmode for whole T
Reply With Quote #2

Normally it should work yes..
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
sake
Senior Member
Join Date: Jul 2011
Old 10-04-2011 , 11:56   Re: set_user_godmode for whole T
Reply With Quote #3

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 .
__________________

Last edited by sake; 10-04-2011 at 17:05.
sake is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 10-04-2011 , 15:15   Re: set_user_godmode for whole T
Reply With Quote #4

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.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
sake
Senior Member
Join Date: Jul 2011
Old 10-04-2011 , 17:05   Re: set_user_godmode for whole T
Reply With Quote #5

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);
     }

__________________
sake is offline
Blue Snake.
Member
Join Date: May 2011
Location: Romania
Old 10-06-2011 , 01:25   Re: set_user_godmode for whole T
Reply With Quote #6

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);

Blue Snake. is offline
iplayz
Junior Member
Join Date: Oct 2011
Old 10-06-2011 , 05:40   Re: set_user_godmode for whole T
Reply With Quote #7

Thanks guys! <3
iplayz is offline
sake
Senior Member
Join Date: Jul 2011
Old 10-06-2011 , 12:20   Re: set_user_godmode for whole T
Reply With Quote #8

@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.
__________________
sake is offline
Erox902
Veteran Member
Join Date: Jun 2009
Location: Never Never Land
Old 10-06-2011 , 12:31   Re: set_user_godmode for whole T
Reply With Quote #9

Quote:
Originally Posted by sake View Post
@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. View Post
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.
Erox902 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:42.


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