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

CSGO gravity issue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
UnityBeateR
New Member
Join Date: May 2021
Old 05-29-2021 , 08:37   CSGO gravity issue
Reply With Quote #1

Hi Guys !

I am quite new to the Csgo plugin programming / amending. I am currently trying to amend few bits and pieces in this plugin - https://forums.alliedmods.net/showthread.php?p=2702331. This is because the gravity part of it doesn't seem to be functioning at all for some reason.

So basically how the gravity part was designed -
Code:
float gMultiplierGravitation[ 5 ] = {
	0.0, 0.08, 0.15, 0.2, 0.3
};
It was designed as an array that worked with this part of gMultiplierGravitation -
Code:
if ( gClientInfo[client].mBadges[BADGE_SUPPORT] )
		SetEntityGravity(client, 1.0 - gMultiplierGravitation[gClientInfo[client].mBadges[BADGE_SUPPORT]]);
All of this is defined for player_spawn -
Code:
HookEvent("player_spawn",		ev_PlayerSpawn,		EventHookMode_Post);
To me it looks like this should function without any issues, gets the badge, sets the entitygravity for client with 1.0 - (minus) the amount given per gMUltiplierGravitation.

As this didn't work I am trying to reconstruct it altogether but still without any luck as I am getting no errors and it doesn't work. Here is what I have tried to do, I have scrapped the part with float and created something like this -
Code:
if ( gClientInfo[client].mBadges[BADGE_SUPPORT] == LEVEL_BASIC)
	SetEntityGravity(client, gClientInfo[client] ? 0.92 : 1.0);
else if(gClientInfo[client].mBadges[BADGE_SUPPORT] ==  LEVEL_VETERAN)
	SetEntityGravity(client, gClientInfo[client] ? 0.84 : 1.0);
else if(gClientInfo[client].mBadges[BADGE_SUPPORT] ==  LEVEL_EXPERT)
	SetEntityGravity(client, gClientInfo[client] ? 0.76 : 1.0);
else if(gClientInfo[client].mBadges[BADGE_SUPPORT] ==  LEVEL_PROFESIONAL)
	SetEntityGravity(client, gClientInfo[client] ? 0.68 : 1.0);
To me both of the codes look correct and both of them won't work. What it should be doing is basically looking up what 'BADGE_SUPPORT' player has, if for example they have 'level_veteran' this should change their gravity from 1.0 to 0.84.

Any hints or help would be appreciated as I am really confused as to why this is giving me no errors and still doesn't work. If anyone would manage to figure out what is wrong with the first code or the second one that I created please let me know, I have spend few days on it and can't figure out what is wrong with it

//Edited 01/06 - Had incorrect link to the mod

Last edited by UnityBeateR; 06-01-2021 at 18:56.
UnityBeateR is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 05-31-2021 , 23:35   Re: CSGO gravity issue
Reply With Quote #2

That plugin you show us, can't find source of it any more.
Bacardi is offline
UnityBeateR
New Member
Join Date: May 2021
Old 06-01-2021 , 19:00   Re: CSGO gravity issue
Reply With Quote #3

Quote:
Originally Posted by Bacardi View Post
That plugin you show us, can't find source of it any more.
Sorry Bacardi, I had uploaded incorrect link which brought you to wrong plugin there. I have amended the post to correct URL!
UnityBeateR is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 06-02-2021 , 19:27   Re: CSGO gravity issue
Reply With Quote #4

You could check what you get before gravity thing.

Somewhere line
https://github.com/Qesik/bf2-mod/blo...eField.sp#L535

PHP Code:
LogAction(-1, -1"gClientInfo[%i].mBadges[BADGE_SUPPORT] = %i"clientgClientInfo[client].mBadges[BADGE_SUPPORT]); 
These logs should appear in ...addons/sourcemod/logs/Lxxxxxx.log
__________________
Do not Private Message @me

Last edited by Bacardi; 06-02-2021 at 19:31.
Bacardi is offline
UnityBeateR
New Member
Join Date: May 2021
Old 06-03-2021 , 03:53   Re: CSGO gravity issue
Reply With Quote #5

Quote:
Originally Posted by Bacardi View Post
You could check what you get before gravity thing.

Somewhere line
https://github.com/Qesik/bf2-mod/blo...eField.sp#L535

