Raised This Month: $ Target: $400
 0% 

help my code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Unkown_name
Junior Member
Join Date: Jan 2022
Old 02-11-2023 , 15:35   help my code
Reply With Quote #1

Why is my code not working?
the plugin is supposed to block the ability to use scopa in awp weapons if the player's speed is less than 250 units.



#include <sourcemod>
#include <cstrike>

public Plugin:myinfo =
{
name = "No AWP Scope Speed Limit",
author = "unkownname",
description = "Prevents players from using the scope on the AWP if their speed is less than 250",
};

public OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
{
if(weapon == CSW_AWP && GetClientSpeed(client) < 250.0)
{
SetClientCrouchButton(client, false);
SetUserCrouchState(client, CROUCH_DISABLED);
}
}
Unkown_name is offline
Naathy
Member
Join Date: Mar 2022
Location: Brazil
Old 02-12-2023 , 01:18   Re: help my code
Reply With Quote #2

Spoiler


1 - There's nothing stored in 'weapon' string.
2 - GetClientSpeed is not a Function or youre missing include file.
3 - Put the code inside PHP tag, it will be better for us to read.

By the way, to get the weapon:
PHP Code:
char weapon[64];

GetClientWeapon(iClientweaponsizeof(weapon)) 
To check if the weapon is awp:
PHP Code:
if(StrEqual(weapon"weapon_awp"
To get the player current speed:
PHP Code:
float playerVelocity[3];
float playerSpeed;

GetEntPropVector(iClientProp_Data"m_vecAbsVelocity"playerVelocity);
playerSpeed SquareRoot(playerVelocity[0]*playerVelocity[0] + playerVelocity[1]*playerVelocity[1]);

if(
playerSpeed 250.0)
{
    
// bla bla

To block an action you need to return Plugin_Handled.
PHP Code:
if(iButtons IN_ATTACK2)
{
    return 
Plugin_Handled;

__________________
Owner of NGServers

Contact
Discord | Steam | Github

Last edited by Naathy; 02-12-2023 at 01:19.
Naathy is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-12-2023 , 14:18   Re: help my code
Reply With Quote #3

is that one of those chatgpt codes in first post ?
Bacardi is offline
Unkown_name
Junior Member
Join Date: Jan 2022
Old 02-12-2023 , 16:19   Re: help my code
Reply With Quote #4

Quote:
Originally Posted by Bacardi View Post
is that one of those chatgpt codes in first post ?
If you can guess whether I wrote this code myself or it was written by a bot and you correct it, then I will answer your question, I am curious if you can handle this task.
Code:
public OnPlayerRunCmd(client, &buttons, &impulse, float forwardmove, float sidemove)
{
    char weapon[64];
    float playerVelocity[3];
    float playerSpeed;
    
    GetClientWeapon(client, weapon, sizeof(weapon));
    if(StrEqual(weapon, "weapon_awp"))
    {
        GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", playerVelocity);
        playerSpeed = SquareRoot(playerVelocity[0]*playerVelocity[0] + playerVelocity[1]*playerVelocity[1]);
        
        if(playerSpeed < 250.0)
        {
            if(buttons & IN_ATTACK2)
            {
                return Plugin_Handled;
            }
        }
    }
    return Plugin_Continue;
}
Unkown_name is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 02-13-2023 , 05:27   Re: help my code
Reply With Quote #5

Quote:
Originally Posted by Unkown_name View Post
PHP Code:
public OnPlayerRunCmd(client, &buttons, &impulsefloat forwardmovefloat sidemove
PHP Code:
/**
 * Called when a clients movement buttons are being processed
 *
 * @param client        Index of the client.
 * @param buttons       Copyback buffer containing the current commands (as bitflags - see entity_prop_stocks.inc).
 * @param impulse       Copyback buffer containing the current impulse command.
 * @param vel           Players desired velocity.
 * @param angles        Players desired view angles.
 * @param weapon        Entity index of the new weapon if player switches weapon, 0 otherwise.
 * @param subtype       Weapon subtype when selected from a menu.
 * @param cmdnum        Command number. Increments from the first command sent.
 * @param tickcount     Tick count. A client's prediction based on the server's GetGameTickCount value.
 * @param seed          Random seed. Used to determine weapon recoil, spread, and other predicted elements.
 * @param mouse         Mouse direction (x, y).
 * @return              Plugin_Handled to block the commands from being processed, Plugin_Continue otherwise.
 *
 * @note To see if all 11 params are available, use FeatureType_Capability and FEATURECAP_PLAYERRUNCMD_11PARAMS.
 */
forward Action OnPlayerRunCmd(int clientint &buttonsint &impulsefloat vel[3], float angles[3], int &weaponint &subtypeint &cmdnumint &tickcountint &seedint mouse[2]); 
__________________
Grey83 is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 02-13-2023 , 05:29   Re: help my code
Reply With Quote #6

Quote:
Originally Posted by Unkown_name View Post
If you can guess whether I wrote this code myself or it was written by a bot and you correct it, then I will answer your question, I am curious if you can handle this task.
The code was written by a bot, or by a person who does not understand programming.
__________________
Grey83 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 21:57.


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