Raised This Month: $ Target: $400
 0% 

[CSS] Choose a Bomb Site & Delete The other Bomb Site


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lascage
Member
Join Date: Nov 2010
Old 07-03-2011 , 12:07   [CSS] Choose a Bomb Site & Delete The other Bomb Site
Reply With Quote #1

Hello ! Sorry for my Bad English, i'm French.

I'm looking for a plugin which allows the Bomber at start of round to delete a bomb site.

I have a plugin that open a Choose Menu, the bomber choose a bomb site where to plant the bomb.

Code:
 
#include <sourcemod>
#include <sdktools>
#include <cstrike>
 
public Plugin:myinfo =
{
    name = "Bomb Site",
    author = "AoT [!] Farzad",
    description = "Displays a menu to the bomber to choose the bomb's destination.",
    version = "1.0.0.0",
    url = "http://www.aotclan.net/"
}
 
public OnPluginStart()
{
    // Hook the spawn event
    HookEvent("player_spawn", Event_Spawn);
}
 
public Event_Spawn(Handle:event,const String:name[],bool:dontBroadcast)
{
    // Get the client id from the event
    new client = GetClientOfUserId(GetEventInt(event, "userid"));

    // Check if client is ingame and a terrorist
    if (IsClientInGame(client) && GetClientTeam(client) == CS_TEAM_T)
    {
        CreateTimer(1.0, Timer_ShowMenu, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
    }
}

public Action:Timer_ShowMenu(Handle:timer, any:userid)
{
    new client = GetClientOfUserId(userid);
    // Check if client is ingame and a terrorist
    if (client && IsClientInGame(client) && IsPlayerAlive(client) && GetClientTeam(client) == CS_TEAM_T)
    {
        // Check to see if the player has the bomb
        new ent = -1;
        if ((ent = GetPlayerWeaponSlot(client, CS_SLOT_C4)) != -1)
        {
            if (!IsValidEntity(ent)) {
                return Plugin_Stop;
            }

            new String:className[32];
            GetEdictClassname(ent, className, sizeof(className));
            
            // Secondary check, its not needed but better safe than sorry
            if (StrEqual(className, "weapon_c4"))
            {
                // Open the menu
                Menu_open(client);
            }
        }
    }
    return Plugin_Stop;
}

public Menu_open(client)
{
    // Create the menu and send it
    new Handle:BombMenu = CreateMenu(Menu_Selection);
    SetMenuTitle(BombMenu, "Ou planter la Bombe ?");

    AddMenuItem(BombMenu, "A", "Bombe Site A");
    AddMenuItem(BombMenu, "B", "Bombe Site B");

    DisplayMenu(BombMenu, client, 20);
}

public Menu_Selection(Handle:menu, MenuAction:action, param1, param2)
{
    if (action == MenuAction_End)
    {
        CloseHandle(menu);
    }
    
    if (action == MenuAction_Select)
    {
        new String:info[32];
        GetMenuItem(menu, param2, info, sizeof(info));

        // Send the message to all the terrorists
        for (new i = 1; i <= MaxClients; i ++)
        {
            if (IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == CS_TEAM_T)
            {
                PrintToChat(i, "\x05[Bombe Site]\x01: La Bombe doit etre plante sur le Bombe Site \x03[%s]\x01, suivez la Bombe et protegez la.", info);
            }
        }
    }
}
What i want ?

If the bomber choose the Bomb Site A, the Bomb Site B is deleted.
If the bomber choose the Bomb Site B, the Bomb Site A is deleted.

Thx For your Help =)

Last edited by lascage; 07-03-2011 at 13:01.
lascage is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-04-2011 , 14:40   Re: [CSS] Choose a Bomb Site & Delete The other Bomb Site
Reply With Quote #2

Credits to exvel for his snippet!
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

new g_BombsiteA = -1;
new 
g_BombsiteB = -1
 
public 
Plugin:myinfo =
{
    
name "Bomb Site",
    
author "AoT [!] Farzad",
    
description "Displays a menu to the bomber to choose the bomb's destination.",
    
version "1.0.0.0",
    
url "http://www.aotclan.net/"
}
 
public 
OnPluginStart()
{
    
// Hook the spawn event
    
HookEvent("player_spawn"Event_Spawn);
}

public 
OnClientConnected(client)
{
    
// Thanks to exvel for his snippet
    
GetBomsitesIndexes();
}