PHP Code:
LogAction(-1, -1"gClientInfo[%i].mBadges[BADGE_SUPPORT] = %i"clientgClientInfo[client].mBadges[BADGE_SUPPORT]); 
These logs should appear in ...addons/sourcemod/logs/Lxxxxxx.log
So from the looks of it, it shows correct data as it loaded me with flag of 0, checked client and came back that its set to '4' which is the highest badge that should give me the lowest gravity -

Code:
L 06/03/2021 - 09:50:40: [BattleField.smx] gClientInfo[1].mBadges[BADGE_SUPPORT] = 0
L 06/03/2021 - 09:50:48: [BattleField.smx] gClientInfo[1].mBadges[BADGE_SUPPORT] = 4
L 06/03/2021 - 09:50:48: [BattleField.smx] gClientInfo[1].mBadges[BADGE_SUPPORT] = 4
This is everything it basically printed.
UnityBeateR is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 06-03-2021 , 07:29   Re: CSGO gravity issue
Reply With Quote #6

ok.
- Then there is possibility that another plugin change player gravity.
Maybe better find this plugin first ?

- Or you could "fix" by delay function when player spawn.

PHP Code:
// =============================================================//
//                         ev_PlayerSpawn                            //
//                                                                 //
// =============================================================//
public Action ev_PlayerSpawn(Event hEvent, const char[] eNamebool dontBroadcast)
{
    
int userid hEvent.GetInt("userid");
    
//int client = GetClientOfUserId(userid);
    //
    //if ( !IsValidClient(client) )
    //    return Plugin_Continue;
    
    
CreateTimer(0.1timer_delay_playerspawnuserid);
}

public 
Action timer_delay_playerspawn(Handle timerint userid)
{

    
int client GetClientOfUserId(userid);
    
    if ( !
IsValidClient(client) )
        return 
Plugin_Continue;

    for(
int i 07i++) gClientInfo[client].sKillsRound[i] = 0;
    for(
int i 06i++) gClientInfo[client].sKillsHSRound[i] = 0;

    if ( 
gClientInfo[client].mBadges[BADGE_ASSAULT] )
        
SetEntData(clientFindDataMapInfo(client"m_iHealth"), gHealthValue[gClientInfo[client].mBadges[BADGE_ASSAULT]]);

    if ( 
gClientInfo[client].mBadges[BADGE_SMG] )
        
SetEntPropFloat(clientProp_Send"m_flLaggedMovementValue", (1.0 gMultiplierSpeed[gClientInfo[client].mBadges[BADGE_SMG]]));

    if ( 
gClientInfo[client].mBadges[BADGE_SUPPORT] )
        
SetEntityGravity(client1.0 gMultiplierGravitation[gClientInfo[client].mBadges[BADGE_SUPPORT]]);

    if ( 
gClientInfo[client].mBadges[BADGE_SNIPER] ) {
        if ( 
gClientInfo[client].mBadges[BADGE_EXPLOSIVES] >= LEVEL_EXPERT && GetRandomInt(1, (gClientInfo[client].mBadges[BADGE_SNIPER])) == )
            
GivePlayerItem(client"weapon_awp");
        else if ( 
GetRandomInt(1, (gClientInfo[client].mBadges[BADGE_SNIPER])) == )
            
GivePlayerItem(client"weapon_ssg08");
    }

    if ( 
gClientInfo[client].mBadges[BADGE_EXPLOSIVES] && GetRandomInt(1, (gClientInfo[client].mBadges[BADGE_EXPLOSIVES])) == )
        
GivePlayerItem(client"weapon_hegrenade");

    
BF2_PrintToChat(client"tb info rank"gRankName[gClientInfo[client].Rank], gClientInfo[client].Stats[KILL_ALL]);

    if ( 
gServerData.cVarEnableHUD.IntValue && gClientInfo[client].TimerHUD == null )
        
gClientInfo[client].TimerHUD CreateTimer(2.0Timer_ShowHUDGetClientUserId(client), TIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);

    return 
Plugin_Continue;

Bacardi is offline
UnityBeateR
New Member
Join Date: May 2021
Old 06-03-2021 , 14:12   Re: CSGO gravity issue
Reply With Quote #7

Thanks Bacardi, the delay of 0.1s actually did the job so you are right by saying that something was overwriting the gravity that was being set on player spawn. It must be one of basic plugins that I had on the server, I will dig through them to spot which one it could be but this is fully resolved. Thanks again !
UnityBeateR is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 06-03-2021 , 15:22   Re: CSGO gravity issue
Reply With Quote #8

your welcome
Bacardi is offline
Reply


Thread Tools
Display Modes

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 08:10.


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