Raised This Month: $344 Target: $400
 86%   Almost there!

pug setup module help with script


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
echocage
Member
Join Date: Oct 2021
Old 08-07-2022 , 20:03   pug setup module help with script
Reply With Quote #1

Hello! I have a problem, I'm trying to write a plugin that in !setup will allow me to change sv_airaccelerate to 12 or 145. Please tell me how I can implement this. My current code:

PHP Code:
#include <pugsetup.inc>



public SharedPlugin:__pl_pugsetup =
{
    
name "pugsetup",
    
file "pugsetup.smx",
    
required 1,
};

public 
void:switchaccelerate(int iType)
{
    new 
ConVar:cvar;
    if (
iType == 1)
    {
        if ((
cvar FindConVar("sv_airaccelerate")))
        {
            
//ConVar.SetInt(cvar, 0, true, false);
            
ServerCommand("sv_airaccelerate"12)
            
        }    }
    else
    {
        if (
iType == 2)
        {
            if ((
cvar FindConVar("sv_airaccelerate")))
            {
                
ServerCommand("sv_airaccelerate"145)
            }
        
//PrintToChatAll("sv_airaccelerate changed to %i", iType)
        
}
    }
}


public 
void:OnPluginStart()
{
    
LoadTranslations("pugsetup.phrases");
}

public 
Action:PugSetup_OnSetupMenuOpen(iClientMenu:hMenubool:bDisplayOnly)
{
    
int a[8];
    
a[0] = GetConVarInt(FindConVar("sv_airaccelerate"));
    
    new 
iStyle;
    new 
var1;
    if (
PugSetup_GetGameState() == || PugSetup_HasPermissions(iClient2true) || PugSetup_HasPermissions(iClient3true))
    {
        
iStyle 0;
    }
    else
    {
        
iStyle 1;
    }
    new 
String:szBuffer[1024];
    
    if ((
a[0] == 1))
    {
        
Format(szBuffer256"%T""SwitchToDisableAccelerate"iClient);
        
AddMenuItem(hMenu"disableAccelerate"szBufferiStyle);
    }
    else
    {
        
Format(szBuffer256"%T""SwitchToEnableAccelerate"iClient);
        
AddMenuItem(hMenu"enableAccelerate"szBufferiStyle);
    }
    return 
0;
}

public 
void:PugSetup_OnSetupMenuSelect(Menu menuint client, const char[] selected_infoint selected_position)
{
    if (
StrEqual(selected_info[0], "enableAccelerate"true))
    {
        
switchaccelerate(2);
    }
    else
    {
        if (
StrEqual(selected_info[0], "disableAccelerate"true))
        {
            
switchaccelerate(1);
        }
    }

echocage is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 08-08-2022 , 08:49   Re: pug setup module help with script
Reply With Quote #2

I think you are missing the parameter (e.g %d) in ServerCommand.

PHP Code:
ServerCommand("sv_airaccelerate %d"intValue); 
Also as I mentioned before

This doesn't make sense:

PHP Code:
    int a[8];
    
a[0] = GetConVarInt(FindConVar("sv_airaccelerate")); 
should be

PHP Code:
int a;
GetConVarInt(FindConVar("sv_airaccelerate")); 
No reason to use array in this example.


Try using new syntax, 7+ years later people keep writing plugins in old syntax.
__________________

Last edited by Marttt; 08-08-2022 at 08:53.
Marttt is offline
oqyh
Senior Member
Join Date: May 2019
Location: United Arab Emirates
Old 08-08-2022 , 09:55   Re: pug setup module help with script
Reply With Quote #3

i think ur code decompiled

test this not tested


Code:
#include <pugsetup.inc>



public SharedPlugin:__pl_pugsetup =
{
    name = "pugsetup",
    file = "pugsetup.smx",
    required = 1,
};

public void switchaccelerate(int iType)
{
    if (iType == 1)
    {
		ServerCommand("sv_airaccelerate 12");
	}
    else
    {
        if (iType == 2)
        {
            ServerCommand("sv_airaccelerate 145");
        }
    }
}


public void OnPluginStart()
{
    LoadTranslations("pugsetup.phrases");
}

public Action PugSetup_OnSetupMenuOpen(iClient, Menu:hMenu, bool:bDisplayOnly)
{
    int a[8];
    a[0] = GetConVarInt(FindConVar("sv_airaccelerate"));
    
    new iStyle;
    if (PugSetup_GetGameState() == 0 || PugSetup_HasPermissions(iClient, 2, true) || PugSetup_HasPermissions(iClient, 3, true))
    {
        iStyle = 0;
    }
    else
    {
        iStyle = 1;
    }
    new String:szBuffer[1024];
    
    if ((a[0] == 1))
    {
        Format(szBuffer, 256, "%T", "SwitchToDisableAccelerate", iClient);
        AddMenuItem(hMenu, "disableAccelerate", szBuffer, iStyle);
    }
    else
    {
        Format(szBuffer, 256, "%T", "SwitchToEnableAccelerate", iClient);
        AddMenuItem(hMenu, "enableAccelerate", szBuffer, iStyle);
    }
    return Plugin_Handled;
}

public void PugSetup_OnSetupMenuSelect(Menu menu, int client, const char[] selected_info, int selected_position)
{
    if (StrEqual(selected_info[0], "enableAccelerate", true))
    {
        switchaccelerate(2);
    }
    else
    {
        if (StrEqual(selected_info[0], "disableAccelerate", true))
        {
            switchaccelerate(1);
        }
    }
}
__________________
.:[ >> My Plugins << ]:.

My discord : Gold KingZ#1337
oqyh is online now
echocage
Member
Join Date: Oct 2021
Old 08-08-2022 , 10:07   Re: pug setup module help with script
Reply With Quote #4

Thank you! But as when switching the sourcemod menu item, I should not have the menu disappear
echocage 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 02:12.


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