Raised This Month: $ Target: $400
 0% 

Fixing Invisible man Plugin. Need help T_T


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dekken
Veteran Member
Join Date: Jul 2007
Old 05-31-2008 , 07:26   Fixing Invisible man Plugin. Need help T_T
Reply With Quote #1

well awhile ago X-Olent made a mod for my request..Invisible man
and now it doesnt work that well

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>

new bool:gModOn true;
new 
gMsgSayText;
new 
gMaxPlayers;

public 
plugin_init()
{
    
register_plugin("Invisible Mod""1.0""Exolent");
    
register_concmd("amx_invismod""cmd_invismod"ADMIN_KICK"<1|0> -- turns on/off Invisible Mod");
    
register_clcmd("say /invishelp""cmd_invishelp");
    
register_event("ResetHUD""event_ResetHUD""be");
    
register_event("DeathMsg""event_DeathMsg""a");
    
register_forward(FM_PlayerPreThink"fm_PreThink"0);
    
gMsgSayText get_user_msgid("SayText");
    
gMaxPlayers get_maxplayers();
    
set_task(2.0"set_cvars");
    
set_task(10.0"show_reminder");
}

public 
set_cvars()
{
    
server_cmd("mp_limitteams %d"gMaxPlayers);
    
server_cmd("humans_join_team ct");
    
server_cmd("mp_autoteambalance 0");
}

public 
show_reminder()
{
    if(
gModOn)
        
green_msg(0"[INVIS] New to Invisible Mod? Type /invishelp to learn more!");
    
set_task(180.0"show_reminder");
}

public 
cmd_invismod(idlevelcid)
{
    if(!
cmd_access(idlevelcid2))
        return 
PLUGIN_HANDLED;
    
    new 
arg[4], num;
    
read_argv(1arg3);
    
num str_to_num(arg);
    if(
num || num 0)
        
num 0;
    new 
message[4];
    new 
bool:change false;
    if(
num && !gModOn)
    {
        
gModOn true;
        
formatex(message3"on");
        
change true;
    }
    else if(!
num && gModOn)
    {
        
gModOn false;
        
formatex(message3"off");
        
change true;
    }
    if(
change)
    {
        new 
name[32];
        
get_user_name(idname31);
        switch(
get_cvar_num("amx_show_activity"))
        {
            case 
2client_print(0print_chat"[AMXX] ADMIN %s: turned %s Invisible Mod!"namemessage);
            case 
1client_print(0print_chat"[AMXX] ADMIN: turned %s Invisible Mod!"message);
        }
        
console_print(id"[AMXX] Turned %s Invisible Mod"message);
    }
    return 
PLUGIN_HANDLED;
}

