Raised This Month: $ Target: $400
 0% 

[HELP] I need help with a plugin code.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
happy_2012
Senior Member
Join Date: Aug 2012
Old 06-28-2014 , 13:35   [HELP] I need help with a plugin code.
Reply With Quote #1

Hello,
I hope someone will be able to help me editing a plugin, which is Night Nadewars system.

Bugs detected are the following:
  1. Respawn players with (HE Grenade only)
  2. Players shouldn't be able to pick up any weapon or use knives
  3. HE Grenade should be given automatically when the player throw the nade he/she is holding
  4. If the nw_respawn "0" they can still respawn automatically or when using /respawn
The fix is the following:
  1. Players are able to use knives and pick weapons up
  2. They doesn't get nades automatically
  3. When nw_respawn "0" it shouldn't respawn automatically or even use /respawn
Code:
/*
 Plugin : Night Nadewars
 Version : 2.0.0
 Author : happy_2012
 Website : http://gamingdistrict.net
 
*/
// Includes
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <colorchat>
#include <fun>
#include <amxmisc>
#include <engine>
// Defines
#define PLUGIN "Night Nadewars"
#define VERSION "2.0.0"
#define AUTHOR "happy_2012"
#define DISABLE_CS 0
// Tags
new const NW_Tag[] = "^1[^4Nade Wars^1]"
new const NW_V[] = "2.0.0"
// Check Pistol
new bool:g_PistolsDisabled = false
// Team ids 
#define UNASSIGNED 0 
#define TS 1 
#define CTS 2 
#define AUTO_TEAM 5 
// Skies related
new g_skyname[32] 
new const g_arg[][] = { "bk", "dn", "ft", "lf", "rt", "up" } 
new sky_on, lights_on
new g_lights_level[4]
public plugin_init() 
{
 
 // Registeration of plugin
 register_plugin(PLUGIN, VERSION, AUTHOR)
 
 // Cvars
 register_cvar("nw_checkpistols", "1")
 register_cvar("nw_respawn", "1")
 register_cvar("nw_respawn_version", VERSION, FCVAR_SERVER)
 
 // Events
 register_event("HLTV", "EventNewRound", "a", "1=0", "2=0");
 register_event("DeathMsg", "on_Death", "a");
 
 // Client commands
 register_clcmd("say", "on_Chat")
 register_clcmd("say_team", "on_Chat")
 
 // No function in plugin precache
 set_effect() 
 
}
public plugin_precache() 
{ 
 register_plugin(PLUGIN, VERSION, AUTHOR)
 sky_on = register_cvar("nw_sky_on", "1")
 lights_on = register_cvar("nw_lights_on", "1")
 
 if(!load_data()) return 
     
 new precache[64]
 for(new i; i < sizeof g_arg; i++)
 { 
  formatex(precache, 63, "gfx/env/%s%s.tga", g_skyname, g_arg[i]) 
  precache_generic(precache)
 }
 
}
load_data() 
{ 
 new file[64]
     
 get_configsdir(file, 63) 
 format(file, charsmax(file), "%s/nw_skies.ini", file) 
 if(!file_exists(file))
 {
  log_amx("nw_skies.ini is not found")
  return 0 
 }
 
 new str_hour[3], hour
 format_time(str_hour, charsmax(str_hour), "%H")
 hour = str_to_num(str_hour)
 new buff[36], key[16], value[16], fo_hour[3], to_hour[3], sky_num
 new open=fopen(file,"r") 
     
 while(!feof(open))
 {
  buff[0]='^0' 
  fgets(open, buff, charsmax(buff))
  trim(buff) 
  
  if(!buff[0] || buff[0] == ';')
   continue
  
  if (buff[0] == '[')
  {
   sky_num++
   continue
  }
  
  strtok(buff, key, charsmax(key), value, charsmax(value), ':')
  trim(key)
  trim(value)
  
  if(sky_num)
  {
   sky_num = 0
   if(check_hour(hour, fo_hour, to_hour) && g_skyname[0] && g_lights_level[0])
   {
    fclose(open)
    return 1
   }
  }
    
  if(equal(key, "hour"))
   strtok(value, fo_hour, 2, to_hour, 2, ',')
  else if(equal(key, "sky_name"))
   copy(g_skyname, charsmax(g_skyname), value)
  else if(equal(key, "lights_level"))
   copy(g_lights_level, charsmax(g_lights_level), value)
 }
 if(check_hour(hour, fo_hour, to_hour) && g_skyname[0] && g_lights_level[0])
 {
  fclose(open)
  return 1
 }
 log_amx("misconfigured nw_skies.inil")
  
 fclose(open)
 return 0
 
}
stock check_hour(hour, fo_hour[3], to_hour[3])
{
 if(str_to_num(fo_hour) <= hour <= str_to_num(to_hour))
  return 1
 return 0
 
}
set_effect()
{
 if(g_skyname[0] && get_pcvar_num(sky_on))
  set_cvar_string("sv_skyname", g_skyname)
  
 if(g_lights_level[0] && get_pcvar_num(lights_on) && !equal(g_lights_level, "off")) 
  set_lights(g_lights_level)
 else set_lights("#OFF")
 
}
public EventNewRound(id)
{
 
 ColorChat(id, GREEN, "%s ===== ^4Nade Wars %s^1 =====", NW_Tag, NW_V);
 ColorChat(id, GREEN, "%s Type ^4/respawn ^1to revive yourself.", NW_Tag);
 ColorChat(id, GREEN, "%s www.gamingdistrict.net", NW_Tag);
 
}
public on_Chat(id)
{
 
 if (!get_cvar_num("nw_respawn"))
 {
  ColorChat(id, GREEN, "%s Respawn is currently disabled.", NW_Tag);
  return PLUGIN_CONTINUE
 }
 new szSaid[32]
 read_args(szSaid, 31) 
 if (equali(szSaid,"^"/respawn^"") || equali(szSaid,"^"respawn^""))
 {
  spawn_func(id)
 }
 return PLUGIN_CONTINUE
}
public check_pistols()
{
 
 // Determine if we should give players a pistol or not
 if ( get_cvar_num("nw_checkpistols") )
 {
  new mapname[32]
  get_mapname(mapname,31) 
  if (containi(mapname,"he_")!=-1 || containi(mapname,"scoutzknivez")!=-1)
    g_PistolsDisabled = true
 }
 
}
public spawn_func(id)
{
 
 new parm[1]
 parm[0]=id
 
 //Spawn the player twice to avoid the HL engine bug
 set_task(0.5,"player_spawn",72,parm,1)
 set_task(0.7,"player_spawn",72,parm,1)
 //Then give them a suit and a knife
 set_task(0.9,"player_giveitems",72,parm,1)
 
}
public on_Death()
{
 if (!get_cvar_num("nw_respawn"))
  return PLUGIN_CONTINUE
 
 new victim_id = read_data(2)
 
 spawn_func(victim_id)
 return PLUGIN_CONTINUE
}
public player_giveitems(parm[1])
{
 new id = parm[0]
 give_item(id, "item_suit");
 give_item(id, "weapon_hegrenade");
 
 // force giving player a nade
 if ( !g_PistolsDisabled )
 {
  give_item(id, "item_suit");
  give_item(id, "weapon_hegrenade");
 }
 
 return PLUGIN_CONTINUE
}
public player_spawn(parm[1])
{
 spawn(parm[0])
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ fbidis\\ ansi\\ ansicpg1256\\ deff0\\ deflang11265{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ ltrpar\\ f0\\ fs16 \n\\ par }
*/
Can somebody please, help me with fixing the bugs.

Kind Regards,
happy_2012
__________________
Discord contacts:
I rarely look at private messages here, but I am very active on Discord!
happy_2012 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 21:16.


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