AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   BombSites Origins [ Solved ] (https://forums.alliedmods.net/showthread.php?t=240481)

HamletEagle 05-16-2014 10:41

BombSites Origins [ Solved ]
 
So , I want to know in which bomb site the bomb is. So, I'm getting bomb origin when it's planted and the bomb sites origins.
From now, I tryed a lot of things but they aren't working. So, do you have an ideea about this ?How should I check if the origins match ?

If it is needed, I'll post here my code.

NikKOo31 05-16-2014 12:04

Re: BombSites Origins
 
Hmm not tested but it will help you :)

PHP Code:

/* Plugin generated by AMXX-Studio */

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

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define MAX_BS 2

new const site_name[][] =
{
    
"Site A",
    
"Site B",
    
"Site C"
    
//etc
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_logevent("bomb_planted"3"2=Planted_The_Bomb")
}

public 
bomb_planted()
{
    new 
sites_ent[MAX_BS]
    new 
Float:sites_origin[MAX_BS][3]
    new 
Float:c4_origin[3]
    new 
sites find_bs(sites_entsites_origin)
    new 
c4 find_c4(c4_origin)
    
    if(!
sites || !c4)
        return

    
//new planted_site = sites_ent[0]
    
new Float:planted_origin[3]
    
planted_origin[0] = sites_origin[0][0]
    
planted_origin[1] = sites_origin[0][1]
    
planted_origin[2] = sites_origin[0][2]
    new 
site 0
    
for(new 1sitesi++)
    {
        if(
get_distance_f(c4_originplanted_origin) > get_distance_f(c4_originsites_origin[i]))
        {
            
planted_origin[0] = sites_origin[i][0]
            
planted_origin[1] = sites_origin[i][1]
            
planted_origin[2] = sites_origin[i][2]
            
//planted_site = sites_ent[i]
            
site i
        
}
    }
    
    
client_print(0print_chat"Bomb planted on %s"site_name[site])
    
client_print(0print_chat"Bomb site origin %.0f %.0f %.0f"planted_origin[0], planted_origin[1], planted_origin[2])
    
    return
}

stock find_bs(bs_ent[MAX_BS], Float:bs_origin[MAX_BS][3])
{
    new 
bs_found 0
    bs_ent
[0] = -1
    
for(new 0MAX_BSi++)
    {
        
bs_ent[i] = engfunc(EngFunc_FindEntityByStringbs_ent[i], "classname""func_bomb_target")
        if(
MAX_BS 1)
            
bs_ent[i+1] = bs_ent[i]
        
bs_found++
        
get_brush_entity_origin(bs_ent[i], bs_origin[i])
    }
    return 
bs_found
}

stock find_c4(Float:origin[3])
{
    new 
ent = -1
    
while((ent engfunc(EngFunc_FindEntityByStringent"classname""grenade")) && (!(get_pdata_int(ent96) & (1<<8)))) { }
    if(
ent)
    {
        
pev(entpev_originorigin)
        return 
1
    
}
    return 
0


Also, some maps have swapped the site names. I saw a plugin that has a stock to correct that, I can't remember the name right now

HamletEagle 05-16-2014 12:26

Re: BombSites Origins
 
It helps a lot, I will test to understand why my code didn't work, since it is something like this. Thx.

meTaLiCroSS 05-16-2014 20:54

Re: BombSites Origins
 
What do you want to do? Get bomb's origin, or get bombsite origin?

ezio_auditore 05-16-2014 23:55

Re: BombSites Origins
 
Quote:

Originally Posted by HamletEagle (Post 2138570)
So , I want to know in which bomb site the bomb is. So, I'm getting bomb origin when it's planted and the bomb sites origins.
From now, I tryed a lot of things but they aren't working. So, do you have an ideea about this ?How should I check if the origins match ?

If it is needed, I'll post here my code.

He wants both the bomb's and bombsite's origin

ezio_auditore 05-16-2014 23:57

Re: BombSites Origins
 
For bomb's origin, you may try
Code:
#include <amxmodx> #include <csx> #include <fakemeta_util> new Float:f_bOrigin[3] public plugin_init(){     register_plugin("x", "x", "x") } public bomb_planted(planter) {     new iBomb; isPlanted = true     if ((iBomb = fm_find_ent_by_model(-1, "grenade", "models/w_c4.mdl")))     {               pev(iBomb, pev_origin, f_bOrigin)     } }

meTaLiCroSS 05-17-2014 02:27

Re: BombSites Origins
 
Or better:

https://wiki.alliedmods.net/Half-Lif...vents#BombDrop

HamletEagle 05-17-2014 05:29

Re: BombSites Origins
 
I didn't asked how to find them. I asked something differently,how to compare the bomb and bomb sites origins. Questions is solved as I sai above.


All times are GMT -4. The time now is 09:36.

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