AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Roundtime problem (https://forums.alliedmods.net/showthread.php?t=133907)

nikhilgupta345 07-30-2010 00:24

Roundtime problem
 
I'm making a plugin where u can set all the server cvars like mp_roundtime and stuff with commands like amx_roundtime so you don't have to use cvar. I know there is probably another one like this around.

So what happens is when I type amx_roundtime 3 or seomthing, it says mp_roundtime changed to "1957348738961" or some random number thats not 3... Any ideas?

Also, when I do all commands like amx_timelimit 40 for example, it works, but right before it says mp_timelimit changed to 40, it says Unknown command: amx_timelimit. Any way to remove that?

Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    //Client Commands
    register_clcmd("say /timelimit", "sayTime")
    register_clcmd("say /roundtime", "sayRound")
    register_clcmd("say /buytime", "sayBuy")
    register_clcmd("say /freezetime", "sayFreeze")
    //Admin Commands
    register_concmd("amx_restartround", "restartround", ADMIN_RCON, "<seconds (1-20)>")
    register_concmd("amx_timelimit", "timelimit", ADMIN_RCON, "<minutes (1-60)>")
    register_concmd("amx_roundtime", "roundtime", ADMIN_RCON, "<minutes (1-9)>")
    register_concmd("amx_buytime", "buytime", ADMIN_RCON, "<seconds>")
    register_concmd("amx_freezetime", "freezetime", ADMIN_RCON, "<seconds>")
    register_concmd("amx_friendlyfire", "friendlyfire", ADMIN_RCON, "<0=No, 1=Yes>")
    register_concmd("amx_hostname", "hostname", ADMIN_RCON, "<'new name'>")
    register_concmd("amx_execfile", "exec", ADMIN_RCON, "<'file.cfg'>")
}


public restartround(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
   
new arg1[3]
read_argv(1, arg1, 2)
new num=str_to_num(arg1)
if(num>20 || num<1)
{
console_print(id, "Seconds must be between 1 and 20!!!")
return PLUGIN_HANDLED
}
server_cmd("sv_restartround %i", num)
client_print(0, print_chat, "Round is being restarted in %i seconds!!!", num)
return 0;
}


public timelimit(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new arg1[3]
read_argv(1, arg1, 2)
new num=str_to_num(arg1)
if(num>60)
{
console_print(id, "Timelimit must be less than 60 minutes!!!")
return PLUGIN_HANDLED
}
server_cmd("mp_timelimit %i", num)
return 0;
}


public roundtime(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new arg1[3]
read_argv(1, arg1, 2)
new Float:num=str_to_float(arg1)
if(num<1 || num>9)
{
console_print(id, "Roundtime must be between 1 and 9")
return PLUGIN_HANDLED
}
server_cmd("mp_roundtime %d", num)
return 0;
}


public buytime(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new arg1[3]
read_argv(1, arg1, 2)
new num=str_to_num(arg1)
if(num=0)
{
console_print(id, "Buytime cannot be 0!!!")
return PLUGIN_HANDLED
}
server_cmd("mp_buytime %i", num)
return 0;
}


public freezetime(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new arg1[3]
read_argv(1, arg1, 2)
new num=str_to_num(arg1)
server_cmd("mp_freezetime %i", num)
return 0;
}


public friendlyfire(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new arg1[3]
read_argv(1, arg1, 2)
new num=str_to_num(arg1)
if(num>1)
{
console_print(id, "Friendlyfire must be either 1 or 0!!!")
return PLUGIN_HANDLED
}
server_cmd("mp_friendlyfire %i", num)
return 0;
}


public hostname(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new arg1[256]
read_argv(1, arg1, 255)
if(arg1[0]=='"' && arg1[1]=='"')
{
console_print(id, "Server must have a name!!!")
return PLUGIN_HANDLED
}
server_cmd("hostname %s", arg1)
console_print(id, "Name has been set to '%s'", arg1)
return 0;
}


public exec(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new arg1[32]
read_argv(1, arg1, 31)
trim(arg1)
if(!containi(arg1, ".cfg"))
{
console_print(id, "File name must have .cfg extension.")
return PLUGIN_HANDLED
}
server_cmd("exec %s", arg1)
return 0;
}

public sayFreeze(id)
{
new num=get_cvar_num("mp_freezetime")
client_print(id, print_chat, "Freezetime is set to %i seconds.", num)
}
public sayRound(id)
{
new num=get_cvar_num("mp_roundtime")
client_print(id, print_chat, "The time in each round is %i minutes.", num)
}
public sayBuy(id)
{
new num=get_cvar_num("mp_buytime")
client_print(id, print_chat, "The buytime is %i seconds.", num)
}
public sayTime(id)
{
new num=get_cvar_num("mp_timelimit")
client_print(id, print_chat, "Time per map is %i minutes.", num)
}


minato 07-30-2010 01:54

Re: Roundtime problem
 
Code:
public roundtime(id, level, cid) {     if(!cmd_access(id, level, cid, 2))         return PLUGIN_HANDLED     new arg1[3]     read_argv(1, arg1, 2)    new Float:num=str_to_float(arg1)     if(num<1 || num>9)     {         console_print(id, "Roundtime must be between 1 and 9")         return PLUGIN_HANDLED     }     server_cmd("mp_roundtime %d", num)     return 0; }

:arrow:
Code:
 new num = str_to_num(arg1)

nikhilgupta345 07-31-2010 02:52

Re: Roundtime problem
 
I tried doing what you said in the VERY beginning, but it would not allow me to use floats. Roundtimes you can set floats, but if i use str_to_float, it messes up or soemthing. A random number comes up and that's what gets set for the roundtime. Anybody else have any ideas on what to do?


All times are GMT -4. The time now is 00:14.

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