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

[OB] Change Team Score


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoD-Tony
Veteran Member
Join Date: Jul 2005
Old 04-08-2012 , 09:25   [OB] Change Team Score
Reply With Quote #1

Edit: https://forums.alliedmods.net/showthread.php?t=183257

The SetTeamScore native (m_iScore) allows you to change the score visually, but it doesn't get saved by the engine (as of OB) and will reset to its 'real' value after a round has ended.

Here is one method to change the real value:
Code:
/* Change a team's score by +/- amount of points. */ stock bool:Team_ApplyScore(team, points) {     // A player must exist on the team to modify its score.     new target;     for (new i = 1; i <= MaxClients; i++)     {         if (IsClientInGame(i) && GetClientTeam(i) == team)         {             target = i;             break;         }     }         if (!target)         return false;         // Create entity to modify score.     new entity = CreateEntityByName("game_score");     if (entity == -1)         return false;     decl String:sPoints[12];     IntToString(points, sPoints, sizeof(sPoints));     DispatchKeyValue(entity, "points", sPoints);     DispatchKeyValue(entity, "spawnflags", "3");     if (!DispatchSpawn(entity))         return false;         AcceptEntityInput(entity, "ApplyScore", target);     AcceptEntityInput(entity, "Kill");     return true; } stock bool:Team_SetScore(team, points) {     return Team_ApplyScore(team, points - GetTeamScore(team)); }

I'm sure there is a function that can be called that works better, but this will do for now.
__________________

Last edited by GoD-Tony; 04-20-2012 at 04:16.
GoD-Tony is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-08-2012 , 09:40   Re: [OB] Change Team Score
Reply With Quote #2

hehe, nice.

*dam Tony.
You don't have "ENTERS" on that code... Everything is one line

Last edited by Bacardi; 04-08-2012 at 09:50.
Bacardi is offline
GoD-Tony
Veteran Member
Join Date: Jul 2005
Old 04-08-2012 , 09:49   Re: [OB] Change Team Score
Reply With Quote #3

After further testing it seems like this method works in some cases but not others. Makes it just as unreliable as SetTeamScore.

I'll look into something better.
__________________
GoD-Tony is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-08-2012 , 09:58   Re: [OB] Change Team Score
Reply With Quote #4

Yep, noticed same. cs:s
Bacardi is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 04-08-2012 , 11:12   Re: [OB] Change Team Score
Reply With Quote #5

This is the URL Peace-Maker game me yesterday in IRC - https://developer.valvesoftware.com/wiki/Game_score, but it looks like you don't need it - just here for reference for others
__________________
View my Plugins | Donate
TnTSCS is offline
TheAvengers2
BANNED
Join Date: Jul 2011
Old 04-09-2012 , 03:42   Re: [OB] Change Team Score
Reply With Quote #6

Quote:
Originally Posted by Bacardi View Post
You don't have "ENTERS" on that code... Everything is one line
You can get around that problem by excluding a single character from the top or bottom of the code while selecting and copying. And no, I don't know why this works. I speculate there's something wrong with the websites html or css.

Last edited by TheAvengers2; 04-09-2012 at 03:55.
TheAvengers2 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-09-2012 , 06:22   Re: [OB] Change Team Score
Reply With Quote #7

Quote:
Originally Posted by TheAvengers2 View Post
You can get around that problem by excluding a single character from the top or bottom of the code while selecting and copying....
Ou yea, indeed.
I just "quote" Tony post and change forum post "Editor Mode" not "WYSIWYG"-mode.
Seems we have
[pawn] tags

Code:
public OnPluginStart() { }
Bacardi is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-12-2012 , 17:08   Re: [OB] Change Team Score
Reply With Quote #8

I'm not exactly up to speed when it comes to manipulating entities, but wouldn't it just be easier to write an abstraction script that gets the current game's gamerules entity and calls the appropriate input on it?

For example, for TF2, getting the tf_gamerules entity and calling AddBlueTeamScore:

PHP Code:
new entity FindEntityByClassname(-1"tf_gamerules");
SetVariantInt(1);
AcceptEntityInput(entity"AddBlueTeamScore"); 
Edit: Oh, it's possible that other games don't have named entities for gamerules. I just kinda assumed they did. CS:S does, but I can't find any docs on cs_gamerules and its inputs.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 04-12-2012 at 17:31.
Powerlord 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 02:13.


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