View Single Post
Sreaper
髪を用心
Join Date: Nov 2009
Old 08-10-2022 , 00:00   Re: Can't get a command to target all players
Reply With Quote #3

Quote:
Originally Posted by itsJakub View Post
Hi, I'm using the SetEntityGravity command to change the gravity and I'm unsure on how to get it to apply to all players.

I've tried a few methods which didn't work. Currently, I'm trying to define all client numbers and use this in the entity parameters.

Error 035 argument mismatch since this is an invalid entity.
PHP Code:
#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    
RegConsoleCmd("sm_lg"Command_Low_Gravity"Sets a low gravity");
}

public 
Action Command_Low_Gravity(int clientint args)
{
    
char arg[3];
    
GetCmdArg(1argsizeof(arg));
    
int gravity StringToInt(arg);

    if (
args != || !HasOnlyNumbers(arg) || gravity || gravity 1)
    {
        
ReplyToCommand(client"[SM] Usage: sm_lg <0/1>");
        return 
Plugin_Handled;
    }

    for (
int i 1<= MaxClientsi++)
    {
        if (!
IsClientInGame(i)) continue;

        
SetEntityGravity(igravity 0.08 1.0);
    }
    
ReplyToCommand(client"[SM] Low gravity has been %s."gravity "Enabled" "Disabled");
    return 
Plugin_Handled;
}

stock bool HasOnlyNumbers(char[] s) {
    
int len strlen(s);
    for (
int i 0leni++)
        if (!
IsCharNumeric(s[i])) return false;
    return 
true;


Last edited by Sreaper; 08-10-2022 at 17:53. Reason: HasOnlyNumbers
Sreaper is offline