Raised This Month: $12 Target: $400
 3% 

Want to remove round end block feature from osdm


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shubhamgulati12
Senior Member
Join Date: Oct 2010
Location: Inida The Holy Place!!
Old 12-17-2012 , 00:54   Want to remove round end block feature from osdm
Reply With Quote #1

I wanted to remove round end feature in osdm , because it is making a bad bug that players gets respawned with no weapons but with invisiblity and spectate type mod in which they cant play ..
It happens after a person dies..
So just wanted to remove the round end block , i tried removing it myself but compilation showed errors..
Here is .sma :
PHP Code:
#include <amxmisc>
#include <cstrike>
#include <fakemeta_util>
#include <hamsandwich>
#include <fun>

#define PLUGIN    "OWDM"
#define PLUGIN_IDENTIFIER "[OWDM]" 
#define AUTHOR    "sake"
#define VERSION    "1.1"

#define key_all      MENU_KEY_0 | MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_9

enum Weapon
{
    
M4A1,
    
AK47,
    
SG552,
    
AUG,
    
M3,
    
MP5,
    
PARA,
    
AWP,
    
SCOUT,
    
P90,
    
XM1014,
    
MAC10,
    
UMP45,
    
TMP,
    
G3SG1,
    
SG550,
    
DEAGLE,
    
GALIL,
    
FAMAS,
    
USP,
    
GLOCK,
    
ELITE,
    
FIVESEVEN,
    
P228,
    
COUNT
}

new const 
g_weapon_name[Weapon][] =
{
    
"weapon_m4a1",
    
"weapon_ak47",
    
"weapon_sg552",
    
"weapon_aug",
    
"weapon_m3",
    
"weapon_mp5navy",
    
"weapon_m249",
    
"weapon_awp",
    
"weapon_scout",
    
"weapon_p90",
    
"weapon_xm1014",
    
"weapon_mac10",
    
"weapon_ump45",
    
"weapon_tmp",
    
"weapon_g3sg1",
    
"weapon_sg550",
    
"weapon_galil",
    
"weapon_famas",
    
"weapon_deagle",
    
"weapon_usp",
    
"weapon_glock18",
    
"weapon_elite",
    
"weapon_fiveseven",
    
"weapon_p228",
    
""
};

new const 
g_weapon_ammo[Weapon][] =
{
    
"556nato",
    
"762nato",
    
"556nato",
    
"556nato",
    
"buckshot",
    
"9mm",
    
"556natobox",
    
"338magnum",
    
"762nato",
    
"57mm",
    
"buckshot",
    
"45acp",
    
"45acp",
    
"9mm",
    
"762nato",
    
"556nato",
    
"ammo_556nato",
    
"ammo_556nato",
    
"50ae",
    
"45acp",
    
"9mm",
    
"9mm",
    
"57mm",
    
"357sig",
    
""
};

//CVAR for spawnprotection
new sv_godmodetime;
new 
Float:g_godModeTime;

//CVAR for Weapon
new sv_weapon;
new 
Weapon:g_weapon;

//vars for RoundEndBlocking
new g_botnum 0;
new 
g_bots[2];
new 
g_failCount 0;
new const 
g_names[2][] = {"OWDM RoundEndBlocker1","OWDM RoundEndBlocker2"};
new const 
g_botCreateNumber 6;
new const 
g_botKickNumber 10;

//various global vars
new bool:g_firstTeamJoin[32] = {true, ...}
new 
g_players 0;
new 
g_maxPlayers 0;

public 
plugin_init()
{
    if(
cstrike_running())
    {
        
register_plugin(PLUGINVERSIONAUTHOR);
        
initVars();
        
blockMessages();
        
registerEvents();        
        
registerClCommands()
        
registerSayCommands();
    }
}

initVars()
{
    
sv_godmodetime register_cvar("sv_godmodetime","1.5",FCVAR_SERVER);
    
g_godModeTime get_pcvar_float(sv_godmodetime);
    
sv_weapon register_cvar("sv_weapon","0",FCVAR_SERVER);
    
g_weapon Weapon:get_pcvar_num(sv_weapon);
    if(
g_weapon >= COUNT || g_weapon M4A1)
    {
        
g_weapon M4A1;
    }
    
g_maxPlayers get_maxplayers();
}

registerSayCommands()
{
    
register_clcmd("say /respawn""respawnPlayer"0);
    
register_clcmd("say respawn""respawnPlayer"0);
    
register_clcmd("say /ammo","giveAmmo",0);
    
register_clcmd("say ammo","giveAmmo",0);
}

registerEvents()
{
    
register_event("DeathMsg""playerKilled""a");
    
register_event("TeamInfo""teamAssigned""a");
    
register_event("SendAudio""roundEnd""a""2&%!MRAD_terwin""2&%!MRAD_ctwin");
    
RegisterHam(Ham_Spawn,"player","playerSpawned",1);
}

blockMessages()
{
    
set_msg_block(get_user_msgid("ClCorpse"),BLOCK_SET);
    
set_msg_block(get_user_msgid("StatusIcon"),BLOCK_SET);
}

