AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Method to check last CT (https://forums.alliedmods.net/showthread.php?t=193497)

danielo_o 08-19-2012 20:11

Method to check last CT
 
Anyone knows a method to check the last CT and give him health and armour?
I tried many ways but my server is crashing.:cry:

Backstabnoob 08-19-2012 20:37

Re: Method to check last CT
 
Hook DeathMsg and check the total amount of alive players using get_players. Flags for that function can be found on the wiki.

Alka 08-20-2012 04:59

Re: Method to check last CT
 
Like Backstabnoob said, check this every DeathMsg event
Code:

new iPlayers[33], iNum;
get_players(iPlayers, iNum, "ahe", "CT");

if(iNum == 1) {
    //do something
}


zekStein 08-20-2012 07:01

Re: Method to check last CT
 
Quote:

Originally Posted by Alka (Post 1776839)
Like Backstabnoob said, check this every DeathMsg event
Code:

int iPlayers[33], iNum;
get_players(iPlayers, iNum, "ahe", "CT");

if(iNum == 1) {
    //do something
}


Oh my dear Alka, int ? :))) What times ... what times ...

Alka 08-20-2012 07:03

Re: Method to check last CT
 
Quote:

Originally Posted by zekStein (Post 1776893)
Oh my dear Alka, int ? :))) What times ... what times ...

xD excuse me

jimaway 08-20-2012 09:05

Re: Method to check last CT
 
you should add a global boolean to check if CT already received hp and armor, otherwise last CT will receive health and armour every time he kills a terrorist

hyphen 08-20-2012 09:06

Re: Method to check last CT
 
Just an added note. Hook HLTV event for deathmsg.

And Alka I used to do the same mistakes few times.. int vs new :P

Backstabnoob 08-20-2012 12:44

Re: Method to check last CT
 
Quote:

Originally Posted by jimaway (Post 1776951)
you should add a global boolean to check if CT already received hp and armor, otherwise last CT will receive health and armour every time he kills a terrorist

Can also be done using automatons.

Code:
public EventDeathMsg( ) < not_given_yet > {      //...      if( iNum == 1 )      {           //... give items           state given      } } public EventDeathMsg( ) < given > { } public Round_Start( )      state not_given_yet

Alka 08-20-2012 20:08

Re: Method to check last CT
 
@Backstabnoob - useless? Why give a certain state when you can include the code you want to execute in that if() ...

Backstabnoob 08-21-2012 06:46

Re: Method to check last CT
 
Please read the post I quoted...


All times are GMT -4. The time now is 05:50.

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