public 
Event_Spawn(Handle:event,const String:name[],bool:dontBroadcast)
{
    
// Get the client id from the event
    
new client GetClientOfUserId(GetEventInt(event"userid"));

    
// Check if client is ingame and a terrorist
    
if (IsClientInGame(client) && GetClientTeam(client) == CS_TEAM_T)
    {
        
CreateTimer(1.0Timer_ShowMenuGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action:Timer_ShowMenu(Handle:timerany:userid)
{
    new 
client GetClientOfUserId(userid);
    
// Check if client is ingame and a terrorist
    
if (client && IsClientInGame(client) && IsPlayerAlive(client) && GetClientTeam(client) == CS_TEAM_T)
    {
        
// Check to see if the player has the bomb
        
new ent = -1;
        if ((
ent GetPlayerWeaponSlot(clientCS_SLOT_C4)) != -1)
        {
            if (!
IsValidEntity(ent)) {
                return 
Plugin_Stop;
            }

            new 
String:className[32];
            
GetEdictClassname(entclassNamesizeof(className));
            
            
// Secondary check, its not needed but better safe than sorry
            
if (StrEqual(className"weapon_c4"))
            {
                
// Open the menu
                
Menu_open(client);
            }
        }
    }
    return 
Plugin_Stop;
}

public 
Menu_open(client)
{
    
// Create the menu and send it
    
new Handle:BombMenu CreateMenu(Menu_Selection);
    
SetMenuTitle(BombMenu"Ou planter la Bombe ?");

    
AddMenuItem(BombMenu"A""Bombe Site A");
    
AddMenuItem(BombMenu"B""Bombe Site B");

    
DisplayMenu(BombMenuclient20);
}

public 
Menu_Selection(Handle:menuMenuAction:actionparam1param2)
{
    if (
action == MenuAction_End)
    {
        
CloseHandle(menu);
    }
    
    if (
action == MenuAction_Select)
    {
        new 
String:info[32];
        
GetMenuItem(menuparam2infosizeof(info));

        if(
g_BombsiteA != -&& g_BombsiteB != -1)
        {
            if(
StrEqual(info"A"))
            {
                
AcceptEntityInput(g_BombsiteA"Enable");
                
AcceptEntityInput(g_BombsiteB"Disable");
            }
            else if(
StrEqual(info"B"))
            {
                
AcceptEntityInput(g_BombsiteA"Disable");
                
AcceptEntityInput(g_BombsiteB"Enable");
            }
        }
        
        
// Send the message to all the terrorists
        
for (new 1<= MaxClients++)
        {
            if (
IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == CS_TEAM_T)
            {
                
PrintToChat(i"\x05[Bombe Site]\x01: La Bombe doit etre plante sur le Bombe Site \x03[%s]\x01, suivez la Bombe et protegez la."info);
            }
        }
    }
}

GetBomsitesIndexes()
{
    new 
index = -1;
    
    new 
Float:vecBombsiteCenterA[3];
    new 
Float:vecBombsiteCenterB[3];
    
    
index FindEntityByClassname(index"cs_player_manager");
    if (
index != -1)
    {
        
GetEntPropVector(indexProp_Send"m_bombsiteCenterA"vecBombsiteCenterA);
        
GetEntPropVector(indexProp_Send"m_bombsiteCenterB"vecBombsiteCenterB);
    }
    
    
index = -1;
    while ((
index FindEntityByClassname(index"func_bomb_target")) != -1)
    {
        new 
Float:vecBombsiteMin[3];
        new 
Float:vecBombsiteMax[3];
        
        
GetEntPropVector(indexProp_Send"m_vecMins"vecBombsiteMin);
        
GetEntPropVector(indexProp_Send"m_vecMaxs"vecBombsiteMax);
        
        if (
IsVecBetween(vecBombsiteCenterAvecBombsiteMinvecBombsiteMax))
        {
            
g_BombsiteA index;
        }
        else if (
IsVecBetween(vecBombsiteCenterBvecBombsiteMinvecBombsiteMax))
        {
            
g_BombsiteB index;
        }
    }


stock bool:IsVecBetween(const Float:vecVector[3], const Float:vecMin[3], const Float:vecMax[3])
{
    return ( (
vecMin[0] <= vecVector[0] <= vecMax[0]) &&
             (
vecMin[1] <= vecVector[1] <= vecMax[1]) &&
             (
vecMin[2] <= vecVector[2] <= vecMax[2])    );

__________________
Peace-Maker is offline
lascage
Member
Join Date: Nov 2010
Old 07-05-2011 , 04:35   Re: [CSS] Choose a Bomb Site & Delete The other Bomb Site
Reply With Quote #3

Thx
lascage is offline
lascage
Member
Join Date: Nov 2010
Old 07-06-2011 , 15:21   Re: [CSS] Choose a Bomb Site & Delete The other Bomb Site
Reply With Quote #4

I can't compile the script.

Error at line 154 i think.

Plz how compile it ?
lascage is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-06-2011 , 23:25   Re: [CSS] Choose a Bomb Site & Delete The other Bomb Site
Reply With Quote #5

Nothing wrong in that script, you have mess something up.
Try again copy/paste example here web compiler
http://www.sourcemod.net/compiler.php
Bacardi is online now
lascage
Member
Join Date: Nov 2010
Old 07-07-2011 , 11:45   Re: [CSS] Choose a Bomb Site & Delete The other Bomb Site
Reply With Quote #6

Code:
Your plugin failed to compile!

Read the errors below:
SourcePawn Compiler 1.3.7 Copyright (c) 1997-2006, ITB CompuPhase, (C)2004-2008 AlliedModders, LLC  /home/groups/sourcemod/upload_tmp/phpXaTuGz.sp(156) : error 030: compound statement not closed at the end of file (started at line 154)  1 Error.
Help Plz
lascage is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-07-2011 , 12:14   Re: [CSS] Choose a Bomb Site & Delete The other Bomb Site
Reply With Quote #7

Whys it so hard do simple task !! ??
Attached Files
File Type: smx asd.smx (4.6 KB, 247 views)
Bacardi is online now
Dj Sadin
Junior Member
Join Date: Jul 2012
Old 08-08-2012 , 23:07   Re: [CSS] Choose a Bomb Site & Delete The other Bomb Site
Reply With Quote #8

Quote:
Originally Posted by Bacardi View Post
Whys it so hard do simple task !! ??
LOl
Dj Sadin 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:23.


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