Quote:
Originally Posted by itsJakub
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 client, int args)
{
char arg[3];
GetCmdArg(1, arg, sizeof(arg));
int gravity = StringToInt(arg);
if (args != 1 || !HasOnlyNumbers(arg) || gravity < 0 || gravity > 1)
{
ReplyToCommand(client, "[SM] Usage: sm_lg <0/1>");
return Plugin_Handled;
}
for (int i = 1; i <= MaxClients; i++)
{
if (!IsClientInGame(i)) continue;
SetEntityGravity(i, gravity ? 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 = 0; i < len; i++)
if (!IsCharNumeric(s[i])) return false;
return true;
}