Raised This Month: $ Target: $400
 0% 

whats wrong?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
marioluda
New Member
Join Date: Aug 2014
Old 08-02-2014 , 23:56   whats wrong?
Reply With Quote #1

#include <sourcemod>

public Plugin:myinfo =
{
name = "Last Survivors",
author = "Eric",
description = "Last Survivors",
version = SOURCEMOD_VERSION,
url = "http://www.sourcemod.net/"
};

public OnPluginStart()
{
HookEvent("player_death", player_death);

}

public player_death(Handle:event, const String:name[], bool:dontBroadcast)
{
new iCount;
new iTeamNum;
for( new iClient = 1; iClient <= MaxClients; iClient++ )
if( IsClientInGame( iClient ) && GetClientTeam( iClient ) == iTeamNum && IsPlayerAlive( iClient ) )
return iCount;

if(iCount == 4)
{
ServerCommand("sm_beacon @all");

}
return iCount;
}


Im trying to get it so that when 4 players are alive it beacons everyone.
marioluda is offline
sparksterRK
Member
Join Date: Jul 2014
Old 08-03-2014 , 00:47   Re: whats wrong?
Reply With Quote #2

You instantiate iCount and iTeamNum, but you don't actually assign them to anything.
iCount and iTeamNum in your current code always equal 0.
Team numbers are static and never change, so it's easier to do something like
Code:
#define infected_team 3
#define survivor_team 2
#define spectator_team 1
and then do
Code:
if (GetClientTeam(client) == survivor_team) { do: }
and instead of returning the value if iCount when that statement is true, do
Code:
iCount++;

if (iCount == 4) { do: }
sparksterRK is offline
floube
SourceMod Donor
Join Date: Jan 2013
Location: Austria
Old 08-03-2014 , 06:56   Re: whats wrong?
Reply With Quote #3

It looks like you can't fix it yourself since this. Anyway this should work (haven't tested it though):

PHP Code:
#include <sourcemod>

public Plugin:myinfo =
{
    
name "Last Survivors",
    
author "Eric",
    
description "Last Survivors",
    
version SOURCEMOD_VERSION,
    
url "http://www.sourcemod.net/"
};

public 
OnPluginStart()
{
    
HookEvent("player_death"player_death);
}

public 
player_death(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
iCount 0;

    for (new 
iClient 1iClient <= MaxClientsiClient++) {
        if (
IsClientConnected(iClient) && IsClientInGame(iClient) && IsPlayerAlive(iClient)) {
            
iCount++;
        }
    }

    if (
iCount == 4) {
        
ServerCommand("sm_beacon @all");
    }

__________________
floube 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:33.


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