Raised This Month: $51 Target: $400
 12% 

Two questions in regards to CS:GO coding


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mythikos
Junior Member
Join Date: Sep 2014
Old 09-08-2014 , 21:09   Two questions in regards to CS:GO coding
Reply With Quote #1

I am creating a script for CS:GO and there is two functional things I can not work out.

1) Is there a way to detect how many players are still alive during a round? And if there is, is there a way to hook an event or a function to the amount of remaining players? In example, if there are ten players - when two are remaining I want to do something special. Is this possible and if so how?

2) Is there a way to reveal the radar after it has been hidden? In my code I am using

Code:
#define HIDEHUD_RADAR 1 << 12 

public OnClientPutInServer(client) {
	SDKHook(client, SDKHook_Spawn, OnPlayerSpawn);
}

public Action:OnPlayerSpawn(client) {
	// Hide the players radar
	CreateTimer(0.0, RemoveHUDElements, client);
}

// Remove hud elements
public Action:HideRadar(Handle:timer, any:client) {
	// Radar
	SetEntProp(client, Prop_Send, "m_iHideHUD", HIDEHUD_RADAR);
}
I want to be able to trigger the radar to re-appear when a function is called to do so. How might I go about doing that?


Thanks for any help in advanced, I really appreciate it. Im new to sourcepawn and I am unsure where documentation is for me to find things like this. Thanks!

Last edited by Mythikos; 09-08-2014 at 21:10.
Mythikos is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 09-08-2014 , 23:31   Re: Two questions in regards to CS:GO coding
Reply With Quote #2

SourceMod Scripting Wiki

For detecting how many players are alive, use the player_death event and check how many players are alive. If the number of alive players matches your criteria, do something.

PHP Code:
// begin player_death event
new aliveCount;
for (new 
1<= MaxClientsi++)
{
    if (
IsClientInGame(i) && IsPlayerAlive(i))
    {
        
aliveCount++;
    }
}
if (
aliveCount == YourCriteria)
{
    
// Do something here
}
// Continue or end player_death event 
__________________
View my Plugins | Donate

Last edited by TnTSCS; 09-08-2014 at 23:32.
TnTSCS is offline
Mythikos
Junior Member
Join Date: Sep 2014
Old 09-10-2014 , 23:31   Re: Two questions in regards to CS:GO coding
Reply With Quote #3

Very helpful TnTSCS. Ill try that out. Any chance you know how to re-reveal the radar as well
Mythikos is offline
h3bus
AlliedModders Donor
Join Date: Nov 2013
Old 09-11-2014 , 03:19   Re: Two questions in regards to CS:GO coding
Reply With Quote #4

For radar, i would try
Code:
SetEntProp(client, Prop_Send, "m_iHideHUD", 0);
but I guess you already did.
h3bus 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 23:07.


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