Raised This Month: $ Target: $400
 0% 

Plugin Optimize


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dark Kingdom
BANNED
Join Date: Apr 2007
Location: VT
Old 04-09-2007 , 23:02   Plugin Optimize
Reply With Quote #1

Hello, I need some 'help' on my plugin and need someone to fix it for me please?

This is susposed to change a CVAR, but it's not. What I'm trying to do is create a command in this case "amx_npckill" and make it so it will change a allready built-in cvar, in this case "killnpc".

amx_npckill - The created command.
killnpc - Allready built-in command (svencoop had it).

Do you get me? amx_npckill 0 should change killnpc to 0, and vise versa.
But theres just one little problem.. It won't work it compiles but just doesn't work. Can someone get it too work please?

PHP Code:
#include <amxmodx>

#define PLUGIN "NPC Protector"
#define VERSION "1.0"
#define AUTHOR "Dark Kingdom"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_cvar("amx_npckill","1")
    
register_concmd("killnpc","killnpc")
    
}

public 
killnpc() {
    if ( 
get_cvar_num"amx_npckill" ) >= set_cvar_num"killnpc" //off
    
client_print(0,print_chat"[NPC Protector] ADMIN has turned the plugin off, NPC's can be killed.")
    
    if ( 
get_cvar_num"amx_npckill" ) <= set_cvar_num"killnpc" //on
    
client_print(0,print_chat,"[NPC Protector] ADMIN has turned the plugin on, NPC's can't be killed.")
    

Thanks.
Dark Kingdom is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 04-10-2007 , 00:07   Re: Plugin Optimize
Reply With Quote #2

killnpc is your command, not your cvar.

Quote:
if ( get_cvar_num( "amx_npckill" ) >= 1 ) set_cvar_num( "killnpc" , 1 )
Change that to this:

Quote:
if ( get_cvar_num( "amx_npckill" ) >= 1 ) set_cvar_num( "amx_npckill" , 1 )
and the same thing (in general) for the other one.


SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
Dark Kingdom
BANNED
Join Date: Apr 2007
Location: VT
Old 04-10-2007 , 00:13   Re: Plugin Optimize
Reply With Quote #3

Responded at a bad time ;) I'm about to go to bed cause it's 12:15 and tired.
I'll test this tomorrow morning, thanks.
Dark Kingdom is offline
scrtxxcaz
Senior Member
Join Date: Feb 2007
Location: a place u cant find
Old 04-10-2007 , 00:17   Re: Plugin Optimize
Reply With Quote #4

if i understand u correctly try this..


u may also have to go into your amxmodx/config/cvars folder and add this line "amx_npckill" "0" "1" "u"

Code:
#include <amxmodx>
 
#define PLUGIN "NPC Protector"
#define VERSION "1.0"
#define AUTHOR "Dark Kingdom"
 
 
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
 
register_cvar("amx_npckill","1")
register_concmd("killnpc","killnpc")
 
}
 
public killnpc(id) {
new cvarkill = get_cvar_num("npckill")
if(cvarkill == 1) //off
{
client_print(id,print_chat,"[NPC Protector] ADMIN has turned the pluginoff, NPC's can be killed.")
}
else if{cvarkill == 0)  //on
}
client_print(id,print_chat,"[NPC Protector] ADMIN has turned the plugin on, NPC's can't be killed.")
}
}
OR:
try somin like this so that each time u type npckill in console it will turn it on and off instean of going into ur amxmodx menu....but hey im pro at coding just tryin to give ideas/help

Code:
#include <amxmodx>
 
#define PLUGIN "NPC Protector"
#define VERSION "1.0"
#define AUTHOR "Dark Kingdom"
 new check = 0
 
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
 
register_cvar("amx_npckill","1")
register_concmd("killnpc","killnpc")
 
}
 
public killnpc(id) {
new cvarkill
  if(check == 0)
  {
    check = 1
    set_cvar_num("npckill",1)
    cvarkill = get_cvar_num("npckill")
    if(cvarkill == 1) //off
    {
         client_print(id,print_chat,"[NPC Protector] ADMIN has turned the pluginoff, NPC's can be killed.")
         return PLUGIN_HANDLED
    }
  }
  if(check == 1)
  {
      check = 0
      set_cvar_num("npckill",0)
      cvarkill = get_cvar_num("npckill")
      if{cvarkill == 0)  //on
      }
           client_print(id,print_chat,"[NPC Protector] ADMIN has turned the plugin on, NPC's can't be killed.")
           return PLUGIN_HANDLED
      }
   }
}
return PLUGIN_CONTINUE

Last edited by scrtxxcaz; 04-10-2007 at 01:26.
scrtxxcaz is offline
Send a message via AIM to scrtxxcaz
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 06:42.


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