Raised This Month: $ Target: $400
 0% 

[CS GO] Respawn a Team except alive clients


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pandrow
Junior Member
Join Date: Mar 2016
Old 03-05-2016 , 14:33   [CS GO] Respawn a Team except alive clients
Reply With Quote #1

Hello everyone,

I have been searching for a while now and I could not find anything, so I decided to ask this:

My problem is that I want to respawn every player on the team when someone killed a player of the other team with a headshot using a deagle except himself (and of course except others who are alive), but the round should not be over; this should just be an opportunity to revive your team and bring it back to the game.
But I can't find anything with which I would be able to get all client indexes of a team or how to get clients' indexes outside the event (attacker, victim, assister)
I would use a for loop with a variable which is the size of GetTeamClientCount(attacker) in the death event, then check whether the client is dead and then respawn the client; but how am I able to vary the clients I want to respawn in the loop? Is there any array with the clients/indexes in a certain team I could use?

Thank you for your advice

Yours sincerely,
Pandrow

Last edited by Pandrow; 03-05-2016 at 14:41.
Pandrow is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 03-05-2016 , 14:46   Re: [CS GO] Respawn a Team except alive clients
Reply With Quote #2

Loop through all clients and check which ones are both dead and on the player's team
Miu is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 03-05-2016 , 15:05   Re: [CS GO] Respawn a Team except alive clients
Reply With Quote #3

Something like this?

PHP Code:
for (new 1<= MaxClientsi++)
{
    if(
IsClientInGame(i) && !IsPlayerAlive(i))
    {
        new 
team GetClientTeam(i);
        if(
team == 2)
        {
            
Code...
        }
        if(
team == 3)
        {
            
Code...
        }
    }

__________________
xines is offline
Pandrow
Junior Member
Join Date: Mar 2016
Old 03-05-2016 , 15:23   Re: [CS GO] Respawn a Team except alive clients
Reply With Quote #4

Thanks for helping me that quickly

@Miu
Yeah, but how am I able to do this and get the clients who are on the server/in the team?

Quote:
Originally Posted by xines View Post
Something like this?

PHP Code:
for (new 1<= MaxClientsi++)
{
    if(
IsClientInGame(i) && !IsPlayerAlive(i))
    {
        new 
team GetClientTeam(i);
        if(
team == 2)
        {
            
Code...
        }
        if(
team == 3)
        {
            
Code...
        }
    }

Yeah, kind of, that helped But is the variable "i" really from the type "client"? I thought you must use a number in the brackets of the loop...
Pandrow is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 03-05-2016 , 17:29   Re: [CS GO] Respawn a Team except alive clients
Reply With Quote #5

Quote:
Originally Posted by Pandrow View Post
But is the variable "i" really from the type "client"? I thought you must use a number in the brackets of the loop...
All clients are numbers 1 through MAXPLAYERS/MaxClients, 0 references the server. The for loop essentially iterates through all of these numbers.

Last edited by thecount; 03-05-2016 at 17:31.
thecount is offline
Pandrow
Junior Member
Join Date: Mar 2016
Old 03-06-2016 , 13:53   Re: [CS GO] Respawn a Team except alive clients
Reply With Quote #6

Okay, thanks

But I have got one more problem: I get an error when compiling this: (Error message in the code)

Code:
public void PlayerDeathEvent(Event ev, const char[] name, bool dontBroadcast)
{
	int attacker_id = ev.GetInt("attacker");
	int attacker = GetClientOfUserId(attacker_id);
	
	bool headshot = ev.GetBool("headshot");
	
	if (ev.GetString("weapon") == "weapon_deagle" && headshot) //Error here: number of    arguments does not match definition
         
        //code... (like the one you told me before)

}
I've been experimenting with that, at first i did it like this:

Code:
String weapon = ev.GetString("weapon");
but I also got some errors like "arrays must be indexed" and "type "String" should be "char" in new-style declarations". I thought weapons are strings in the death event like it is said in the event declaration of CS:GO and no arrays/chars? Do I have to check for the indexes?

I am a bit familiar with Java, but not with C++ and SourcePawn, so I am sorry if this is a dumb question :/

Thanks again,
Pandrow

Last edited by Pandrow; 03-06-2016 at 14:01.
Pandrow is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 03-06-2016 , 14:02   Re: [CS GO] Respawn a Team except alive clients
Reply With Quote #7

I'm not familiar with the new syntax too much, but I believe that you need to specify a string to place the event string in. Like
PHP Code:
String test;
ev.GetString("weapon"testsizeof(test)); 
And then you check if it is equal. I also think that you can't compare strings together by an '==', but rather:
PHP Code:
if(StrEqual(test"weapon_deagle"false) && headshot){ 
Where the boolean parameter specifies case sensitivity.

Last edited by thecount; 03-06-2016 at 14:04.
thecount is offline
Pandrow
Junior Member
Join Date: Mar 2016
Old 03-06-2016 , 16:44   Re: [CS GO] Respawn a Team except alive clients
Reply With Quote #8

I tried it, didn't work out for me :/ still got these errors:

PHP Code:
String ev_weapon;                                        //type "String" should be "char" in new-style declarations
    
ev.GetString("weapon"ev_weaponsizeof(ev_weapon));    //argument type mismatch (argument 3) (twice)
    

    
    
if(StrEqual(ev_weapon"weapon_deagle"false) && headshot//argument type mismatch (argument 1) 
But it sounded pretty plausible to me that it would work like this...
Pandrow is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 03-06-2016 , 17:25   Re: [CS GO] Respawn a Team except alive clients
Reply With Quote #9

char ev_weapon[64];
Miu is offline
lingzhidiyu
Senior Member
Join Date: Mar 2014
Old 03-07-2016 , 00:55   Re: [CS GO] Respawn a Team except alive clients
Reply With Quote #10

char ev_weapon[32];
lingzhidiyu 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 08:14.


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