Raised This Month: $32 Target: $400
 8% 

[CS:GO] Random bomb give ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 12-21-2015 , 12:23   [CS:GO] Random bomb give ?
Reply With Quote #1

I have this plugin that doesn't allow terrorists to plant the bomb until the last minute:
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <sdkhooks>

#define LAST_C4_TIME 60

float g_flNextC4PlantTime;

public 
void OnPluginStart() {
    
HookEvent("round_start"OnRoundStartEventHookMode_Post);
}

public 
void OnRoundStart(Event event, const char[] namebool dontBroadcast) {
    
g_flNextC4PlantTime GetGameTime() + float(GameRules_GetProp("m_iRoundTime") - LAST_C4_TIME);
}

public 
Action OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon, &subtype, &cmdnum, &tickcount, &seedmouse[2])
{
    if (
IsPlayerAlive(client))
    {
        if (
GetEntPropEnt(clientProp_Data"m_hActiveWeapon") == GetPlayerWeaponSlot(clientCS_SLOT_C4) && GetGameTime() < g_flNextC4PlantTime)
        {
            
PrintHintText(client"<font color='00ff00'>You can't plant the bomb until the last minute of the round.</font>");
            if (
buttons IN_ATTACK)
            {
                
buttons &= ~IN_ATTACK;
            }
            if (
buttons IN_USE)
            {
                
buttons &= ~IN_USE;
            }
            if (
GetGameTime() == 60)
            {
                
PrintHintTextToAll("<font color='#00ff00'><b>You can plant the bomb.</b></font>");
            }
        }
    }

But I need it to give the bomb to a random player in the last 60 seconds.
Thanks
EDIT: I need it to announce through PrintHintText who got the bomb
__________________

Last edited by valio_skull; 12-21-2015 at 12:23.
valio_skull is offline
bally
Senior Member
Join Date: Aug 2015
Old 12-21-2015 , 13:22   Re: [CS:GO] Random bomb give ?
Reply With Quote #2

Quote:
Originally Posted by valio_skull View Post
I have this plugin that doesn't allow terrorists to plant the bomb until the last minute:
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <sdkhooks>

#define LAST_C4_TIME 60

float g_flNextC4PlantTime;

public 
void OnPluginStart() {
    
HookEvent("round_start"OnRoundStartEventHookMode_Post);
}

public 
void OnRoundStart(Event event, const char[] namebool dontBroadcast) {
    
g_flNextC4PlantTime GetGameTime() + float(GameRules_GetProp("m_iRoundTime") - LAST_C4_TIME);
}

public 
Action OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon, &subtype, &cmdnum, &tickcount, &seedmouse[2])
{
    if (
IsPlayerAlive(client))
    {
        if (
GetEntPropEnt(clientProp_Data"m_hActiveWeapon") == GetPlayerWeaponSlot(clientCS_SLOT_C4) && GetGameTime() < g_flNextC4PlantTime)
        {
            
PrintHintText(client"<font color='00ff00'>You can't plant the bomb until the last minute of the round.</font>");
            if (
buttons IN_ATTACK)
            {
                
buttons &= ~IN_ATTACK;
            }
            if (
buttons IN_USE)
            {
                
buttons &= ~IN_USE;
            }
            if (
GetGameTime() == 60)
            {
                
PrintHintTextToAll("<font color='#00ff00'><b>You can plant the bomb.</b></font>");
            }
        }
    }

But I need it to give the bomb to a random player in the last 60 seconds.
Thanks
EDIT: I need it to announce through PrintHintText who got the bomb
for loop for all client index and GetRandomInt and GiveBomb??
__________________
Perhaps my lack of faith was my undoing,

Last edited by bally; 12-21-2015 at 13:22.
bally is offline
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 12-21-2015 , 13:47   Re: [CS:GO] Random bomb give ?
Reply With Quote #3

Quote:
Originally Posted by bally View Post
for loop for all client index and GetRandomInt and GiveBomb??
Exactly. I'm just noob and I don't know how to do it...
__________________
valio_skull is offline
bally
Senior Member
Join Date: Aug 2015
Old 12-21-2015 , 14:03   Re: [CS:GO] Random bomb give ?
Reply With Quote #4

PHP Code:
public void init()
{
    
int clindexcount 0;
    for (
int i 1MaxClientsi++)
    {
        if(
IsClientInGame(i) && IsPlayerAlive(i))
        {
            
clindexcount++;
            continue;
        }
        
        if (
clindexcount 0// there's actually players...
        
{
            
removeBomb();
            
int tempcl GetRandomInt(0clindexcount);
            
GivePlayerItem(tempcl"weapon_c4");
        }
    }
}

any:BomberID()
{
    for (
int cl MaxClientscl >= 1; --cl)
    {
        if (
IsClientInGame(cl) && 
                
IsPlayerAlive(cl) &&
                
GetPlayerWeaponSlot(cl4) != -1)
        {
            return 
cl// ID of the bomber
        
}
    }
    return 
0;
}

any:removeBomb()
{
    
int bomberindex BomberID();
    
    if (
bomberindex != 0
    {        
        
int iEntIndex GetPlayerWeaponSlot(bomberindex4);
        
char sClassName[128];
        
GetEdictClassname(iEntIndexsClassNamesizeof(sClassName));  
        if ( 
StrEqualsClassName"weapon_c4"false ) )  
        {
            
RemovePlayerItem(bomberindexiEntIndex); 
            
AcceptEntityInput(iEntIndex"kill");
        }
    }
    else 
    {
        
// Bomb not found?
    
}
    
    return 
bomberindex;

You mean this?
__________________
Perhaps my lack of faith was my undoing,
bally is offline
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 12-21-2015 , 14:13   Re: [CS:GO] Random bomb give ?
Reply With Quote #5

Quote:
Originally Posted by bally View Post
PHP Code:
public void init()
{
    
int clindexcount 0;
    for (
int i 1MaxClientsi++)
    {
        if(
IsClientInGame(i) && IsPlayerAlive(i))
        {
            
clindexcount++;
            continue;
        }
        
        if (
clindexcount 0// there's actually players...
        
{
            
removeBomb();
            
int tempcl GetRandomInt(0clindexcount);
            
GivePlayerItem(tempcl"weapon_c4");
        }
    }
}

any:BomberID()
{
    for (
int cl MaxClientscl >= 1; --cl)
    {
        if (
IsClientInGame(cl) && 
                
IsPlayerAlive(cl) &&
                
GetPlayerWeaponSlot(cl4) != -1)
        {
            return 
cl// ID of the bomber
        
}
    }
    return 
0;
}

any:removeBomb()
{
    
int bomberindex BomberID();
    
    if (
bomberindex != 0
    {        
        
int iEntIndex GetPlayerWeaponSlot(bomberindex4);
        
char sClassName[128];
        
GetEdictClassname(iEntIndexsClassNamesizeof(sClassName));  
        if ( 
StrEqualsClassName"weapon_c4"false ) )  
        {
            
RemovePlayerItem(bomberindexiEntIndex); 
            
AcceptEntityInput(iEntIndex"kill");
        }
    }
    else 
    {
        
// Bomb not found?
    
}
    
    return 
bomberindex;

You mean this?
That's not exactly what I want...
I want to give the bomb to a random player when it's one minute remaning, and to announce through PrintHintText who got the bomb...
__________________
valio_skull is offline
bally
Senior Member
Join Date: Aug 2015
Old 12-21-2015 , 14:17   Re: [CS:GO] Random bomb give ?
Reply With Quote #6

I'm not going to make your code, I already gave you what you need.
__________________
Perhaps my lack of faith was my undoing,
bally is offline
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 12-21-2015 , 14:31   Re: [CS:GO] Random bomb give ?
Reply With Quote #7

Quote:
Originally Posted by bally View Post
I'm not going to make your code, I already gave you what you need.
ok... I will try to make it, I will fail, I will load the faliure on my host, the server will crash and I'll lose my players. Thanks for that code, T/C please
EDIT: Don't trash the topic, I don't have time to make the plugin right now, and I need that code
__________________

Last edited by valio_skull; 12-21-2015 at 14:32.
valio_skull is offline
bally
Senior Member
Join Date: Aug 2015
Old 12-21-2015 , 15:20   Re: [CS:GO] Random bomb give ?
Reply With Quote #8

Quote:
Originally Posted by valio_skull View Post
ok... I will try to make it, I will fail, I will load the faliure on my host, the server will crash and I'll lose my players. Thanks for that code, T/C please
EDIT: Don't trash the topic, I don't have time to make the plugin right now, and I need that code
It is not my fault you aren't spending any time whatsoever, to learn the basics of the basics of sourcemod, the only thing you had to do was to re-arrange my code to fit in yours.
I wasted my OWN time to try and help you more than I ever had too. I've made your code, took care of some problems you might run into, and I basically developed the entire plugin... Now you consider I'm trashing your topic? Because I didn't made YOUR PLUGIN? lmao

If it wasn't for other people that might wanted to learn, I'd regret posting my code.
__________________
Perhaps my lack of faith was my undoing,

Last edited by bally; 12-21-2015 at 15:26.
bally is offline
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 12-21-2015 , 15:44   Re: [CS:GO] Random bomb give ?
Reply With Quote #9

Quote:
Originally Posted by bally View Post
It is not my fault you aren't spending any time whatsoever, to learn the basics of the basics of sourcemod, the only thing you had to do was to re-arrange my code to fit in yours.
I wasted my OWN time to try and help you more than I ever had too. I've made your code, took care of some problems you might run into, and I basically developed the entire plugin... Now you consider I'm trashing your topic? Because I didn't made YOUR PLUGIN? lmao

If it wasn't for other people that might wanted to learn, I'd regret posting my code.
I tried to do it. Clients are crashing:
PHP Code:
CUtlLinkedList overflow! (exhausted index range
Edit: That's not MY plugin, I'm not taking any credits for it and I'm not posting it anywhere. And I'm not here to learn, I just need that plugin, and I don't know how to do it.
__________________

Last edited by valio_skull; 12-21-2015 at 16:25.
valio_skull 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 23:09.


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