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

SetTeamScore


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
-sang-
BANNED
Join Date: Jun 2009
Location: Russia
Old 01-15-2011 , 17:24   SetTeamScore
Reply With Quote #1

How correctly to use function SetTeamScore(index, value) in CSS?

For example, I do so
PHP Code:
SetTeamScore(210
in the middle of a round

But points change only if I switch team on the opposite.

it is possible to change team points at any time?
-sang- is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 01-15-2011 , 18:32   Re: SetTeamScore
Reply With Quote #2

wiki said: This native should not be called before OnMapStart.

so
go and find CTeam entity
and change prop_send m_iScore
__________________
Leonardo is offline
Andersso
Member
Join Date: Nov 2009
Location: E8 2A 2A 2A 2A
Old 01-15-2011 , 18:39   Re: SetTeamScore
Reply With Quote #3

OnMapStart != middle of a round
Andersso is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-15-2011 , 19:10   Re: SetTeamScore
Reply With Quote #4

It seems Sourcemod doesn't mark the property as changed, bleh.
Use my stocks:

PHP Code:
/*
* Changes a team's score.
* Don't use this before OnMapStart().
*
* @param index            Team Index.
* @param score            Score value.
* @return                True on success, false otherwise
*/
stock bool:Team_SetScore(indexscore)
{
    new 
edict Team_GetEdict(index);
    
    if (
edict == -1) {
        return 
false;
    }

    
SetEntProp(edictProp_Send"m_iScore"score);
    
ChangeEdictState(edictGetEntSendPropOffs(edict"m_iScore"));
    
    return 
true;
}

/*
* Gets a team's edict (team_manager) Team Index.
* Don't call this before OnMapStart()
*
* @param edict            Edict
* @return                Team Index
*/
stock Team_EdictGetNum(edict)
{
    return 
GetEntProp(edictProp_Send"m_iTeamNum");
}

/*
* Gets a team's edict (team_manager)
* Don't call this before OnMapStart()
*
* @param index            Team Index.
* @return                Team edict or -1 if not found
*/
stock Team_GetEdict(index)
{
    new 
maxEntities GetMaxEntities();
    for (new 
entity=MaxClients+1entity maxEntitiesentity++) {
        
        if (!
IsValidEntity(entity)) {
            continue;
        }
        
        if (!
Entity_CheckClassName(entity"team_manager"true)) {
            continue;
        }
        
        if (
Team_EdictGetNum(entity) == index) {
            return 
entity;
        }
    }
    
    return -
1;
}

/*
 * Checks if an entity matches a specific entity class.
 *
 * @param entity        Entity Index.
 * @param class            Classname String.
 * @return                True if the classname matches, false otherwise.
 */
stock bool:Entity_CheckClassName(entity, const String:className[], partialMatch=false)
{
    
decl String:entity_className[64];
    
GetEdictClassname(entityentity_classNamesizeof(entity_className));

    if (
partialMatch) {
        return (
StrContains(entity_classNameclassName) != -1);
    }
    
    return 
StrEqual(entity_classNameclassName);

__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0

Last edited by berni; 01-16-2011 at 20:39. Reason: Updated stocks
berni is offline
-sang-
BANNED
Join Date: Jun 2009
Location: Russia
Old 01-16-2011 , 01:43   Re: SetTeamScore
Reply With Quote #5

Quote:
Originally Posted by berni View Post
It seems Sourcemod doesn't mark the property as changed, bleh.
Use my stocks:

PHP Code:
/*
* Changes a team's score.
* Don't use this before OnMapStart().
*
* @param index            Team Index.
* @param score            Score value.
* @return                True on success, false otherwise
*/
stock bool:Team_SetScore(indexscore)
{
    new 
edict Team_GetEdict(index);
    
    if (
edict == -1) {
        return 
false;
    }

    
SetEntProp(edictProp_Send"m_iScore"score);
    
    return 
true;
}

/*
* Gets a team's edict (team_manager) Team Index.
* Don't call this before OnMapStart()
*
* @param edict            Edict
* @return                Team Index
*/
stock Team_EdictGetNum(edict)
{
    return 
GetEntProp(edictProp_Send"m_iTeamNum");
}

/*
* Gets a team's edict (team_manager)
* Don't call this before OnMapStart()
*
* @param index            Team Index.
* @return                Team edict or -1 if not found
*/
stock Team_GetEdict(index)
{
    new 
team_manager = -1;
    while ((
team_manager FindEntityByClassname(team_manager"team_manager")) != -1) {
        
        if (
Team_EdictGetNum(team_manager) == index) {
            return 
team_manager;
        }
    }
    
    return -
1;

It works just as also a SetTeamScore

Points change only if someone switch team.

and "team_manager" should be "cs_team_manager".


There can be a scoreboard doesn't understand that points have changed and it is necessary to it to prompt it?
-sang- is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-16-2011 , 17:52   Re: SetTeamScore
Reply With Quote #6

Ok, I actually thought SetEntProp marks the property as changed already.
Please re-copy my functions and try again, thx
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
Master53
Veteran Member
Join Date: Dec 2009
Old 01-16-2011 , 19:23   Re: SetTeamScore
Reply With Quote #7

would it be possable to set the player count for each team on the scoreboard? if so how would it be done.
__________________
Master(d)



Master53 is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-16-2011 , 19:46   Re: SetTeamScore
Reply With Quote #8

Not in a simple way, there is no property for that.
Maybe with really dirty extension haxx.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
Master53
Veteran Member
Join Date: Dec 2009
Old 01-16-2011 , 19:56   Re: SetTeamScore
Reply With Quote #9

:/ damn it would be usefull for what i need it for, oh well ill just have to live with it.
__________________
Master(d)



Master53 is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-16-2011 , 20:40   Re: SetTeamScore
Reply With Quote #10

Updated my stocks above again to support all games
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni 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 21:19.


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