AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [OB] Change Team Score (https://forums.alliedmods.net/showthread.php?t=182290)

GoD-Tony 04-08-2012 09:25

[OB] Change Team Score
 
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.

Bacardi 04-08-2012 09:40

Re: [OB] Change Team Score
 
hehe, nice.

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

GoD-Tony 04-08-2012 09:49

Re: [OB] Change Team Score
 
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.

Bacardi 04-08-2012 09:58

Re: [OB] Change Team Score
 
Yep, noticed same. cs:s

TnTSCS 04-08-2012 11:12

Re: [OB] Change Team Score
 
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 :)

TheAvengers2 04-09-2012 03:42

Re: [OB] Change Team Score
 
Quote:

Originally Posted by Bacardi (Post 1684463)
You don't have "ENTERS" on that code... Everything is one line :3

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. :grrr:

Bacardi 04-09-2012 06:22

Re: [OB] Change Team Score
 
Quote:

Originally Posted by TheAvengers2 (Post 1685068)
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 :P

Code:
public OnPluginStart() { }

Powerlord 04-12-2012 17:08

Re: [OB] Change Team Score
 
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.


All times are GMT -4. The time now is 18:35.

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