registerClCommands()
{
    
register_clcmd("buy""blockCmd");
    
register_clcmd("buyequip""blockCmd");
}

/////////////////////////////////////Forwarded Functions//////////////////////////////////////

/*
* make sure everything is back to default, playernumber+1, maybe kick bots
*/
public client_connect(id)
{
    
g_firstTeamJoin[id-1] = true;
    
g_players++;
    if(
g_botnum && g_players g_botKickNumber)
    {
        
kickBots();
    }
}

/*
* If user disconnects the weapon are set back to default
*/
public client_disconnect(id)
{
    
g_players--;
}

/*
* Kick all bots at the end of the map
*/
public plugin_end()
{
    
kickBots();
}

/*
* Kick all bots on plugin_pause
*/
public plugin_pause()
{
    
kickBots();
}

/////////////////////////////////////EventHandling Functions//////////////////////////////////////

/*
* prevents commands
*/
public blockCmd(id)
{
    return 
PLUGIN_HANDLED;
}

/*
* create RoundEndBlockers at the end of the first round.
*/
public roundEnd()
{
    if(
g_players >= g_maxPlayers -|| g_players g_botCreateNumber)
    {
        return;
    }
    while(
g_botnum && g_failCount 5)
    {
        
createBot();
    }
}

/*
* function for respawning on death
*/
public playerKilled()
{
    new 
victim read_data(2);
    
set_task(0.5,"spawnPlayer",victim);
    return 
PLUGIN_CONTINUE;
}

/*
* called on spawn, if user is bot he gets default weapons, if not he can decide (showWeapons).
* Spawnprotection is turned on
*/
public playerSpawned(id)
{
    if(
id == g_bots[0])
    {
        
cs_set_user_team(id,CS_TEAM_CT);
        
hideBot(id);
    }
    else if(
id == g_bots[1])
    {
        
cs_set_user_team(id,CS_TEAM_T);
        
hideBot(id);
    }
    if(
is_user_alive(id) && id <= 32)
    {
        
set_task(0.1,"startGodMode",id);
        
set_task(g_godModeTime+0.1,"stopGodMode",id);
        
giveWeapon(id);
        if(
callfunc_begin("spawn_Preset","csdm_spawn_preset.amxx") == 1)
        {
            
callfunc_push_int(id);
            
callfunc_push_int(1);
            
callfunc_end();
        }
    }    
}

/////////////////////////////////////RoundendBlocker Functions//////////////////////////////////////

/*
* Kicks the bots
* //dllfunc(DLLFunc_ClientDisconnect, g_bots[0]);
* //engfunc(EngFunc_FreeEntPrivateData, g_bots[0]);
*/
public kickBots()
{
    if(
g_bots[0] && is_user_connected(g_bots[0]))
    {
        
server_print("[OWDM - RoundEndBlocker] Kicking bot!");
        
server_cmd("kick #%d"get_user_userid(g_bots[0]));
        
g_botnum--;
    }
    if(
g_bots[1] && is_user_connected(g_bots[1]))
    {
        
server_print("[OWDM - RoundEndBlocker] Kicking bot!");
        
server_cmd("kick #%d"get_user_userid(g_bots[1]));
        
g_botnum--;
    }
}