public 
cmd_invishelp(id)
{
    if(
gModOn)
    {
        
console_print(id"[==============[INVISIBLE MOD]==============]");
        
console_print(id"Invisible Mod is a game in which there is only one Terrorist.");
        
console_print(id"That Terrorist is invisible and only has a knife.");
        
console_print(id"All of the other players are placed on Counter-Terrorist and can buy any weapon they choose.");
        
console_print(id"To become to invisible Terrorist, you must kill the current one.");
        
console_print(id"[===========================================]");
        
green_msg(id"[INVIS] Explanation has been printed in your console.");
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}

public 
event_DeathMsg()
{
    if(
gModOn)
    {
        new 
killer read_data(1);
        new 
victim read_data(2);
        new 
CsTeams:kteam cs_get_user_team(killer);
        new 
CsTeams:vteam cs_get_user_team(victim);
        if(
kteam == CS_TEAM_CT && vteam == CS_TEAM_T)
        {
            new 
kname[32], vname[32];
            
get_user_name(killerkname31);
            
get_user_name(victimvname31);
            
green_msg(0"[INVIS] %s killed the invisible Terrorist, %s!"knamevname);
            
green_msg(0"[INVIS] %s is now the invisible Terrorist!"kname);
            
cs_set_user_team(killerCS_TEAM_T);
            
cs_set_user_team(victimCS_TEAM_CT);
        }
    }
}

public 
event_ResetHUD(id)
{
    if(
gModOn)
    {
        
set_task(1.0"start_cloaking"id);
        
set_task(2.0"set_weapons"id);
    }
}

public 
set_weapons(id)
{
    
fm_strip_weapons(id);
    new 
CsTeams:team cs_get_user_team(id);
    if(
team == CS_TEAM_CT)
    {
        
fm_give_item(id"weapon_knife");
        
fm_give_item(id"weapon_usp");
        
fm_give_item(id"ammo_45acp");
        
fm_give_item(id"ammo_45acp");
        switch(
random_num(01))
        {
            case 
0:
            {
                
fm_give_item(id"weapon_ak47");
                
fm_give_item(id"ammo_762nato");
                
fm_give_item(id"ammo_762nato");
                
fm_give_item(id"ammo_762nato");
            }
            case 
1:
            {
                
fm_give_item(id"weapon_m4a1");
                
fm_give_item(id"ammo_556nato");
                
fm_give_item(id"ammo_556nato");
                
fm_give_item(id"ammo_556nato");
            }
        }
    }
    else if(
team == CS_TEAM_T)
    {
        
fm_give_item(id"weapon_knife");
    }
}

public 
fm_PreThink(id)
{
    if(
gModOn)
    {
        new 
CsTeams:team cs_get_user_team(id);
        new 
clipammo;
        new 
weapon get_user_weapon(idclipammo);
        if(
team == CS_TEAM_T)
        {
            if(
weapon != CSW_KNIFE)
            {
                
set_weapons(id);
                
green_msg(id"[INVIS] You cannot have that weapon during Invisible Mod!");
            }
        }
        else if(
team == CS_TEAM_CT)
        {
            if(
weapon != CSW_KNIFE
            
&& weapon != CSW_SMOKEGRENADE
            
&& weapon != CSW_HEGRENADE
            
&& weapon != CSW_FLASHBANG
            
&& weapon != CSW_AK47
            
&& weapon != CSW_M4A1
            
&& weapon != CSW_USP)
            {
                
set_weapons(id);
                
green_msg(id"[INVIS] You cannot have that weapon during Invisible Mod!");
            }
        }
    }
}

public 
start_cloaking(id)
{
    if(
is_user_alive(id))
    {
        new array[
2];
        array[
0] = id;
        array[
1] = 240;
        
set_task(0.1"finish_cloaking"0, array, 2);
    }
}

public 
finish_cloaking(array[])
{
    if(
is_user_alive(array[0]))
    {
        
set_cloak(array[0], array[1]);
        if(array[
1] == 0) return;
        array[
1] -= 24;
        
set_task(0.1"finish_cloaking"0, array, 2);
    }
}

public 
anti_cloak_start(id)
{
    if(
is_user_alive(id))
    {
        new array[
2];
        array[
0] = id;
        array[
1] = 15;
        
set_task(0.1"anti_cloak_finish"0, array, 2);
    }
}

public 
anti_cloak_finish(array[])
{
    if(
is_user_alive(array[0]))
    {
        
set_cloak(array[0], array[1]);
        if(array[
1] == 255) return;
        array[
1] += 24;
        
set_task(0.1"anti_cloak_finish"0, array, 2);
    }
}

public 
set_cloak(idamount)
{
    
set_pev(idpev_rendermodekRenderTransAlpha);
    
set_pev(idpev_renderamtfloat(amount));
}

public 
fm_strip_weapons(id)
{
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"player_weaponstrip"));
    if(
pev_valid(ent))
    {
        
dllfunc(DLLFunc_Spawnent);
        
dllfunc(DLLFunc_Useentid);
        
engfunc(EngFunc_RemoveEntityent);
    }
}

public 
fm_give_item(id, const item[])
{
    if(!
equal(item"weapon_"7) && !equal(item"ammo_"5) && !equal(item"item_"5) && !equal(item"tf_weapon_"10))
    {
        return 
0;
    }
    
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringitem));
    if(!
pev_valid(ent))
    {
        return 
0;
    }
    
    new 
Float:origin[3];
    
pev(idpev_originorigin);
    
set_pev(entpev_originorigin);
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN);
    
dllfunc(DLLFunc_Spawnent);
    
    new 
save pev(entpev_solid);
    
dllfunc(DLLFunc_Touchentid);
    if(
pev(entpev_solid) != save)
    {
        return 
ent;
    }
    
    
engfunc(EngFunc_RemoveEntityent);
    return -
1;
}

public 
green_msg(id, const message[], {Float,Sql,Result,_}:...)
{
    static 
msg[192];
    
msg[0] = 0x04;
    
    
vformat(msg[1], 190message3);
    
    if(
id && id <= 32)
    {
        
message_begin(MSG_ONEgMsgSayText, {000}, id);
        
write_byte(id);
        
write_string(msg);
        
message_end();
    }
    else if(
id == 0)
    {
        for(new 
1<= gMaxPlayersi++)
        {
            if(
is_user_connected(i))
            {
                
message_begin(MSG_ONEgMsgSayText, {000}, i);
                
write_byte(i);
                
write_string(msg);
                
message_end();
            }
        }
    }

The Current bugs i found:

it will sometimes Spam with the Message:
Code:
[INVIS] You cannot have that weapon during Invisible Mod!
While you spawn..

Second issue and thats the biggest one so far...
There's supposed to be One invisible man...but Sometimes CT's get invisible too and sometimes none gets invisible..

Someone could probably write this from scratch...

If anyone could fix this...it would be Awesome
thanks!
__________________
Signature Goes Here
dekken 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 08:35.


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