Raised This Month: $ Target: $400
 0% 

Bomb planting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
flyeni6
Senior Member
Join Date: Jun 2006
Location: CAli
Old 07-10-2007 , 17:40   Re: Bomb planting
Reply With Quote #1

this code seems easier because it give u a menu to create a box. now i dont know how to make it a bombsite when the box is created
(sorry it isn't indented. im about to go somewhere)

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
#define MAX_ZONES 5
#define TASK_ID  1234
#define OriginX  0
#define OriginY  1
#define OriginZ  2
new cvar_delay
new cvar_kzsize
new cvar_kzsizez
new cvar_height
new bool:g_DirExist
new g_ConfigsDir[64]
new 
g_KnifeZoneDir[64]
new 
Float:g_fDelay[33]
new 
g_ProtectionTime[33]
new 
bool:g_InTheZone[33]
new 
zoneID
new sprite_zbeam
new g_KnifeZoneOrgins[MAX_ZONES][3]
 
static const 
PLUGIN_NAME[]  = "Knife Zone"
static const PLUGIN_AUTHOR[]  = "Cheap_Suit"
static const PLUGIN_VERSION[] = "1.6"
public plugin_init()
{
 
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)
 
register_cvar(PLUGIN_NAMEPLUGIN_VERSIONFCVAR_SPONLY|FCVAR_SERVER)
 
register_clcmd("amx_kzmenu""open_KnifeZone"ADMIN_LEVEL_A"Knife Zone Menu")
 
register_menucmd(register_menuid("Knife Zone Menu"), 1023"action_KnifeZone")
 
cvar_delay register_cvar("amx_kzdelay",  "3")
 
cvar_height register_cvar("amx_kzheight""140")
 
cvar_kzsize  register_cvar("amx_kzsize",  "140")
 
cvar_kzsizez  register_cvar("amx_kzsizez",  "50")
 
 
register_forward(FM_TraceLine"fwd_TraceLine")
 
register_directory()
}
public 
plugin_precache() 
{
 
sprite_zbeam precache_model("sprites/zbeam4.spr")
}
register_directory()
{
 
get_configsdir(g_ConfigsDir63)
 
format(g_KnifeZoneDir63"%s/knifezone"g_ConfigsDir)
 
 if(!
dir_exists(g_KnifeZoneDir))
 {
  
log_amx("Knife Zone directory does not exist")
  
g_DirExist false
 

 else 
 {
  
g_DirExist true
  
  
new curMap[32]
  
get_mapname(curMap31)
  
load_origins(curMap)
  
  
set_task(1.0"task_visuals"TASK_ID__"b")
 }
}
public 
open_KnifeZone(idlevelcid)
{
 if(!
cmd_access(idlevelcid1))
  return 
PLUGIN_HANDLED
 
 
if(!g_DirExist
  
console_print(id"Knife Zone directory does not exist")
 else
  
display_KnifeZone(id)
 
 return 
PLUGIN_HANDLED
}
public 
display_KnifeZone(id)
{
 new 
menuBody[512]
 new 
len format(menuBody511"\yKnife Zone Menu^n")
 
len += format(menuBody[len], 511-len"^n\w1. Create a zone")
 
len += format(menuBody[len], 511-len"^n\r2. Remove all zones")
 
len += format(menuBody[len], 511-len"^n\d3. Exit menu")
 new 
keys = (1<<0|1<<1|1<<2)
 
show_menu(idkeysmenuBody, -1"Knife Zone Menu"
}
public 
action_KnifeZone(idkey)
{
 switch(
key
 {
  case 
0
  {
   if(
zoneID >= MAX_ZONES)
   {
    
client_print(idprint_chat"Max Knife Zones reached")
    return 
PLUGIN_HANDLED
   
}
   
   if(!
is_user_alive(id)) 
   {
    
client_print(idprint_chat"You have to be alive to make a knife zone")
    return 
PLUGIN_HANDLED
   
}
   
   
_makeZone(id)
   
display_KnifeZone(id)
   
client_print(idprint_chat"knife zone created")
  }   
  case 
1
  {
   
_removeZones()
   
display_KnifeZone(id)
   
client_print(idprint_chat"All Knife Zones removed")
  }
 }
 return 
PLUGIN_HANDLED
}
public 
fwd_TraceLine(Float:v1[3], Float:v2[3], noMonstersid)
{  
 if(!
is_user_alive(id))
  return 
FMRES_IGNORED
 
 
new victim get_tr(TR_pHit)
 if(!
is_user_alive(victim))
  return 
FMRES_IGNORED
  
 
new tmp[2], weapon get_user_weapon(victimtmp[0], tmp[1]) 
 if(
weapon == CSW_KNIFE && g_InTheZone[victim])
  
set_tr(TR_flFraction1.0)
  
 return 
FMRES_IGNORED
}
public 
client_PreThink(id)
{
 if(!
task_exists(TASK_ID) || !is_user_alive(id)) 
 {
  
g_ProtectionTime[id] = -1
  g_InTheZone
[id] = false
  
  
return PLUGIN_CONTINUE
 
}
 
 if(!
check_origin(id))
 {
  
g_InTheZone[id] = false
  g_ProtectionTime
[id] = -1
  
  
return PLUGIN_CONTINUE
 
}
 
 new 
protectionDelay get_pcvar_num(cvar_delay)
 if(
g_ProtectionTime[id] < protectionDelay)
 {
  if(
g_fDelay[id] + 1.0 get_gametime())
  {
   
g_ProtectionTime[id] += 1
   g_fDelay
[id] = get_gametime()
  }
  
  
set_hudmessage(25500, -1.0, -1.0__0.5__4)
  
show_hudmessage(id"Protection in %d...", (protectionDelay g_ProtectionTime[id]))
 }
 else if(
g_ProtectionTime[id] >= protectionDelay)
  
g_InTheZone[id] = true
 
 
return PLUGIN_CONTINUE
}
stock check_origin(id)
{
 new 
iOrigin[3]
 
get_user_origin(idiOrigin0)
 
 for(new 
0MAX_ZONES; ++i)
 {
  if((
g_KnifeZoneOrgins[i][OriginX] == 0
  && (
g_KnifeZoneOrgins[i][OriginY] == 0
  && 
g_KnifeZoneOrgins[i][OriginZ] == 0)
   continue
  
  new 
ZoneSizeX get_pcvar_num(cvar_kzsize)
  new 
ZoneSizeY get_pcvar_num(cvar_kzsize)
  new 
ZoneSizeZ get_pcvar_num(cvar_kzsizez)
  
  if((
g_KnifeZoneOrgins[i][OriginX] - iOrigin[0] > ZoneSizeX) || (g_KnifeZoneOrgins[i][OriginX] - iOrigin[0] < -ZoneSizeX
  || (
g_KnifeZoneOrgins[i][OriginY] - iOrigin[1] > ZoneSizeY) || (g_KnifeZoneOrgins[i][OriginY] - iOrigin[1] < -ZoneSizeY)
  || (
g_KnifeZoneOrgins[i][OriginZ] - iOrigin[2] > ZoneSizeZ) || (g_KnifeZoneOrgins[i][OriginZ] - iOrigin[2] < -ZoneSizeZ))
   continue
  return 
true
 
}
 return 
false
}
load_origins(mapname[])
{
 new 
mapFile[64]
 
format(mapFile63"%s/%s.cfg"g_KnifeZoneDirmapname)
 if(!
file_exists(mapFile)) 
 {
  
server_print("There are no Knife Zone(s) for %s"mapname)
  return 
PLUGIN_CONTINUE
 
}
 new 
Text[64], Line 0Len 0
 
while(read_file(mapFileLine++, Text63Len))
 {
  if((
Text[0]==';') || !Len)
    continue
  
  if(
zoneID >= MAX_ZONES)
  {
   
log_amx("Max Knife Zones reached, increase MAX_ZONES")
   break
  }
  
  new 
iOrigin[3][16]
  
parse(TextiOrigin[OriginX], 15iOrigin[OriginY], 15iOrigin[OriginZ], 15)
  
  
g_KnifeZoneOrgins[zoneID][OriginX] = str_to_num(iOrigin[OriginX])
  
g_KnifeZoneOrgins[zoneID][OriginY] = str_to_num(iOrigin[OriginY])
  
g_KnifeZoneOrgins[zoneID][OriginZ] = str_to_num(iOrigin[OriginZ])
  
  
zoneID += 1
 
}
 return 
PLUGIN_CONTINUE
}
save_origin(mapname[], Origin[3])
{
 new 
mapFile[64], Text[64]
 
format(mapFile63"%s/%s.cfg"g_KnifeZoneDirmapname)
 if(!
file_exists(mapFile)) 
 {
  new 
Comments[64]
  
format(Comments63"; Knife Zone origins for %s"mapname)
  
write_file(mapFileComments, -1)
 }
 
 
format(Text64"%i %i %i"Origin[OriginX], Origin[OriginY], Origin[OriginZ])
 
write_file(mapFileText, -1)
}
public 
task_visuals()
{
 for(new 
0MAX_ZONES; ++i)
 {
  if((
g_KnifeZoneOrgins[i][OriginX] == 0
  && (
g_KnifeZoneOrgins[i][OriginY] == 0
  && 
g_KnifeZoneOrgins[i][OriginZ] == 0)
    continue
  
  
create_kzring(g_KnifeZoneOrgins[i])
  
  
 }
}
stock create_kzring(Origin[3])
{
 new 
shape[4][2] = {{1,1}, {-1,1}, {-1,-1}, {1,-1}}
 new 
x1y1x2y2heightij
 
new ZoneSize get_cvar_num("amx_kzsize")
 
 for(
02j++)
 {
  
height = (30 30)
  for(
04i++)
  {
   
x1 = (shape[i][0] * ZoneSize)
   
y1 = (shape[i][1] * ZoneSize)
   if(
3)
   {
    
x2 = (shape[i+1][0] * ZoneSize)
    
y2 = (shape[i+1][1] * ZoneSize)
   }
   else
   {
    
x2 = (shape[0][0] * ZoneSize)
    
y2 = (shape[0][1] * ZoneSize)
   }
   
   
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
   
write_byte(0)
   
write_coord(Origin[OriginX] + x1)
   
write_coord(Origin[OriginY] + y1)
   
write_coord(Origin[OriginZ] + height)
   
write_coord(Origin[OriginX] + x2)
   
write_coord(Origin[OriginY] + y2)
   
write_coord(Origin[OriginZ] + height)
   
write_short(sprite_zbeam)
   
write_byte(0)
   
write_byte(0)
   
write_byte(30)
   
write_byte(15)
   
write_byte(0)
   
write_byte(255)
   
write_byte(0)
   
write_byte(0)  
   
write_byte(100)
   
write_byte(0)
   
message_end()
  }
 }
}
_makeZone(id)
{
 new 
iOrigin[3], CurMap[32]
 
get_user_origin(idiOrigin0)
 
get_mapname(CurMap31)
 
zoneID 0
 save_origin
(CurMapiOrigin)
 
load_origins(CurMap)
 
 if(
task_exists(TASK_ID))
  
remove_task(TASK_ID)
  
 
set_task(1.0"task_visuals"TASK_ID__"b")
}
_removeZones()
{
 new 
MapFile[64], CurMap[32]
 
get_mapname(CurMap31)
 
format(MapFile63"%s/%s.cfg"g_KnifeZoneDirCurMap)
 if(
file_exists(MapFile))
  
delete_file(MapFile)
 
 if(
task_exists(TASK_ID))
  
remove_task(TASK_ID)
 
 
zoneID 0
 
 
for(new 0MAX_ZONES; ++i)
 {
  
g_KnifeZoneOrgins[i][OriginX] = 0
  g_KnifeZoneOrgins
[i][OriginY] = 0
  g_KnifeZoneOrgins
[i][OriginZ] = 0
 
}

__________________

flyeni6 is offline
Send a message via AIM to flyeni6
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 07-10-2007 , 20:19   Re: Bomb planting
Reply With Quote #2

Of course that is probably better, it's made by Cheap Suit. He's by far better at programming then I am.

If you need anymore help I'll be around to 'maybe' assist (depending how confusing it is lol).
hlstriker 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:25.


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