/*
* Creates 1 RoundEndBlocker. If fails 4 times no more Bots will be created on this map
*/
public createBot()
{
    new 
bot;
    
bot engfunc(EngFunc_CreateFakeClientg_names[g_botnum]);
    if(!
bot
    {
        
server_print("[OWDM - RoundEndblocker] Error!");
        
g_failCount++;
        if(
g_failCount 4)
        {
            
kickBots();
        }
        return;
    }
    new 
ptr[128];
    
engfunc(EngFunc_FreeEntPrivateDatabot);
    
dllfunc(DLLFunc_ClientConnectbotg_names[g_botnum], "127.0.0.1"ptr);
    if(!
is_user_connected(bot)) 
    {
        
server_print("[OWDM - RoundEndblocker] Error: %s"ptr);
        return;
    }
    
dllfunc(DLLFunc_ClientPutInServerbot);
    
set_pev(botpev_spawnflagspev(botpev_spawnflags) | FL_FAKECLIENT);
    
set_pev(botpev_flagspev(botpev_flags) | FL_FAKECLIENT);
    
cs_set_user_team(botg_botnum CS_TEAM_T CS_TEAM_CT);
    
server_print("[OWDM - RoundEndblocker] ^"%s^" has been created."g_names[g_botnum]);
    
g_bots[g_botnum++] = bot;
    
g_failCount 0;
}

/*
* makes RoundEndBlockers to "Spectators"
*/
public hideBot(bot)
{
    
set_pev(botpev_effectspev(botpev_effects) | EF_NODRAW);
    
set_pev(botpev_solidSOLID_NOT);
    
set_pev(botpev_takedamageDAMAGE_NO);
    
engfunc(EngFunc_SetOriginbotFloat:{9999.09999.09999.0});
    new 
msgTeamInfo get_user_msgid("TeamInfo");
    
message_begin(MSG_ALLmsgTeamInfo);
    
write_byte(bot);
    
write_string("SPECTATOR");
    
message_end();
}

/////////////////////////////////////Spawnprotection & Color Functions//////////////////////////////////////

/*
* lets entities glow in a defined color
*/
public glow(idcolor[3],amt)
{
    
set_user_rendering(id,kRenderFxGlowShell,color[0],color[1],color[2],kRenderNormal,amt);
}

/*
* unglows entities. back to normal
*/
public unglow(id)
{
    
set_user_rendering(id,kRenderFxNone,0,0,0,kRenderNormal,0);
}


/*
* used to start the godmode. Lets the user glow. (both only when he is alive (to prevent possible bug?))
*/
public startGodMode(id)
{
    if(!
is_user_alive(id) || id 32)
    {
        return;
    }
    
fm_set_user_godmode(id,1);
    if(
get_user_team(id) == 1)
    {
        
glow(id,{255,0,0},25);
    }
    if(
get_user_team(id) == 2)
    {
        
glow(id,{0,0,255},25);
    }
}

/*
* used to stop the godmode. Only if user is connected (so he isn't dead or left the game)
*/
public stopGodMode(id)
{
    if(!
is_user_connected(id) || id 32)
    {
        return;
    }
    
fm_set_user_godmode(id,0);
    
unglow(id);
}

/////////////////////////////////////Respawning, giving Weapons, Teams, etc.//////////////////////////////////////

/*
* method for giving users weapons
*/
public giveWeapon(id)
{
    if(
id <= 32 && is_user_alive(id))
    {
        
strip_user_weapons(id);
        
cs_set_user_armor(id,100,CS_ARMOR_VESTHELM);
        
        
//give the user the primary weapon he has chosen
        
fm_give_item(id,g_weapon_name[g_weapon]);
        
        
//give the user his knife back
        
fm_give_item(id,"weapon_knife");    
        
        
giveAmmo(id);
    }
}

/*
* Gives the user the ammo for his weapons
*/
public giveAmmo(id)
{
    
ExecuteHam(Ham_GiveAmmo,id,200,g_weapon_ammo[g_weapon],200);
}

/*
* simple spawnPlayer method. spawns player.
* credits:
* https://forums.alliedmods.net/showpost.php?p=678294&postcount=19
*/
public spawnPlayer(id)
{
    
// Disconnected, already spawned, or switched to Spectator
    
if (!is_user_connected(id
    || 
is_user_alive(id
    || 
cs_get_user_team(id) == CS_TEAM_SPECTATOR 
    
|| cs_get_user_team(id) == CS_TEAM_UNASSIGNED
    
|| id >32)
    {   
        return;
    }
    
    
// Try to spawn the player setting the appropiate dead flag and forcing a think
    
set_pev(idpev_deadflagDEAD_RESPAWNABLE);
    
dllfunc(DLLFunc_Thinkid);
    
    
// Fix for Bots: DLLFunc_Think won't work on them,
    // but DLLFunc_Spawn does the job without any bugs.
    
if (is_user_bot(id) && pev(idpev_deadflag) == DEAD_RESPAWNABLE)
    {
        
dllfunc(DLLFunc_Spawnid);
    }
}


/*
* simple killUser method. kills player.
*/
public killUser(id)
{
    if(
is_user_alive(id) && id <= 32)
    {
        
user_kill(id);
    }
}

/*
* respawns player on say /respawn. -1 stats. 
* Player could connect and then is just dead and has to wait.
*/
public respawnPlayer(id)
{
    if(
id 32)
    {
        return 
PLUGIN_CONTINUE;
    }
    new 
CsTeams:team cs_get_user_team(id);
    if(
team == CS_TEAM_CT || team == CS_TEAM_T)
    {
        
set_task(0.5,"killUser",id);
    }
    return 
PLUGIN_CONTINUE;
}

/*
* called on change of TeamInfo. spawns player if neccessary
*/
public teamAssigned()
{
    new 
id read_data(1);
    if(
id 32 || id == g_bots[0] || id == g_bots[1])
    {
        return;
    }
    if(
is_user_connected(id) && !is_user_hltv(id))
    {
        if(
is_user_alive(id))
        {
            
g_firstTeamJoin[id-1] = true;
            return;
        }
        
        new 
szTeam[2];
        
        
read_data(2szTeamcharsmax(szTeam))
        
        switch(
szTeam[0])
        {
            case 
'T','C':
            {
                if(!
g_firstTeamJoin[id-1])
                {
                    
dllfunc(DLLFunc_Spawn,id);
                    
g_firstTeamJoin[id-1] = true;
                }
                else
                {
                    
g_firstTeamJoin[id-1] = false;
                }
            }
            
            default:
            {
                
g_firstTeamJoin[id-1] = true;
            }
        }
    }

__________________

Join Free File hosting - http://db.tt/VvebKSSW
[Free 2 GB cloud storage]
shubhamgulati12 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 11:01.


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