Raised This Month: $ Target: $400
 0% 

Help with this plugin..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 05-01-2006 , 18:31   Help with this plugin..
Reply With Quote #1

What is wrong with my code??

I ran it on my server and when I typed /stuck, it said you must be alive to use /stuck...I was very much alive ...Any help here?...Making this from an old request.

Code:
#include <amxmodx>   #include <amxmisc>   #include <fun>   #define PLUGIN "Stuck"   #define VERSION "1.0"   #define AUTHOR "SweatyBanana"   new stuck[33]; public plugin_init()   {       register_plugin(PLUGIN, VERSION, AUTHOR)       register_cvar("stuck_time", "5")     register_cvar("anounce_Time","60")     register_clcmd("say_team /stuck", "cmd_stuck")     register_clcmd("say /stuck", "cmd_stuck")     set_task(20.0,"advertise");     register_logevent("round_start", 2, "0=World triggered", "1=Round_Start"); } public round_start() {    for(new id = 1; id <= 32; id++)       stuck[id] = 0; } public cmd_stuck()   {       new Time = get_cvar_num("stuck_time");         new id;         if(!is_user_alive(id))        client_print(id, print_chat, "[STUCK] you can only use /stuck if you are alive!")             else if(stuck[id] >= Time)        client_print(id, print_chat, "[STUCK] you can only use /stuck every %i second(s)", Time)             else     {         set_user_noclip (id, 0)         set_task(get_cvar_float("Time"),"unclip");         client_print(id, print_chat, "[STUCK] You have %i second(s) until becoming solid again.", Time);     }     return PLUGIN_HANDLED; } public unclip() {     new id;     set_user_noclip (id) } public advertise() {     client_print(0,print_chat,"[STUCK] say /stuck to become a 'ghost'")     set_task(get_cvar_float("anounce_Time"),"advertise")     return PLUGIN_HANDLED }
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 05-01-2006 , 19:07  
Reply With Quote #2

lol, simple mistake:
Code:
set_user_noclip (id, 0)
You never set it in the first place.

Also, this is a better way to do the whole "time between uses" thing:
Code:
new g_iTime[33]; public my_func(id) {   new iTime = floatround(get_gametime());   if(iTime - g_iTime[id] < 30)   {     client_print(id , print_chat , "[AMXX] You can only do that command every 30 seconds!");     return PLUGIN_HANDLED;   }   g_iTime[id] = floatround(get_gametime());   return PLUGIN_HANDLED; }
I think that's how it's done ;)
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 05-01-2006 , 20:04  
Reply With Quote #3

So does this look good?

Code:
#include <amxmodx>   #include <amxmisc>   #include <fun>   #define PLUGIN "Stuck"   #define VERSION "1.0"   #define AUTHOR "SweatyBanana"   new stuck[33]; new g_secondTime[33]; public plugin_init()   {       register_plugin(PLUGIN, VERSION, AUTHOR)       register_cvar("stuck_time", "5")     register_cvar("anounce_Time","60")     register_clcmd("say_team /stuck", "cmd_stuck")     register_clcmd("say /stuck", "cmd_stuck")     set_task(20.0,"advertise");     register_logevent("round_start", 2, "0=World triggered", "1=Round_Start"); } public round_start() {     for(new id = 1; id <= 32; id++)        stuck[id] = 0; } public cmd_stuck(id) {     new Time = get_cvar_num("stuck_time");     new firstTime = floatround(get_gametime());     if(firstTime - g_secondTime[id] < Time)     {         client_print(id , print_chat , "[AMXX] You can only do that command every %i seconds!", Time);         return PLUGIN_HANDLED;     }     g_secondTime[id] = floatround(get_gametime());     return PLUGIN_HANDLED; } /************************************************************************ public cmd_stuck()   {       new Time = get_cvar_num("stuck_time");         new id;         if(!is_user_alive(id))        client_print(id, print_chat, "[STUCK] you can only use /stuck if you are alive!")             else if(stuck[id] >= Time)        client_print(id, print_chat, "[STUCK] you can only use /stuck every %i second(s)", Time)             else     {         set_user_noclip (id, 1)         set_task(get_cvar_float("Time"),"unclip");         client_print(id, print_chat, "[STUCK] You have %i second(s) until becoming solid again.", Time);     }     return PLUGIN_HANDLED; } ************************************************************************/ public unclip() {     new id;     set_user_noclip (id) } public advertise() {     client_print(0,print_chat,"[STUCK] say /stuck to become a 'ghost'")     set_task(get_cvar_float("anounce_Time"),"advertise")     return PLUGIN_HANDLED }
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 05-01-2006 , 21:31  
Reply With Quote #4

Yeah but you gotta put the noclip functions in
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 05-01-2006 , 21:44  
Reply With Quote #5

So hows this


Code:
#include <amxmodx>   #include <amxmisc>   #include <fun>   #define PLUGIN "Stuck"   #define VERSION "1.0"   #define AUTHOR "SweatyBanana"   new stuck[33]; new g_secondTime[33]; public plugin_init()   {       register_plugin(PLUGIN, VERSION, AUTHOR)       register_cvar("stuck_time", "5")     register_cvar("anounce_Time","60")     register_clcmd("say_team /stuck", "cmd_stuck")     register_clcmd("say /stuck", "cmd_stuck")     set_task(20.0,"advertise");     register_logevent("round_start", 2, "0=World triggered", "1=Round_Start"); } public round_start() {     for(new id = 1; id <= 32; id++)        stuck[id] = 0; } public cmd_stuck(id) {     new id;         new Time = get_cvar_num("stuck_time");     new firstTime = floatround(get_gametime());         if(!is_user_alive(id))     {         client_print(id, print_chat, "[STUCK] you can only use /stuck if you are alive!")     }         if(firstTime - g_secondTime[id] < Time)     {         client_print(id , print_chat , "[AMXX] You can only do that command every %i seconds!", Time);         return PLUGIN_HANDLED;     }         else     {         set_user_noclip (id, 1)         set_task(get_cvar_float("Time"),"unclip");         client_print(id, print_chat, "[STUCK] You have %i second(s) until becoming solid again.", Time);     }     g_secondTime[id] = floatround(get_gametime());     return PLUGIN_HANDLED; } public unclip() {     new id;     set_user_noclip (id) } public advertise() {     client_print(0,print_chat,"[STUCK] say /stuck to become a 'ghost'")     set_task(get_cvar_float("anounce_Time"),"advertise")     return PLUGIN_HANDLED }
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 05-01-2006 , 21:49  
Reply With Quote #6

Code:
public cmd_stuck(id) {     //new id; wtf?         new Time = get_cvar_num("stuck_time");     new firstTime = floatround(get_gametime());         if(!is_user_alive(id))     {         client_print(id, print_chat, "[STUCK] you can only use /stuck if you are alive!")         return PLUGIN_HANDLED; // added this return     }         if(firstTime - g_secondTime[id] < Time)     {         client_print(id , print_chat , "[AMXX] You can only do that command every %i seconds!", Time);         return PLUGIN_HANDLED;     }         // removed the else statement     set_user_noclip (id, 1)     set_task(get_cvar_float("Time"),"unclip");     client_print(id, print_chat, "[STUCK] You have %i second(s) until becoming solid again.", Time);     g_secondTime[id] = floatround(get_gametime());     return PLUGIN_HANDLED; }
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x 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 05:12.


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