|
Veteran Member
|

01-03-2006
, 17:55
|
#4
|
1) You don't need to post the .amxx, it gets put in automatically if you post the .sma
2) You need to edit the client commands - for example: the client command is just say, so if I type anything, like "hi" the gravity will be changed. Make the commands "say /gravity 200" or w/e, you get my point
3) This is kind of nitpicky, but you can make this script a smaller:
Code:
/* AMXX Mod script.
*
* (c) Copyright 2005, Wolle
* This file is provided as is (no warranties)
*
* Allows admins to easily control gravity
*
* Usage: "command amountofgravity timeinminutes"
* Example: To set the gravity to 200 for a duration of 5 minutes just say or team_say: "/grav 200 5"
*
* Enjoy!!
* Contact: <a href="mailto:[email protected]">[email protected]</a>
*/
#include <amxmodx>
#include <fun>
#define MAX_ARGUMENTS 3
#define MAX_ARGUMENT_LENGTH 32
new g_iDuration = 0;
new bool:g_bTimesUp = false;
public plugin_init ()
{
register_plugin("Gravity Control", "1.00", "Wolle");
register_clcmd ("say", "GravityControl");
register_clcmd ("say_team", "GravityControl");
}
public Timer ()
{
if(g_iDuration > 0)
{
g_iDuration --;
if(g_iDuration == 0)
{
g_bTimesUp = true;
}
else if(g_iDuration < = 5)
{
set_hudmessage(230, 130, 30, 0.03, 0.6, 2, 0.02, 0.6, 0.01, 0.3, 0);
show_hudmessage(0, "Normal gravity in: %d", g_iDuration );
}
if(g_bTimesUp )
{
set_cvar_num("sv_gravity", 800);
g_bTimesUp = false;
set_hudmessage(230, 130, 30, 0.03, 0.6, 2, 0.02, 5.0, 0.01, 0.3, 1);
show_hudmessage(0, "Gravity has been restored.");
}
}
else if(g_iDuration < 0)
{
g_iDuration = 0;
}
}
public GravityControl (id )
{
if(!id )
{
return PLUGIN_CONTINUE;
}
if(get_user_flags(id ) && ADMIN_LEVEL_A )
{
new i, j, len, len2, arg1, arg2;
new said [192], cmd [10], arguments [MAX_ARGUMENTS ][MAX_ARGUMENT_LENGTH ];
read_argv(0, cmd, 9);
read_args(said, 191);
remove_quotes(said );
len = strlen(said );
for(i = 0 ; i < len ; i ++)
{
if (said [i ] == ' ')
{
j ++;
}
else
{
if(containi(arguments [0], "/grav") != -1)
{
if(j > 2)
{
set_hudmessage(230, 130, 30, 0.03, 0.6, 2, 0.02, 5.0, 0.01, 0.3, 1);
show_hudmessage(0, "Too many arguments!!^nUsage: /grav <gravity> <time>");
return PLUGIN_CONTINUE;
}
}
len2 = strlen(arguments [j ]);
add(arguments [j ], len2 +1, said [i ]);
}
}
if( containi(arguments [0], "/grav") != -1)
{
arg1 = str_to_num(arguments [1]);
arg2 = str_to_num(arguments [2]);
if(arg1 != 0 && arg2 != 0 || containi(arguments [1], "normal") != -1)
{
new user_name [64];
get_user_name (id, user_name, 63);
if(containi(arguments [1], "normal") != -1)
{
set_cvar_num("sv_gravity" , 800);
g_iDuration = 0;
remove_task(1, 0);
set_hudmessage(230, 130, 30, 0.03, 0.6, 2, 0.02, 5.0, 0.01, 0.3, 0);
show_hudmessage(0, "%s set the gravity back to normal", user_name );
return PLUGIN_CONTINUE;
}
else if(arg2 * 60 > get_timeleft())
{
set_hudmessage(230, 130, 30, 0.03, 0.6, 2, 0.02, 5.0, 0.01, 0.3, 1);
show_hudmessage(id, "Theres not enough time left.^nSet the duration to a lower value!");
}
else
{
g_iDuration = arg2 *60;
set_task(1.0, "Timer", 1, "", 0, "a", g_iDuration );
set_cvar_num("sv_gravity" , arg1 );
set_hudmessage(230, 130, 30, 0.03, 0.6, 2, 0.02, 5.0, 0.01, 0.3, 0);
show_hudmessage(0, "%s set the gravity to %d for %d minutes", user_name, arg1, arg2 );
}
}
else
{
set_hudmessage(230, 130, 30, 0.03, 0.6, 2, 0.02, 5.0, 0.01, 0.3, 0);
show_hudmessage(id, "Invalid Arguments!!^nUsage: /grav <gravity> <time>");
}
}
engclient_cmd (id, cmd, said );
}
return PLUGIN_CONTINUE;
}
Also, if you want you can put the { on lines like this:
if(random != random) {
And it'll save you a line  Yeah but that was just my nitpickiness for the day... overall, gj!
|
|