AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Bomb planting (https://forums.alliedmods.net/showthread.php?t=57706)

flyeni6 07-09-2007 16:41

Bomb planting
 
How do i make a specific area anywhere on a map to plant the C4.
(like in de_dust2 want to plant the bomb in a big, visible square at the Ct spawn)

thanks :)

Rolnaaba 07-09-2007 21:37

Re: Bomb planting
 
I am not sure exactly the code to do this, but I would say it would be similar to Hawk552's question about spawning a buyzone found here.

flyeni6 07-09-2007 23:41

Re: Bomb planting
 
k well how do i atlest make an ajustable square. when people enter it they will have godmode. ???

hlstriker 07-10-2007 01:01

Re: Bomb planting
 
I had a very similar problem a few weeks ago.

This thread should tell you what you want about creating the box for god mode.
http://forums.alliedmods.net/showthread.php?t=56983

---[EDIT]----
Also, here is a very very fast plugin I whipped up to help me get the coords for where to place the box in the map.
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <engine>

#define PLUGIN "Box Coord Finder"
#define VERSION "1.0"
#define AUTHOR "hlstriker"

new x1;
new 
x2;
new 
y1;
new 
y2;
new 
z1;
new 
z2;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_clcmd("say /x1""getx1");
    
register_clcmd("say /x2""getx2");
    
register_clcmd("say /y1""gety1");
    
register_clcmd("say /y2""gety2");
    
register_clcmd("say /z1""getz1");
    
register_clcmd("say /z2""getz2");
    
register_clcmd("say /center""showCenter");
}

public 
getx1(id)
{
    new 
origin[3];
    
    
get_user_origin(idorigin3);
    
    
x1 origin[0];
    
client_print(0print_chat"X 1 = %d"x1);
    
    return 
PLUGIN_CONTINUE;
}

public 
getx2(id)
{
    new 
origin[3];
    
    
get_user_origin(idorigin3);
    
    
x2 origin[0];
    
client_print(0print_chat"X 2 = %d"x2);
    
    return 
PLUGIN_CONTINUE;
}

public 
gety1(id)
{
    new 
origin[3];
    
    
get_user_origin(idorigin3);
    
    
y1 origin[1];
    
client_print(0print_chat"Y 1 = %d"y1);
    
    return 
PLUGIN_CONTINUE;
}

public 
gety2(id)
{
    new 
origin[3];
    
    
get_user_origin(idorigin3);
    
    
y2 origin[1];
    
client_print(0print_chat"Y 2 = %d"y2);
    
    return 
PLUGIN_CONTINUE;
}

public 
getz1(id)
{
    new 
origin[3];
    
    
get_user_origin(idorigin3);
    
    
z1 origin[2];
    
client_print(0print_chat"Z 1 = %d"z1);
    
    return 
PLUGIN_CONTINUE;
}

public 
getz2(id)
{
    new 
origin[3];
    
    
get_user_origin(idorigin3);
    
    
z2 origin[2];
    
client_print(0print_chat"Z 2 = %d"z2);
    
    return 
PLUGIN_CONTINUE;
}

public 
showCenter(id)
{
    new 
xDisyDiszDis;
    new 
xyz;
    
    if(
x1 x2)
    {
        
xDis = (x1 x2) / 2;
        
x2 xDis;
    }
    else if(
x1 x2)
    {
        
xDis = (x2 x1) / 2;
        
x1 xDis;
    }
    else
    {
        
client_print(0print_chat"You must first get the X distances.");
        return 
PLUGIN_HANDLED;
    }
    
    if(
y1 y2)
    {
        
yDis = (y1 y2) / 2;
        
y2 yDis;
    }
    else if(
y1 y2)
    {
        
yDis = (y2 y1) / 2;
        
y1 yDis;
    }
    else
    {
        
client_print(0print_chat"You must first get the Y distances.");
        return 
PLUGIN_HANDLED;
    }
    
    if(
z1 z2)
    {
        
zDis = (z1 z2) / 2;
        
z2 zDis;
    }
    else if(
z1 z2)
    {
        
zDis = (z2 z1) / 2;
        
z1 zDis;
    }
    else
    {
        
client_print(0print_chat"You must first get the Z distances.");
        return 
PLUGIN_HANDLED;
    }
    
    
client_print(0print_chat"ENT COORDS = [X = %d] - [Y = %d] - [Z = %d]"xyz);
    
client_print(0print_chat"RADIUS' = [X = %d] - [Y = %d] - [Z = %d]"xDisyDiszDis);
    
    
// Set box
    
new ent create_entity("info_target");
    new 
Float:origin[3];
    
origin[0] = float(x);
    
origin[1] = float(y);
    
origin[2] = float(z);
    
    
entity_set_origin(entorigin);
    
    new 
Float:mins[3], Float:maxs[3];
    
mins[0] = origin[0] - float(xDis);
    
mins[1] = origin[1] - float(yDis);
    
mins[2] = origin[2] - float(zDis);
    
    
maxs[0] = origin[0] + float(xDis);
    
maxs[1] = origin[1] + float(yDis);
    
maxs[2] = origin[2] + float(zDis);
    
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
    
write_byte(31); // TE_BOX
    
write_coord(floatround(mins[0])); // boxmins
    
write_coord(floatround(mins[1]));
    
write_coord(floatround(mins[2]));
    
write_coord(floatround(maxs[0])); // boxmaxs
    
write_coord(floatround(maxs[1]));
    
write_coord(floatround(maxs[2]));
    
write_short(200); // life in 0.1 s (200 = 20 sec)
    
write_byte(255); // r
    
write_byte(0); // g
    
write_byte(0); // b
    
message_end();
    
    
remove_entity(ent);
    
    return 
PLUGIN_CONTINUE;


To use it all you have to do is look at every 'face' of where the box should go and type the correct origin.
Example:
- Pretend you are in a square room.
- Look straight at the wall in front of you, type /x1
- Look straight at the wall opposite from the wall you just looked at, type /x2
- Look at the side wall, type /y1
- Look at the opposite side wall, type /y2
- Look at the ceiling, type /z1
- Look at the floor, type /z2
- Now type /center
- A box outlined in little dots should appear and it should give you all the needed coords.
Note: the /y and /x commands depend on the origin the wall is facing, so use the right ones.

Sorry I'm extremely tired and explained this very poorly :P

flyeni6 07-10-2007 09:40

Re: Bomb planting
 
thank you hlstriker. do you know i way i can set that to be a place where you can plant a bomb in it?

Alka 07-10-2007 09:47

Re: Bomb planting
 
Make that ent and set classname! This should do the trick
Code:

set_pev(entity, pev_classname, "func_bomb_target");
or info_bomb_target , dunno exactly! :wink:

flyeni6 07-10-2007 09:56

Re: Bomb planting
 
thx alka :)

flyeni6 07-10-2007 17:17

Re: Bomb planting
 
hlstriker i followed the directions and i can only see one side of the box and its really big. is it supposed to be like this>?

flyeni6 07-10-2007 17:40

Re: Bomb planting
 
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
 
}



hlstriker 07-10-2007 20:19

Re: Bomb planting
 
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).


All times are GMT -4. The time now is 21:25.

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