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

Simple Bombsite limiter...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
motto
Member
Join Date: Aug 2009
Location: Poland
Old 01-11-2010 , 00:55   Simple Bombsite limiter...
Reply With Quote #1

Hello,

I'm write now "Simple Bombsite Limiter" for CSS. Look this please...

---
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#pragma semicolon 1

new Handle:Cvar_mp4ab = INVALID_HANDLE;
public Plugin:myinfo =
{
name = "Simple BS Limiter",
author = "motto",
version = "1.0",
url = "http://infamous-clan.eu/"
}

new count;
public OnPluginStart()
{
Cvar_mp4ab = CreateConVar("sm_mp4ab", "8", "Min players required to unrestrict all bombsite");
HookEvent("round_start",Event_RoundStart);
HookEvent("bomb_beginplant",Event_BombBeginPl ant);
}


public Event_RoundStart (Handle:event, const String:name[], bool:dontBroadcast)
{
count = GetClientCount();
}

public Event_BombBeginPlant (Handle:event, const String:name[], bool:dontBroadcast)
{
if(GetConVarInt(Cvar_mp4ab) > count)
{
new bs = GetEventInt(event,"site");
new player = GetClientOfUserId(GetEventInt(event,"userid") );
/*
(...)
*/
}
}

I have two problems now. First, function GetClientOfUserId(GetEventInt(event,"userid") ) return (yeeeees) site (B or A) and GetEventInt(event,"site") return ... hmm I don't know what is it... Maybe this is bug. So, (this is 2nd problem) I don't know how to (if enough players and bad site) droped C4 on event bomb_beginplant. Idea is simple, if players < 8 then and bombsite = A the (on "bomb_beginplant") drop C4...
Anyone Can help me?
motto is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 01-11-2010 , 01:52   Re: Simple Bombsite limiter...
Reply With Quote #2

1. Theres no point in using pragma semi-colon

2. Your probably going to want to check the player count more then once, becuase if some one leaves or connects during the round it will throw your plugin off. Try getting player count at player connect and disconnect too.

3. Every event you call needs to be an action like this


PHP Code:



public Action:Event_BombBeginPlant (Handle:event, const String:name[], bool:dontBroadcast

4. Use code tags in your post to make it them easier to read

5. Also this is the correct way to get the Client ID of a user in a event.

PHP Code:

new clientID GetEventInt(event,"userid");
new 
client GetClientOfUserId(clientID); 
__________________

Last edited by Peoples Army; 01-11-2010 at 02:01.
Peoples Army is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 01-11-2010 , 02:18   Re: Simple Bombsite limiter...
Reply With Quote #3

I use #pragma semicolon 1 in everything I make. I prefer semicolons because it's more like C++.

The pragma helps keep it consistent. Semicolons are just a good habit to get into I think. Considering the most widely used language uses them.
__________________
Greyscale is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 01-11-2010 , 02:21   Re: Simple Bombsite limiter...
Reply With Quote #4

I use semi colons in everything I do, but if your used to using them with other languages than it should already be habit and you wont need that.
__________________
Peoples Army is offline
motto
Member
Join Date: Aug 2009
Location: Poland
Old 01-13-2010 , 21:10   Re: Simple Bombsite limiter...
Reply With Quote #5

Code:
#include <sourcemod>    
#include <sdktools>
#include <cstrike>
#pragma semicolon 1

public Plugin:myinfo =
{
    name = "Bombsite Limiter",
    author = "impact",
    description = "?",
    version = "1.0",
    url = "http://infamous-clan.eu/"
}
new bombsite_index[2];

public OnPluginStart()
{
    HookEvent("round_start",Event_RoundStart);
}

public OnMapStart()
{
    new index = -1;
    bombsite_index[0] = -1;
    bombsite_index[1] = -1;
    while ((index = FindEntityByClassname(index,"func_bomb_target")) != -1)
    {
        if (bombsite_index[0] == -1) bombsite_index[0] = index;
        if ((bombsite_index[1] == -1)  && (index != bombsite_index[0])) bombsite_index[1] = index;
    }
    PrintToConsole (0,"[Bombsite Limiter Debug] bombsite_index[0]: %d, bombsite_index[1]:%d",bombsite_index[0],bombsite_index[1]);    
}
public Action:Event_RoundStart (Handle:event, const String:name[], bool:dontBroadcast)
{
    new player_count = GetClientCount();
    if ((bombsite_index[0] != -1) && (bombsite_index[1] != -1))
    {
        if (player_count < 8)
        {
            new index;
            new bombsite_disabled_index;
            new bombsite_enabled_index;
            index = GetRandomInt(1,2);
            PrintToConsole (0,"[Bombsite Limiter Debug] disabled index: %d,",index);
            if (index == 1)
            {
                bombsite_disabled_index = bombsite_index[0];
                bombsite_enabled_index = bombsite_index[1];
            }
            else
            {
                bombsite_disabled_index = bombsite_index[1];
                bombsite_enabled_index = bombsite_index[0];
            }
            PrintToConsole (0,"[Bombsite Limiter Debug] bombsite_enabled_index: %d, bombsite_disabled_index:%d",bombsite_enabled_index,bombsite_disabled_index);
            AcceptEntityInput(bombsite_disabled_index,"Disable");
            AcceptEntityInput(bombsite_enabled_index,"Enable");

            new bombsite_enabled_letter;
            bombsite_enabled_letter = bombsite_enabled_index; //NEED HELP HERE!!!
            PrintToChatAll ("Due to the low number of players in this round, only one bombsite (%d) is now enabled.",bombsite_enabled_letter);
        }
        else
        {
            AcceptEntityInput(bombsite_index[0],"Enable");
            AcceptEntityInput(bombsite_index[1],"Enable");
        }
    }
}

Last edited by motto; 01-16-2010 at 09:20.
motto 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 12:22.


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