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

CSGO random event (public void event_something)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BassPower
Member
Join Date: Mar 2011
Location: Lithuania
Old 10-11-2017 , 07:10   CSGO random event (public void event_something)
Reply With Quote #1

Hey guys, how i can do random events. I have knife, deagle or more rounds and want do random rounds: 10, 15, 20 rounds. Pls help

Code:
char RoundEvent[][] =  { "event_knife", "event_dgl" };
int RoundEventId[MAXPLAYERS + 1];

int random = GetRandomInt(0, 1);
RoundEventId[client] = random;


public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if (GameRules_GetProp("m_totalRoundsPlayed") == 10)
{
RoundEvent[RoundEventId[client]];
} else if (GameRules_GetProp("m_totalRoundsPlayed") == 15)
{
RoundEvent[RoundEventId[client]];
}
BassPower is offline
Bobakanoosh
Senior Member
Join Date: Sep 2015
Location: United States
Old 10-11-2017 , 13:31   Re: CSGO random event (public void event_something)
Reply With Quote #2

My compiler's bugged on my laptop, but this should work fine:
PHP Code:
int g_iEventDay;
enum RoundType {

    
RoundType_None 0
    RoundType_Deagle 
1,
    
RoundType_AWP 2,
    
RoundType_Knife 3,
    
//etc

}

public 
void OnPluginStart()
{
    
    
HookEvent("player_spawn"Event_PlayerSpawn);
    
HookEvent("round_start"Event_RoundStart_PreEventHookMode_Pre);
    
}

public 
Action Event_PlayerSpawn(Event eventchar[] namebool dontBroadcast) {

    if(
g_iEventDay == RoundType_Deagle) {
    
        
// Do stuff
    
    
} else if(g_iEventDay == RoundType_AWP) {
    
        
// Do stuff
    
    
} else if(g_iEventDay == RoundType_Knife) {
    
        
// Do stuff
    
    
}

}

public 
Action Event_RoundStart_Pre(Event eventchar[] namebool dontBroadcast) {

    
// If the round is a divisible by 5.
    
if (GameRules_GetProp("m_totalRoundsPlayed") % == 0) {
                                                       
// First round type to the last round type
        
g_iEventDay GetRandomInt(RoundType_DeagleRoundType_Knife);
    
    } else {
    
        
g_iEventDay RoundType_None;
    
    }



Last edited by Bobakanoosh; 10-11-2017 at 13:38.
Bobakanoosh is offline
BassPower
Member
Join Date: Mar 2011
Location: Lithuania
Old 10-13-2017 , 06:29   Re: CSGO random event (public void event_something)
Reply With Quote #3

not working i edited but tag mismatch

Code:
int g_iEventDay;

enum RoundType
{
	RoundType_None = 0, 
	RoundType_WarmUp = 1, 
	RoundType_Knife = 2, 
	RoundType_NoScope = 3, 
	RoundType_HSDeagle = 4, 
	RoundType_Primary = 5, 
	RoundType_Rifles = 6, 
	RoundType_Secondary = 7, 
	RoundType_ShotGuns = 8
};

public Action Event_RoundStartMode(Event event, const char[] name, bool dontBroadcast)
{
	if (GameRules_GetProp("m_bWarmupPeriod") == 1)
	{
		g_iEventDay == RoundType_WarmUp;
	} 
               // If the round is a divisible by 5.
	else if (GameRules_GetProp("m_totalRoundsPlayed") % 5 == 0)
	{
		// First round type to the last round type
		g_iEventDay == GetRandomInt(RoundType_Knife, RoundType_NoScope, RoundType_HSDeagle, RoundType_Primary, RoundType_Rifles, RoundType_Secondary, RoundType_ShotGuns);
	} else {
		
		g_iEventDay == RoundType_None;
		
	}
}

public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
	int client = GetClientOfUserId(event.GetInt("userid"));
	if (g_iEventDay == RoundType_WarmUp)
	{
		event_warmup(client);
	} else if (g_iEventDay == RoundType_Knife)
	{
		event_kniferound(client);
	} else if (g_iEventDay == RoundType_NoScope)
	{
		event_noscoperound(client);
	} else if (g_iEventDay == RoundType_HSDeagle)
	{
		event_headshotround(client);
	} else if (g_iEventDay == RoundType_Primary)
	{
		event_primaryround(client);
	} else if (g_iEventDay == RoundType_Rifles)
	{
		event_riflesround(client);
	} else if (g_iEventDay == RoundType_Secondary)
	{
		event_secondaryround(client);
	} else if (g_iEventDay == RoundType_ShotGuns)
	{
		event_shotgunsround(client);
	} else if (g_iEventDay == RoundType_None)
	{
		event_handlespawn(client);
	}
}

Last edited by BassPower; 10-13-2017 at 08:25.
BassPower is offline
Bobakanoosh
Senior Member
Join Date: Sep 2015
Location: United States
Old 10-13-2017 , 15:25   Re: CSGO random event (public void event_something)
Reply With Quote #4

A few things:

== is used for comparing two things, not setting them equal to one another.

PHP Code:
g_iEventDay == RoundType_WarmUp
should be
PHP Code:
g_iEventDay RoundType_WarmUp
Also, you're using GetRandomInt wrong. Look here: https://sm.alliedmods.net/new-api/halflife/GetRandomInt for more information.

One last thing, what are you doing in your functions event_headshotround(client), etc?

Edit: Your enum should look like this, sorry, was using old syntax:

PHP Code:
enum 
{
    
RoundType_None
    
RoundType_WarmUp
    
RoundType_Knife
    
RoundType_NoScope
    
RoundType_HSDeagle
    
RoundType_Primary
    
RoundType_Rifles
    
RoundType_Secondary
    
RoundType_ShotGuns,


Last edited by Bobakanoosh; 10-13-2017 at 15:28. Reason: fixing enum
Bobakanoosh is offline
BassPower
Member
Join Date: Mar 2011
Location: Lithuania
Old 10-16-2017 , 07:10   Re: CSGO random event (public void event_something)
Reply With Quote #5

ok working, Thanks Bobakanoosh
BassPower is offline
Reply


Thread Tools
Display Modes

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 19:26.


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