AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problems making bomb transfer.. (https://forums.alliedmods.net/showthread.php?t=48484)

SweatyBanana 12-12-2006 23:37

Problems making bomb transfer..
 
Well I am using part of VEN's plugin, but it wont transfer the bomb.

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <fakemeta>

#define    FL_ONGROUND (1<<9)

new index,cvar1,cvar2,cvar3,cvar4,cvar5,cvar6;
new 
Float:startFloat:endFloat:burytime;
new 
origin[3];

public 
plugin_init()
{
    
register_plugin("Bomb Drop Slay","0.5","SweatyBanana");

    
register_dictionary("bombdict.txt")

    
// bomb status
    // 1 - plugin on
    // 0 - plugin off
    
cvar1 register_cvar("bomb_status","1");
    
cvar2 register_cvar("bomb_time","10.0");
    
cvar3 register_cvar("bomb_punish","1");
    
cvar4 register_cvar("bomb_slaphealth","50");
    
cvar5 register_cvar("bomb_burytime","10.0");
    
cvar6 register_cvar("bomb_transfer","1");


    if(
engfunc(EngFunc_FindEntityByString, -1"classname""func_bomb_target") > 0)
    {
        
register_logevent("f_spawned"3"2=Spawned_With_The_Bomb")
        
register_logevent("f_dropped"3"2=Dropped_The_Bomb")
    }
}

public 
f_spawned()
{
    if(
get_pcvar_num(cvar1)==0)
        return 
PLUGIN_HANDLED;

    
index get_loguser_index();
    
start get_gametime();

    return 
PLUGIN_CONTINUE;
}

public 
f_dropped()
{
    new 
user get_loguser_index();
    if(
get_pcvar_num(cvar1)==|| !is_user_alive(user))
        return 
PLUGIN_HANDLED;

    
end get_gametime();
    if(
user==index && end-start<=get_pcvar_float(cvar2))
    {
        
f_punishuser(index);
    }

    return 
PLUGIN_CONTINUE;
}

public 
f_punishuser(index)
{
    new 
punishment get_pcvar_num(cvar3);
    new 
starthealth get_user_health(index);
    new 
slaphealth get_pcvar_num(cvar4);
    new 
transfer get_pcvar_num(cvar6);
    
burytime get_pcvar_float(cvar5);

    if(
slaphealth<|| burytime<0.0)
    {
        
slaphealth 50;
        
burytime 10.0;
    }

    new 
Name[33];
    
get_user_name(index,Name,32);
    
set_hudmessage(25500, -1.00.006.012.0);

    switch(
punishment)
    {
        case 
1:
        {
            
user_kill(index,0);
            
show_hudmessage(0,"%L",LANG_SERVER,"SLAY",Name);
        }
        case 
2:
        {
            
user_slap(index,slaphealth);
            
show_hudmessage(0,"%L",LANG_SERVER,"SLAP",Name,starthealth-slaphealth);
        }
        case 
3:
        {
            
set_task(0.1,"f_bury",index);
            
show_hudmessage(0,"%L",LANG_SERVER,"BURY",Name,floatround(burytime,floatround_floor));
        }
    }

    if(
transfer == 1)
    {
        new 
user[32],num,x;
        
get_players(user,num,"ae","TERRORIST")

        
get_user_origin(index,origin)
        new 
min_dist 999999,dist,recipient,origin2[3];
        for(new 
0;num;++i)
        {
            
user[i]

            
get_user_origin(x,origin2)
            
dist get_distance(origin,origin2)
            if(
dist min_dist)
            {
                
min_dist dist
                recipient 
x
            
}
        }

        if(
num<2)
        {
            return 
PLUGIN_HANDLED;
        }

        new 
c4 engfunc(EngFunc_FindEntityByString,-1,"classname","weapon_c4"// find weapon_c4 entity
        
if(!c4)
            return 
PLUGIN_HANDLED;

        new 
backpack pev(c4,pev_owner// get backpack entity
        
if(backpack <= get_maxplayers())
            return 
PLUGIN_HANDLED;

        
set_pev(backpack,pev_flags,pev(backpack,pev_flags)|FL_ONGROUND)
        
dllfunc(DLLFunc_Touch,backpack,recipient)
    }
    return 
PLUGIN_HANDLED;
}

public 
f_bury(index)
{
    
get_user_origin(index,origin);
    
origin[2] -= 50;
    
set_user_origin(index,origin);
    
set_task(burytime,"f_unbury",index);
}

public 
f_unbury(index)
{
    
get_user_origin(index,origin);
    
origin[2] += 50;
    
set_user_origin(index,origin);
    
client_print(index,print_chat,"%L",LANG_SERVER,"UNBURY");
}

stock get_loguser_index()
{
    new 
loguser[80],name[32]

    
read_logargv(0,loguser,79)
    
parse_loguser(loguser,name,31)

    return 
get_user_index(name)



The Specialist 12-13-2006 03:17

Re: Problems making bomb transfer..
 
why dont you try something like
Code:
fm_strip_user_gun(id,"weapon_c4") fm_tranfer_user_gun() or fm_give_item(id,weapon_c4")

any combination of those should work

SweatyBanana 12-13-2006 03:56

Re: Problems making bomb transfer..
 
It should have the same affect as the other. But i am not forcing a drop.

dutchmeat 12-13-2006 04:52

Re: Problems making bomb transfer..
 
You should try not to combine new var + value , and new var:

new min_dist = 999999,dist,recipient,origin2[3];
should be:
new min_dist = 999999
new
dist,recipient,origin2[3];

P34nut 12-13-2006 07:27

Re: Problems making bomb transfer..
 
Quote:

Originally Posted by dutchmeat (Post 414826)
You should try not to combine new var + value , and new var:

new min_dist = 999999,dist,recipient,origin2[3];
should be:
new min_dist = 999999
new
dist,recipient,origin2[3];

There is nothing wrong with that...

SweatyBanana 12-13-2006 09:22

Re: Problems making bomb transfer..
 
Anybody got any ideas?

dutchmeat 12-13-2006 09:52

Re: Problems making bomb transfer..
 
Where does the function stop working? debug it please

nick123 12-13-2006 11:50

Re: Problems making bomb transfer..
 
hmm i got an idea!.

use find_ent_in_sphere to find the closest ent, check if it's index is between 32 and 1, then check if it's a te play. easy!

SweatyBanana 12-13-2006 12:03

Re: Problems making bomb transfer..
 
You are an idiot.

dutchmeat 12-13-2006 13:34

Re: Problems making bomb transfer..
 
Quote:

Originally Posted by SweatyBanana (Post 414938)
You are an idiot.

I hope you're refering referring to nick


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

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