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

[CS:GO] Problem with assists manipulation


Post New Thread Reply   
 
Thread Tools Display Modes
StSatan
Senior Member
Join Date: Apr 2010
Old 07-25-2016 , 09:16   Re: [CS:GO] Problem with assists manipulation
Reply With Quote #11

client assists and mvps reset every spawn, so you need to cache the value of you assists by global variable and restore it every player spawn
StSatan is offline
Jcrr
Senior Member
Join Date: Jul 2015
Old 07-25-2016 , 12:54   Re: [CS:GO] Problem with assists manipulation
Reply With Quote #12

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

#pragma semicolon 1

public OnPluginStart()
{
    
HookEvent("player_spawn"OnPlayerSpawnEvent);
}

new 
Int:score[MAXPLAYERS+1] = 0;

public 
Action:OnPlayerSpawnEvent(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
pClient GetClientOfUserId(GetEventInt(event"userid"));

    
PrintToChat(pClient"[DEBUG] SCORE+10");

    
score[pClient] = score[pClient] + 10;
    
CS_SetClientAssists(pClientscore[pClient]);

I got this code, theoretically it should:
OnPlayerSpawnEvent:
Print: [DEBUG] SCORE+10
Take pClient "score", add to it 10
Set client assist's to "score"

On FIRST respawn right after joining into server, assist's are set to 30 (no idea why) and on next spawns, assist's aren't changed at all
Debug message are printed correctly.
__________________

Jcrr is offline
StSatan
Senior Member
Join Date: Apr 2010
Old 07-25-2016 , 20:31   Re: [CS:GO] Problem with assists manipulation
Reply With Quote #13

Code:
#include <sourcemod> #include <sdktools> #include <cstrike> #pragma semicolon 1 int g_iScore[MAXPLAYERS]; public OnPluginStart() {     HookEvent("round_end", OnRoundEnd);     HookEvent("player_spawn", OnPlayerSpawnEvent); } public OnRoundEnd(Handle event, const char[] name, bool dontBroadcast) {     for(int i = 1; i <= MaxClients; ++i)     {         if(!IsClientInGame(i) || GetClientTeam(i) <= CS_TEAM_SPECTATOR)             continue;                     g_iScore[i] = CS_GetClientAssists(i);         g_iScore[i] += 10; // add 10 assists         CS_SetClientAssists(i, g_iScore[i]);         PrintToChat(i, "[DEBUG] OnRoundEnd: ASSISTS=%i", g_iScore[i]);     } } public void OnClientDisconnect(int client) {     g_iScore[client] = 0; } public Action OnPlayerSpawnEvent(Handle event, const char[] name, bool dontBroadcast) {     int client = GetClientOfUserId(GetEventInt(event, "userid"));     if(!client || !IsPlayerAlive(client))         return Plugin_Continue;     CS_SetClientAssists(client, g_iScore[client]);     PrintToChat(client, "[DEBUG] OnPlayerSpawnEvent: ASSISTS=%i", g_iScore[client]);     return Plugin_Continue; }

Maybe you forgot to reset variable when client disconnects, it' should work. Also you need to store it again in a variable every time when it's changed, or only right before client spawn, depends on the gameplay...

You can also store a value right before round start and event death if it is necessary:

Code:
HookEvent("round_prestart", OnRoundPreStart, EventHookMode_Pre); public Action OnRoundPreStart(Handle event, const char[] name, bool dontBroadcast) {     for(int i = 1; i < MAXPLAYERS; i++)     {         if(!IsClientInGame(i))             continue;                 g_iScore[i] = CS_GetClientAssists(i)     } }

Last edited by StSatan; 07-25-2016 at 20:59.
StSatan is offline
Jcrr
Senior Member
Join Date: Jul 2015
Old 07-26-2016 , 08:26   Re: [CS:GO] Problem with assists manipulation
Reply With Quote #14

StSatan
Code is really awesome, and works almost perfectly.
But still there is wired thing about assist's
Little timeline stuff:

First round
Players spawns > g_iScore is 10 | assist's are set to 10 in table | debug message that assist's are 10
Round end OR player die > g_iScore is 10 | assist's are set to 10 in table | debug that assist's are 10

Second round
Player spawns > g_iScore is 20 | assist's are set to 10 in table | debug message that assist's are 20
Round end OR player die > g_iScore is 20 | assist's are set to 20 in table | debug that assist's are 20

On every next round situation looks like in second round:
Player spawns > g_iScore is 20 | assist's are set to 10 in table | debug message that assist's are 20
Round end OR player die > g_iScore is 20 | assist's are set to 20 in table | debug that assist's are 20

If you want to check it out on server just pm me ;)
__________________

