AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Plugin Optimize (https://forums.alliedmods.net/showthread.php?t=53725)

Dark Kingdom 04-09-2007 23:02

Plugin Optimize
 
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.

SweatyBanana 04-10-2007 00:07

Re: Plugin Optimize
 
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.



Dark Kingdom 04-10-2007 00:13

Re: Plugin Optimize
 
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.

scrtxxcaz 04-10-2007 00:17

Re: Plugin Optimize
 
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



All times are GMT -4. The time now is 06:42.

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