Jcrr is offline
StSatan
Senior Member
Join Date: Apr 2010
Old 07-26-2016 , 20:19   Re: [CS:GO] Problem with assists manipulation
Reply With Quote #15

Better to use sdkhook to hook player spawn, because player_spawn event little buggy. I have never use it.

Code:
#include <sourcemod> #include <sdkhooks> #include <cstrike> #pragma semicolon 1 int g_iScore[MAXPLAYERS]; public OnPluginStart() {     HookEvent("round_end", OnRoundEnd);     HookEvent("round_prestart", OnRoundPreStart, EventHookMode_Pre); } public OnRoundEnd(Handle event, const char[] name, bool dontBroadcast) {     for(int i = 1; i <= MaxClients; ++i)     {         if(!IsClientInGame(i) || GetClientTeam(i) <= CS_TEAM_SPECTATOR)             continue;                     g_iScore[i] = CS_GetClientAssists(i);         g_iScore[i] += 10; // add 10 assists         CS_SetClientAssists(i, g_iScore[i]);         PrintToChat(i, "[DEBUG] OnRoundEnd: ASSISTS=%i", g_iScore[i]);     } } public void OnClientPostAdminCheck(int client) {     SDKHook(client, SDKHook_SpawnPost, OnPlayerSpawnPost); } public void OnClientDisconnect(int client) {     g_iScore[client] = 0; } public void OnPlayerSpawnPost(int client) {     if(!IsPlayerAlive(client))         return;     CS_SetClientAssists(client, g_iScore[client]);     PrintToChat(client, "[DEBUG] OnPlayerSpawnEvent: ASSISTS=%i - %i", CS_GetClientAssists(client), g_iScore[client]); } public Action OnRoundPreStart(Handle event, const char[] name, bool dontBroadcast) {     for(int i = 1; i < MAXPLAYERS; i++)     {         if(!IsClientInGame(i))             continue;                 g_iScore[i] = CS_GetClientAssists(i);     } }
StSatan is offline
Jcrr
Senior Member
Join Date: Jul 2015
Old 07-27-2016 , 07:52   Re: [CS:GO] Problem with assists manipulation
Reply With Quote #16

That's works perfectly fine. And since you learn'd me that player_spawn is little buggy and hook player spawn is better, I need to rewrite few of my plugins

Thread can be closed.
__________________

Jcrr is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-27-2016 , 10:38   Re: [CS:GO] Problem with assists manipulation
Reply With Quote #17

The event itself isn't buggy at all. It just happens, that the game code resets the assist count after it fired the game event. You could try to set the assists one frame after player_spawn using RequestFrame.
__________________
Peace-Maker is offline
StSatan
Senior Member
Join Date: Apr 2010
Old 07-28-2016 , 01:49   Re: [CS:GO] Problem with assists manipulation
Reply With Quote #18

Quote:
Originally Posted by Peace-Maker View Post
The event itself isn't buggy at all. It just happens, that the game code resets the assist count after it fired the game event. You could try to set the assists one frame after player_spawn using RequestFrame.
I noticed that it fires with different delay, and use RequestFrame is not solution, because it may fires a little later than necessary and RequestFrame is not needed and all working fine, or it may fires so early that RequestFrame doesn't help

Last edited by StSatan; 07-28-2016 at 01:55.
StSatan is offline
Jcrr
Senior Member
Join Date: Jul 2015
Old 08-01-2016 , 08:36   Re: [CS:GO] Problem with assists manipulation
Reply With Quote #19

Hmm i found something wired too.
I changed it from assist's to score (CS_Set/GetClientContributionScore) and after that, players with manipulated score are not shown in gametracker score table, and even they are not reported to be on server (player is on server but for gametracker, player isn't on server)
__________________

Jcrr 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 00:40.


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